0

I'm trying to import German NAS-Data into a SQLite- Spatialite-database. For this I use the following command:

ogr2ogr -f SQLITE --config OGR_SQLITE_CACHE 8192 -gt 65536 -skipfailures -s_srs "+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=500000 +y_0=0 +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7 +units=m +no_defs" -t_srs EPSG:31468 data.sqlite data.xml

This takes quite some time, but finally a SQLite database will be produced. But if I try to open it with QGis I'm told that QGis faild to check metadata. I'm not sure what is missing in the above command.

For dataprotection reasons I cannot provide real data - Testdata can be downloaded from this (official) link: https://ldbv.bayern.de/file/zip/2407/Testdaten_Lurchingen_ALKIS.zip

Can anybody help?

2
  • What does ogrinfo say about your SQLite database? You might want to try the -al and -so options (all layers, summary only). Without your data it might be hard to figure this out...
    – Spacedman
    Commented Mar 10, 2019 at 15:43
  • As per the Tour there should be only one question asked per question. I recommend asking about the coordinate system in a separate question.
    – PolyGeo
    Commented Mar 10, 2019 at 22:10

1 Answer 1

1

Actually you do not create a SpatiaLite database but a "regular" SQLite database where geometries are stored as FDO geometries. For creating a SpatiaLite database use the corresponding Data store creation option

-f SQLite -dsco spatialite=YES

Read details from https://www.gdal.org/drv_sqlite.html

It may be good to know that -gt option does not have an effect when used together with -skipfailures. Skipfailures sets the size of the transaction into 1 which makes is possible to rollback the insertion of one single row. Unfortunately with SQLite databases it is quite slow to make a transaction. Try first without -skipfailures. If there are no errors you will get the job done much faster. The ogr2ogr manual page https://www.gdal.org/ogr2ogr.html seems to give misleading information about this However, note that if there are failed insertions, the scope of -skipfailures is a whole transaction.

Try to rewrite your command like this:

ogr2ogr -f SQLITE -dsco spatialite=yes --config OGR_SQLITE_CACHE 8192 -gt 65536 -s_srs "+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=500000 +y_0=0 +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7 +units=m +no_defs" -t_srs EPSG:31468 data.sqlite data.xml

If you want the result to be in EPSG:4647 it is enough to use that as -t_srs. But I do you know that your proj string for the input data (-s_srs) is still correct?

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