Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ogr2ogr does not create tables

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.

like image 516
LaPregunta Avatar asked Sep 10 '18 14:09

LaPregunta


People also ask

Why is SQL so slow?

Memory Contention SQL Server caches the databases in what's called a buffer pool. A buffer pool acts as a storage space for data pages that have been recently written or read to and from disk. A small buffer pool will slow down your SQL application by overwhelming the disk's subsystem.

What can be the cause of a database engine running sluggishly on table operations?

Reasons for Slow Database Performance Database/Query: There may be redundant query lines, complex or looping syntaxes, query deadlocks, lack of proper indexing, improper partitioning of database tables, etc.


1 Answers

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

like image 178
LaPregunta Avatar answered Nov 10 '22 22:11

LaPregunta