basemap: Fail on basemap.drawcounties() Python 3.5.2

Platform:

Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux

Throws error on basemap.drawcounties() (over Illinois)

 Traceback (most recent call last):
  File "animate_aws.py", line 171, in <module>
    writer='imagemagick', fps=5)
  File "/home/scollis/anaconda/envs/pyart35/lib/python3.5/site-packages/matplotlib/animation.py", line 832, in save
    anim._init_draw()
  File "/home/scollis/anaconda/envs/pyart35/lib/python3.5/site-packages/matplotlib/animation.py", line 1221, in _init_draw
    self._draw_frame(next(self.new_frame_seq()))
  File "/home/scollis/anaconda/envs/pyart35/lib/python3.5/site-packages/matplotlib/animation.py", line 1243, in _draw_frame
    self._drawn_artists = self._func(framedata, *self._args)
  File "animate_aws.py", line 166, in animate
    display.basemap.drawcounties()
  File "/home/scollis/anaconda/envs/pyart35/lib/python3.5/site-packages/mpl_toolkits/basemap/__init__.py", line 1980, in drawcounties
    default_encoding='latin-1',drawbounds=drawbounds)
  File "/home/scollis/anaconda/envs/pyart35/lib/python3.5/site-packages/mpl_toolkits/basemap/__init__.py", line 2146, in readshapefile
    for shprec in shf.shapeRecords():
  File "/home/scollis/anaconda/envs/pyart35/lib/python3.5/site-packages/mpl_toolkits/basemap/shapefile.py", line 543, in shapeRecords
    for rec in zip(self.shapes(), self.records())]
  File "/home/scollis/anaconda/envs/pyart35/lib/python3.5/site-packages/mpl_toolkits/basemap/shapefile.py", line 515, in records
    r = self.__record()
  File "/home/scollis/anaconda/envs/pyart35/lib/python3.5/site-packages/mpl_toolkits/basemap/shapefile.py", line 491, in __record
    value = u(value)
  File "/home/scollis/anaconda/envs/pyart35/lib/python3.5/site-packages/mpl_toolkits/basemap/shapefile.py", line 58, in u
    return v.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf1 in position 2: invalid continuation byte

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 3
  • Comments: 23 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I have the same problem. I’ve solved it. I replace all “utf-8” with “latin-1” in shapefile.py, which located in ~/Library/Python/3.7/lib/python/site-packages/shapefile.py

Created #340 that should help fix this

On Thu, Feb 2, 2017 at 2:16 PM, Benjamin Root ben.v.root@gmail.com wrote:

Oooh, it is a bit more trickier than that. drawstates() and drawcountries() is implemented using LineCollection objects, but drawcounties() is implemented using a PolyCollection, which has a lower default zorder. This wouldn’t be too much of an issue, but because the coastline drawing is done as PolyCollection, and came after the county drawing, the coastline stuff clobbers the county polygons. Perhaps I can “fix” it by keeping the counties as PolyCollection for backwards compat, but initializing it with the default zorder of a LineCollection (which is what the documentation says it should do, anyway).

On Thu, Feb 2, 2017 at 2:00 PM, Benjamin Root ben.v.root@gmail.com wrote:

oooh, good catch! Perhaps I should update the default zorder of the county stuff so that it goes above other stuff?

On Thu, Feb 2, 2017 at 1:53 PM, Huziy Oleksandr (Sasha) < notifications@github.com> wrote:

@datacathy https://github.com/datacathy

It fills continents over your county boundaries (which is a bit weird)… A workaround is to use mm.drawcounties(zorder=20)

Cheers

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/matplotlib/basemap/issues/324#issuecomment-277047335, or mute the thread https://github.com/notifications/unsubscribe-auth/AARy-LwitRatOYuc_zzXTN5aFVK1crWEks5rYiYWgaJpZM4KVEE9 .