ogr2ogr does not create tables
Asked Answered
C

1

6

im trying to import some shapes to SQL using ogr2ogr command following this guide https://alastaira.wordpress.com/ogr2ogr-patterns-for-sql-server/

Im using this command:

ogr2ogr -overwrite -f MSSQLSpatial [connection string] [shapefile] -nln "shape3" -nlt GEOMETRY

and getting this error:

ERROR 1: INSERT command for new feature failed. [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'dbo.shape3'. ERROR 1: Unable to write feature 0 from layer tl_2010_06_zcta510. ERROR 1: Terminating translation prematurely after failed translation of layer tl_2010_06_zcta510 (use -skipfailures to skip errors)

The command does not create the table and the inserts fails.

I tried to create the table first and using the command to insert on it:

ogr2ogr -f "MSSQLSpatial" [connection string] [shapefile] -a_srs "ESPG:4269" -lco "GEOM_TYPE=geography" -lco "GEOM_NAME=area" -nln "shapes3"

It works fine exept that it does not load the GEOGRAPHY colum (area), it remains NULL.

Im using the file provided in the guide and the user in the connection string is the admin so it is not a permission problem.

Thank you all in advance.

Carmen answered 10/9, 2018 at 14:10 Comment(0)
C
9

Solved it adding -lco UPLOAD_GEOM_FORMAT=wkt to the command, its related to some geometry formating.

UPLOAD_GEOM_FORMAT: (From GDAL 2.0.0) Specify the geometry format (wkb or wkt) when creating or modifying features. The default is wkb. https://www.gdal.org/drv_mssqlspatial.html

Carmen answered 10/9, 2018 at 19:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.