We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reproject_vector
I have an example shapefile that raises this exception:
Traceback (most recent call last): File "C:\Users\dmf\projects\pygeoprocessing\scratch\reproject_vector.py", line 8, in <module> pygeoprocessing.reproject_vector( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ base_vector_path, base_wkt, ^^^^^^^^^^^^^^^^^^^^^^^^^^^ '../forum/ndr_setfield/copy.shp', ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ driver_name='ESRI Shapefile') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "src\\pygeoprocessing\\geoprocessing_core.pyx", line 77, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper with GDALUseExceptions(): File "src\\pygeoprocessing\\geoprocessing_core.pyx", line 78, in pygeoprocessing.geoprocessing_core.gdal_use_exceptions.wrapper return func(*args, **kwargs) File "C:\Users\dmf\projects\pygeoprocessing\src\pygeoprocessing\geoprocessing.py", line 2282, in reproject_vector target_feature.SetField(target_index, value) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dmf\projects\pygeoprocessing\env\Lib\site-packages\osgeo\ogr.py", line 3877, in SetField return _ogr.Feature_SetFieldString(self, fld_index, args[1]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: not a string or os.PathLike
I think GDAL tried to read a string assuming a UTF8 encoding during a GetField call, and then the result is not usable in SetField.
GetField
SetField
layer.TestCapability(ogr.OLCStringsAsUTF8)) returns False for this layer.
layer.TestCapability(ogr.OLCStringsAsUTF8))
False
We could simply wrap the SetField call in reproject_vector in a try/except. And then maybe replace offending characters with something else.
try/except
The text was updated successfully, but these errors were encountered:
to clarify, the string in question is a field name?
Sorry, something went wrong.
It's actually the field value.
No branches or pull requests
I have an example shapefile that raises this exception:
I think GDAL tried to read a string assuming a UTF8 encoding during a
GetField
call, and then the result is not usable inSetField
.layer.TestCapability(ogr.OLCStringsAsUTF8))
returnsFalse
for this layer.We could simply wrap the
SetField
call inreproject_vector
in atry/except
. And then maybe replace offending characters with something else.The text was updated successfully, but these errors were encountered: