2

I have downloaded the latest OSGeo4w (GDAL 2.4) and GDAL 2.4 (from GIS Internals site) but I cant get the below command to correctly reproject the shapes in either application.

I used the command below

ogr2ogr.exe  -f MSSQLSpatial "MSSQL:server=blah;database=blah;trusted_connection=yes;" "MSSQL:server=blah;database=blah;trusted_connection=yes;" -overwrite -sql "select databaseName,objectid,shape from gm.dbo.stg_polygon" -s_srs "EPSG:26910" -t_srs "EPSG:102008" -lco "UPLOAD_GEOM_FORMAT=wkt" -lco "GEOM_TYPE=geometry" -lco "GEOMETRY_NAME=shape" -nlt POLYGON  -nln "stg_ztest"

It always returns a spatial SRID = 32768. We are loading into SQL Server 2017.This works correctly using OSGeo4W shell (from QGIS 2.18) in GDAL 2.2.1

1 Answer 1

4

The other GDAL is somehow missing the definitions of ESRI projections. You can read the Proj string from your OSGeo4W installation and use that as -t_srs

gdalsrsinfo epsg:102008

PROJ.4 : +proj=aea +lat_1=20 +lat_2=60 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs

This command should make correct transformatiton for your coordinates:

ogr2ogr.exe  -f MSSQLSpatial "MSSQL:server=blah;database=blah;trusted_connection=yes;" "MSSQL:server=blah;database=blah;trusted_connection=yes;" -overwrite -sql "select databaseName,objectid,shape from gm.dbo.stg_polygon" -s_srs "EPSG:26910" -t_srs "+proj=aea +lat_1=20 +lat_2=60 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs" -lco "UPLOAD_GEOM_FORMAT=wkt" -lco "GEOM_TYPE=geometry" -lco "GEOMETRY_NAME=shape" -nlt POLYGON  -nln "stg_ztest"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.