1

I am having issues importing a SHP file into SQLServer. The SHP file is EPSG 28354 (drawn in QGIS 3.x) and has these assoc files:

  • REE_ProjectAreas.cpg
  • REE_ProjectAreas.dbf
  • REE_ProjectAreas.prj
  • REE_ProjectAreas.shp
  • REE_ProjectAreas.shx

The ogr2ogr.exe I am using is from OSGeo4w v 3.3.1 (from https://trac.osgeo.org/osgeo4w) which installed itself into c:\OSGeo4w

the two Windows commands I am using are:

call c:\OSGeo4W\bin\o4w_env.bat

c:\OSgeo4w\bin\ogr2ogr.exe  -progress -f MSSQLSpatial  "MSSQL:server=HSLT_17;database=REE_DHSS;trusted_connection=yes"  "c:\temp\REE_ProjectAreas.shp"  -a_srs "ESPG:28354"

The error I get is:

ERROR 1: Failed to process SRS definition: ESPG:28354

if I remove the -a_srs "ESPG:28354" part then the SHP file gets imported but the SRID is incorrect in the assoc SQL tables that ogr2ogr creates and populates: enter image description here enter image description here

the contents of the o4w_env.bat is:

REM Make parent of this script location our current directory,
REM converting UNC path to drive letter if needed
pushd %~dp0
cd ..

REM set OSGEO4W_ROOT to short path version
for %%i in ("%CD%") do set OSGEO4W_ROOT=%%~fsi

REM start with clean path
set path=%OSGEO4W_ROOT%\bin;%WINDIR%\system32;%WINDIR%;%WINDIR%\WBem
for %%f in ("%OSGEO4W_ROOT%\etc\ini\*.bat") do call "%%f"

popd

After running that the path is pretty clean:

PATH=c:\OSGeo4W\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\WBem

The contents of the REE_ProjectAreas.prj is:

PROJCS["GDA_1994_MGA_Zone_54",GEOGCS["GCS_GDA_1994",DATUM["D_GDA_1994",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",10000000.0],PARAMETER["Central_Meridian",141.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]

i found:

“Cannot find proj.db” and "ERROR 1: PROJ: proj_create_from_database: cannot build geodeticCRS 4326" errors

but that is not quite the same. I am setting my path to be clean and only use c:\OSGeo4W\bin

Also tried ogr2ogr from within C:\Program Files\QGIS 3.10\bin, same problem.

Why does ogr2ogr not import the SHP into SQL with the correct EPSG?

1 Answer 1

2

You have a typo in your command, it should be:

c:\OSgeo4w\bin\ogr2ogr.exe  -progress -f MSSQLSpatial  "MSSQL:server=HSLT_17;database=REE_DHSS;trusted_connection=yes"  "c:\temp\REE_ProjectAreas.shp"  -a_srs "EPSG:28354"

That's EPSG not ESPG

1
  • duh, sorry, my bad. good catch ... works now.
    – LukeB
    Commented Sep 21, 2022 at 8:16

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.