You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given I have a Shapefile that is encoded via ISO-8859-1 and has a .cst file that denotes this (but no .cpg file)
When I upload this Shapefile using Geonode with a PostgreSQL/PostGIS backend set to UTF-8 encoding
Then the Shapefile is successfully converted from ISO-8859-1 to UTF-8 during the upload process and is successfully created as a new layer in Geonode.
Actual Behavior
The ogr2ogr command throws the following warning and error:
Warning 6: dataset XXX does not support layer creation option ENCODING
ERROR 1: Non UTF-8 content found when writing feature -1 of layer XXX
I can see that there is function which attempts to get the encoding from the .cst if there isn't a .cpg provided:
This doesn't work because the target in this instance is the PostgreSQL database where the encoding is not managed at the layer (table) level, but rather at the database level. I think instead it should be setting a --config option, and as this is the handler for Shapefiles, it probably makes sense to use the SHAPE_ENCODING parameter, so something like:
Alternatively, the _get_encoding function could be updated so if there isn't a .cpg file then it creates one from the contents of the .cst file (as providing a .cpg file with the ISO-8859-1 encoding is handled correctly by ogr2ogr). This is probably more work though.
The following ZIP file can be used to replicate this issue. I've done some testing using the --config SHAPE_ENCODING method mentioned above and it resolves the issue in this instance. hospitals_8859.zip
Specifications
GeoNode version: 4.3.1
Installation type (vanilla, geonode-project):
Installation method (manual, docker):
Platform:
Additional details:
The text was updated successfully, but these errors were encountered:
Expected Behavior
Given I have a Shapefile that is encoded via
ISO-8859-1
and has a.cst
file that denotes this (but no.cpg
file)When I upload this Shapefile using Geonode with a PostgreSQL/PostGIS backend set to
UTF-8
encodingThen the Shapefile is successfully converted from
ISO-8859-1
toUTF-8
during the upload process and is successfully created as a new layer in Geonode.Actual Behavior
The
ogr2ogr
command throws the following warning and error:I can see that there is function which attempts to get the encoding from the
.cst
if there isn't a.cpg
provided:geonode/geonode/upload/handlers/shapefile/handler.py
Lines 176 to 192 in c1b0fbb
The problem appears to be that when it gets the encoding from the
.cst
file it is adding it to the ogr2ogr command via theENCODING
parameter:geonode/geonode/upload/handlers/shapefile/handler.py
Lines 167 to 168 in c1b0fbb
This doesn't work because the target in this instance is the PostgreSQL database where the encoding is not managed at the layer (table) level, but rather at the database level. I think instead it should be setting a
--config
option, and as this is the handler for Shapefiles, it probably makes sense to use theSHAPE_ENCODING
parameter, so something like:Alternatively, the
_get_encoding
function could be updated so if there isn't a.cpg
file then it creates one from the contents of the.cst
file (as providing a.cpg
file with theISO-8859-1
encoding is handled correctly by ogr2ogr). This is probably more work though.The following ZIP file can be used to replicate this issue. I've done some testing using the
--config SHAPE_ENCODING
method mentioned above and it resolves the issue in this instance.hospitals_8859.zip
Specifications
The text was updated successfully, but these errors were encountered: