Skip to content

Commit c7e36cc

Browse files
authored
Merge pull request #554 from guziy/add-encoding-error-option
Add an option encoding_errors to readshapefile
2 parents 346a604 + 06fb4d3 commit c7e36cc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/basemap/src/mpl_toolkits/basemap/__init__.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ def is_land(self,xpt,ypt):
20642064

20652065
def readshapefile(self,shapefile,name,drawbounds=True,zorder=None,
20662066
linewidth=0.5,color='k',antialiased=1,ax=None,
2067-
default_encoding='utf-8'):
2067+
default_encoding='utf-8',encoding_errors='strict'):
20682068
"""
20692069
Read in shape file, optionally draw boundaries on map.
20702070
@@ -2117,6 +2117,10 @@ def readshapefile(self,shapefile,name,drawbounds=True,zorder=None,
21172117
antialiased antialiasing switch for shape boundaries
21182118
(default True).
21192119
ax axes instance (overrides default axes instance)
2120+
default_encoding encoding used to parse properties from .dbf files
2121+
(default utf-8)
2122+
encoding_errors encoding error handling (default strict), other
2123+
possible values: ignore, replace and backslashreplace
21202124
============== ====================================================
21212125
21222126
A tuple (num_shapes, type, min, max) containing shape file info
@@ -2140,7 +2144,8 @@ def readshapefile(self,shapefile,name,drawbounds=True,zorder=None,
21402144
# open shapefile, read vertices for each object, convert
21412145
# to map projection coordinates (only works for 2D shape types).
21422146
try:
2143-
shf = Reader(shapefile, encoding=default_encoding)
2147+
shf = Reader(shapefile, encoding=default_encoding,
2148+
encodingErrors=encoding_errors)
21442149
except:
21452150
raise IOError('error reading shapefile %s.shp' % shapefile)
21462151
fields = shf.fields

0 commit comments

Comments
 (0)