GeoNode / geonode-importer

MIT License
2 stars 15 forks source link

Shapefile import with accompanying cst-file fails #255

Open ridoo opened 2 months ago

ridoo commented 2 months ago

Issue https://github.com/GeoNode/geonode-importer/issues/210 added support for cst files. However, the approach adding the layer create option ENCODING does not work (anymore?) as expected. For example (using vineyards register (Weinbergsrolle) from the German state Rhineland-Palatinate):

/usr/bin/ogr2ogr --config PG_USE_COPY YES -f PostgreSQL PG:" dbname=geonode_data host=172.18.0.1 port=5432 user=geonode_data password=geonode_data " Weinlagen.shp -nln weinlagen "weinlagen" -lco precision=no -lco GEOMETRY_NAME=geometry -nlt PROMOTE_TO_MULTI -lco SHAPE_ENCODING=ISO-8859-1
Warning 6: dataset PG: dbname=geonode_data host=172.18.0.1 port=5432 user=geonode_data password=XXXXXXXXXXXX  does not support layer creation option SHAPE_ENCODING
ERROR 1: Non UTF-8 content found when writing feature -1 of layer weinlagen: 0106000020E8640000010000000103000000010000001F000000DBF97E6A93D61A41295C8F9296DC5441FED478E995D61A41448B6C8796DC54419EEFA746CAD61A411D5A645B95DC54412FDD2486FED61A4123DBF92E94DC5441666666E625D71A41C74B374193DC5441C3F528DCB4D71A4185EB511890DC5441FA7E6A3CBFD71A41C1CAA1DD8FDC5441E5D0225BF4D71A412B8716B18EDC5441A8C64BB7F0D71A41CBA145D68DDC5441713D0A57F0D71A4117D9CEBF8DDC5441F4FDD478EFD71A41C3F5288C8DDC5441AAF1D24DE4D71A416ABC74F38ADC5441A245B673CBD71A415839B42885DC54418716D9CEA5D71A41AE47E1627CDC5441D34D62901ED61A41D122DB8182DC54416DE7FB290CD51A4104560E2D87DC544152B81E0502D51A41D578E95E87DC544148E17A14EFD41A41D9CEF7BB87DC54412B871659D4D41A41FED4787988DC54416891ED7CC1D41A41EC51B8EE88DC544123DBF9FEB4D41A4148E17A3C89DC544191ED7C3FB3D41A41355EBA7189DC54415A643BDFB2D41A41A4703DB289DC54411D5A64BBC1D41A41105839548BDC5441E5D022DBC9D41A410AD7A3388CDC544123DBF97EE5D41A41BA490C428FDC5441D122DB791DD51A4183C0CA9998DC5441986E12035CD51A41B81E852B97DC5441B6F3FDD4F8D51A41A01A2F9593DC544121B072E81AD61A41C1CAA12D99DC5441DBF97E6A93D61A41295C8F9296DC5441   820917  2022/07/04  Johannitergarten/Mu�bach    Johannitergarten(Mu�bach)   Pfalz   Ber. Mittelhaardt/Dt. Weinstra�eMeerspinne  Johannitergarten    Neustadt an der Weinstra�e  Mu�bach k. A.   -   1375

ERROR 1: Unable to write feature 3 from layer Weinlagen.
ERROR 1: Terminating translation prematurely after failed
translation of layer Weinlagen (use -skipfailures to skip errors)
ERROR 1: ERROR:  permission denied to create event trigger "ogr_system_tables_event_trigger_for_metadata"
HINT:  Must be superuser to create an event trigger.

ERROR 1: ERROR:  current transaction is aborted, commands ignored until end of transaction block

ERROR 1: ERROR:  current transaction is aborted, commands ignored until end of transaction block

When renaming Weinlagen.cst to Weinlagen.cpg everything works as expected.

@mattiagiupponi I tend to change the current approach "read and set the encoding" to change the .cst extension (if it exists) to .cpg and let ogr2ogr do the rest. Any objections/thourghts on this?

mattiagiupponi commented 2 months ago

I dont like much the idea of changing a file format on the fly, this may lead to other issues (manly related to the OS)

What is intresting here is the error that raise:

does not support layer creation option SHAPE_ENCODING

Looking at this topic, they suggest to use the option ENCODING https://trac.osgeo.org/gdal/ticket/4359#comment:1 Is it possible for you to make a test with the ENCODING instead of SHAPE_ENCODING?