3

The problem

I'm encountering some issue trying to use ogr2ogr to import some GML input data (not OSM) into Postgres. I'm trying to use COLUMN_TYPES=other_tags=hstore to store all the fields not referenced in the -select option in a hstore-type-column.

The data gets imported, but there is no column of type hstore in the resulting table containing the rest of the fields...

The command I try to use

ogr2ogr -f PostgreSQL "PG:dbname=rem host=192.168.XX.YY user=XXXXX password=XXXXXXX" test.xml -append -nln public.t_test_ogr2ogr_v26 -select gml_id,identifier,beginnt -lco COLUMN_TYPES=other_tags=hstore -nlt geometry

The current result

'ogc_fid';'wkb_geometry';'gml_id';'identifier';'beginnt'
1;'0102000000030...';'DERPTL4a0000zZFt';'urn:adv:oid:DERPTL4a0000zZFt';'2015-11-25T14:28:13Z'
2;'0102000000020...';'DERPTL4a0000AIzO';'urn:adv:oid:DERPTL4a0000AIzO';'2015-11-25T14:28:13Z'
3;'0102000000020...';'DERPTL4a0000AIzP';'urn:adv:oid:DERPTL4a0000AIzP';'2015-11-25T14:28:13Z'

The expected result

The same as above with an additional column of type hstore.

'ogc_fid';'wkb_geometry';'gml_id';'identifier';'beginnt';'tags'
1;'0102000000030...';'DERPTL4a0000zZFt';'urn:adv:oid:DERPTL4a0000zZFt';'2015-11-25T14:28:13Z';'"anlass"=>"3000", "advStandard"=>"DLM50", ...'
2;'0102000000020...';'DERPTL4a0000AIzO';'urn:adv:oid:DERPTL4a0000AIzO';'2015-11-25T14:28:13Z';'"anlass"=>"3000", "advStandard"=>"DLM50", ...'
3;'0102000000020...';'DERPTL4a0000AIzP';'urn:adv:oid:DERPTL4a0000AIzP';'2015-11-25T14:28:13Z';'"anlass"=>"3000", "advStandard"=>"DLM50", ...'

Test Input GML-File (55 KB)

https://haste.zertrin.org/raw/tafomudifi

(if needed, the XSD-files can be found here: http://repository.gdi-de.org/schemas/adv/nas/6.0ea/ )

Corresponding gfs file created automatically by ogr2ogr

https://haste.zertrin.org/raw/diwowideji

  • There may be other issues but at least you do not select the tags at all now -select gml_id,identifier,beginnt – user30184 Feb 16 '16 at 9:27
  • @user30184 tags isn't a field in the input data. This is an exemple of a column name for the HSTORE-column gathering the rest of the fields from the input data through the option COLUMN_TYPES=other_tags=hstore – Zertrin Feb 16 '16 at 9:56
  • Are you sure that it works like that with any other GDAL driver than the OSM driver gdal.org/drv_osm.html? I am rather sure that it doesn't and the virtual other_tags and all_tags field are available only from OSM data and osmconf.ini file. – user30184 Feb 16 '16 at 10:52
  • I'm not sure indeed. This could explain why the virtual fields don't appear. I'm currently looking at gdal.org/drv_nas.html to see if there is more to be done in that direction. – Zertrin Feb 16 '16 at 11:13
  • Your source GML is rather complicated to be used for testing. It seems to contain 10 layers which may all have different schema. I would first extract one layer and tell GDAL to create hstore from one attribute. – user30184 Feb 16 '16 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.