Skip to content

Add an option encoding_errors to readshapefile #554

New issue

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

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/basemap/src/mpl_toolkits/basemap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,7 @@ def is_land(self,xpt,ypt):

def readshapefile(self,shapefile,name,drawbounds=True,zorder=None,
linewidth=0.5,color='k',antialiased=1,ax=None,
default_encoding='utf-8'):
default_encoding='utf-8',encoding_errors='strict'):
"""
Read in shape file, optionally draw boundaries on map.

Expand Down Expand Up @@ -2117,6 +2117,10 @@ def readshapefile(self,shapefile,name,drawbounds=True,zorder=None,
antialiased antialiasing switch for shape boundaries
(default True).
ax axes instance (overrides default axes instance)
default_encoding encoding used to parse properties from .dbf files
(default utf-8)
encoding_errors encoding error handling (default strict), other
possible values: ignore, replace and backslashreplace
============== ====================================================

A tuple (num_shapes, type, min, max) containing shape file info
Expand All @@ -2140,7 +2144,8 @@ def readshapefile(self,shapefile,name,drawbounds=True,zorder=None,
# open shapefile, read vertices for each object, convert
# to map projection coordinates (only works for 2D shape types).
try:
shf = Reader(shapefile, encoding=default_encoding)
shf = Reader(shapefile, encoding=default_encoding,
encodingErrors=encoding_errors)
except:
raise IOError('error reading shapefile %s.shp' % shapefile)
fields = shf.fields
Expand Down