[gdal-dev] Dataloss after importing and exporting Shapefile

Suter, Raphael (Softec) Raphael.Suter at softec.ch
Tue Mar 1 05:46:47 PST 2016


Hi subscribers

I'm using ogr2ogr to import an ESRI Shapefile to our SQL DB (SQL 2008). When I import the file, after 50% of the time, the inserts start to fail.

Command: ogr2ogr -overwrite -f "MSSQLSpatial" "MSSQL:server=URL;database=DBNAME;uid=user;pwd=pwd;" file.shp -a_srs http://spatialreference.org/ref/epsg/2056/ -nln "gis.OGR2OGRTEST" -progress -skipfailures
Error: "ERROR 1: INSERT command for new feature failed."

So one part of the data get lost right here. But if I export the data to a Shapefile again, there will more data get lost and I'm getting the same error multiple times.

Command for export:  ogr2ogr -f "ESRI Shapefile" "H:\OGR2OGR\Files\export\shp\export.shp" "MSSQL:server=URL;database=DBNAME;uid=user;pwd=pwd;" -sql "SELECT * FROM gis.OGR2OGRTEST" -a_srs http://spatialreference.org/ref/epsg/2056/"
Error: "Warning 1: Value 41171617.503899999 of field area of feature 2667 not successfully written. Possibly due to too larger number with respect to field width"


The original shapefile is 18k in size, the new one is only 9k, so like half of the data got lost. Am I doing something wrong on the import/export?

Thank you for your help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160301/451fad99/attachment.html>


More information about the gdal-dev mailing list