matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
772 stars 390 forks source link

readshapefile: add an argument to override unicode decoding error handling #552

Closed guziy closed 1 year ago

guziy commented 1 year ago

Usually, we want to plot the shapes and not care too much about the correctness of decoded .dbf file. But the current behavior: plotting fails if the default encoding does not match the one used for saving .dbf file.

I propose to add an argument to the readshapefile:

mp.readshapefile(..., encoding_errors="strict") # I guess the possible values are  'ignore', 'replace' and 'backslashreplace'

Currently, this is hardcoded to 'strict' inside the readshapefile method (i.e. default in the Reader constructor).

I could try to submit a PR at some point.