question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fail on basemap.drawcounties() Python 3.5.2

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

7reactions
Ackeraacommented, Apr 3, 2019

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

1reaction
WeatherGodcommented, Feb 2, 2017

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 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

python 3.x - Matplotlib Basemap drawcounties having issues
I have looked in previous issues with other users about the Matplotlib basemap function "draw counties", but it has not resolved my issue....
Read more >
Basemap tutorial Documentation - Read the Docs
Basemap is a great tool for creating maps using python in a simple way. It's a matplotlib extension, so it has got all...
Read more >
matplotlib - Bountysource
I use PyCharm but can't install error basemap. Please check installation. ... Python : 2.7 ... Throws error on basemap.drawcounties() (over Illinois)
Read more >
Basemap Customization with Matplotlib
In this Matplotlib tutorial, we continue with the Basemap geographic plotting ... m.drawcounties(color='darkred') plt.title('Basemap Tutorial') plt.show().
Read more >
basemap - PyPI
python -m pip install basemap. If you need to install from source, please visit the GitHub repository for a step-by-step description.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found