-
Notifications
You must be signed in to change notification settings - Fork 391
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
readshapefile fails on certain filenames #151
Comments
Hmm: I look at the code and do not understand how it worked for you .... What Thanks 2014-04-28 18:10 GMT-04:00 Andy Aschwanden notifications@github.com:
Sasha |
Sorry, I was not clear enough, the above code was a snippet from my scripts. I don't specify the the .shp extension, so the above should read: This works: m.readshapefile('foo, 'my_shape') while this fails: m.readshapefile('bar_0.1', 'my_shape') Andy |
I think you are not passing the extension to readshapefile, it is just a If this is so then the culprit is this line: https://github.com/matplotlib/basemap/blob/master/lib/mpl_toolkits/basemap/shapefile.py#L249 It is not to hard to fix, so If you want the glory, go ahead) If Jeff won't Cheers 2014-04-28 18:31 GMT-04:00 Oleksandr Huziy guziy.sasha@gmail.com:
Sasha |
I would do smth like this: if os.path.isfile(shapefile): self.shapeName = shapeName Cheers 2014-04-28 18:44 GMT-04:00 Oleksandr Huziy guziy.sasha@gmail.com:
Sasha |
Correct, I realized that basemap does not accept the extension, so my script removes it first, before passing the name to m.readshapfile. The script looks something like this
I'm not an expert python programmer, so this is sort of a hack as it can fail when the filename contains the pattern .shp besides the extension. |
@guziy 👍 Yes that should work. I can go ahead and make the code change, if that's ok. |
This issue can be closed here, if the issue is still there, then it should be reported to the pyshp project (I am guessing here: https://github.com/GeospatialPython/pyshp). |
Hi,
(Tested with basemap 1.0.6)
This works:
m.readshapefile('foo.shp', 'my_shape')
while this fails:
m.readshapefile('bar_0.1.shp', 'my_shape')
Note that foo.shp and bar_0.1.shp are exactly the same file except for the filename. So it seems that the additional
.
causes the problem. Minimal example to reproduce behavior:Rename
huralll020.{shp,dfb,shx}
tohuralll020_0.1.{shp,dbf,shx}
and change filename inexamples/hurrtracks.py
accordingly. Run hurrtracks.py.Of course the obvious workaround is not to use
.
in filenames. But this is somewhat impracticable as I have a large number or files and would like keeping the filenames consistent accross filetypes (netCDF, shapfiles, pngs, etc).Is there an easy fix?
Thanks very much,
Andy
The text was updated successfully, but these errors were encountered: