matplotlib / basemap

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

readshapefile fails on std99d00 #390

Closed nzqo closed 2 years ago

nzqo commented 6 years ago

I just installed basemap via conda and wanted to run your examples/fillstates.py to plot a map of the US. However, on the following line:

shp_info = m.readshapefile('st99_d00','states',drawbounds=True,
                           linewidth=0.45,color='gray')

I receive the error:

Traceback (most recent call last): File "", line 162, in File "/Users/user/anaconda/lib/python3.5/site-packages/mpl_toolkits/basemap/init.py", line 2124, in readshapefile raise IOError('cannot locate %s.shp'%shapefile) OSError: cannot locate st99_d00.shp

Couldn't find any fix or open issue for this, so sorry if I just didn't see it. Any idea what's going on?

WeatherGod commented 6 years ago

It is a shapefile from the census bureau. Unfortunately, the web address in the comments is outdated. If you can find it, let me know and I can update the documentation.

On Mon, Feb 5, 2018 at 2:14 AM, LiftingBanana notifications@github.com wrote:

I just installed basemap via conda and wanted to run your examples/fillstates.py https://github.com/matplotlib/basemap/blob/master/examples/fillstates.py to plot a map of the US. However, on the following line:

shp_info = m.readshapefile('st99_d00','states',drawbounds=True, linewidth=0.45,color='gray')

I receive the error:

Traceback (most recent call last): File "", line 162, in File "/Users/user/anaconda/lib/python3.5/site-packages/mpl_ toolkits/basemap/init.py", line 2124, in readshapefile raise IOError('cannot locate %s.shp'%shapefile) OSError: cannot locate st99_d00.shp

Couldn't find any fix or open issue for this, so sorry if I just didn't see it. Any idea what's going on?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/matplotlib/basemap/issues/390, or mute the thread https://github.com/notifications/unsubscribe-auth/AARy-KCeoeQCfHxjQ6w_Su1a3EL1VgJuks5tRqpZgaJpZM4R5AcQ .

QuLogic commented 6 years ago

It's in the example directory (+ the other files with the same prefix).

GavinMoreYoung commented 5 years ago

i am also see the same issue

molinav commented 2 years ago

@GavinMoreYoung As mentioned by @QuLogic, the 'st99_d00' files are part of the basemap examples, and they are located in the examples folder within this repository. They do not come with a standard installation of basemap, so you will need to download them from the repository if you want to use them (and write the appropriate path to them in your script).

GavinMoreYoung commented 2 years ago

收到,会尽快给您回复。

molinav commented 2 years ago

@nzqo The most likely reason for your error is if you have run the example from outside the examples folder. Note that the 'st99_d00' files can be found inside the examples folder, and your snippet is using relative paths (i.e. assuming that you are running this code inside the examples folder).