Comments (7)
Hmm:
I look at the code and do not understand how it worked for you .... What
happens if you don't specify the .shp extension?
Thanks
2014-04-28 18:10 GMT-04:00 Andy Aschwanden [email protected]:
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')
raise IOError('error reading shapefile %s.shp' % shapefile)
fields = shf.fields
coords = []; attributes = []IOError: error reading shapefile bar_0.1.shp
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} to huralll020_0.1.{shp,dbf,shx} and
change filename in examples/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
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/151
.
Sasha
from basemap.
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
from basemap.
I think you are not passing the extension to readshapefile, it is just a
typo in your example, right?
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
mind.
Cheers
2014-04-28 18:31 GMT-04:00 Oleksandr Huziy [email protected]:
Hmm:
I look at the code and do not understand how it worked for you .... What
happens if you don't specify the .shp extension?Thanks
2014-04-28 18:10 GMT-04:00 Andy Aschwanden [email protected]:
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')
raise IOError('error reading shapefile %s.shp' % shapefile)
fields = shf.fields
coords = []; attributes = []IOError: error reading shapefile bar_0.1.shp
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} to huralll020_0.1.{shp,dbf,shx} and
change filename in examples/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
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/151
.Sasha
Sasha
from basemap.
I would do smth like this:
if os.path.isfile(shapefile):
(shapeName, ext) = os.path.splitext(shapefile)
else:
shapeName = shapefile
self.shapeName = shapeName
Cheers
2014-04-28 18:44 GMT-04:00 Oleksandr Huziy [email protected]:
I think you are not passing the extension to readshapefile, it is just a
typo in your example, right?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 mind.Cheers
2014-04-28 18:31 GMT-04:00 Oleksandr Huziy [email protected]:
Hmm:
I look at the code and do not understand how it worked for you .... What
happens if you don't specify the .shp extension?Thanks
2014-04-28 18:10 GMT-04:00 Andy Aschwanden [email protected]:
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')
raise IOError('error reading shapefile %s.shp' % shapefile)
fields = shf.fields
coords = []; attributes = []IOError: error reading shapefile bar_0.1.shp
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} to huralll020_0.1.{shp,dbf,shx} and
change filename in examples/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
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/151
.Sasha
Sasha
Sasha
from basemap.
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
shape_filename = ['foo.shp', 'bar_0.1.shp']
for index, shpfile in enumerate(shape_filename):
# remove .shp extension
shpfile = shpfile.split('.shp')[0]
m.readshapefile(shpfile,
'my_shapefile', linewidth=.75)
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.
from basemap.
@guziy 👍 Yes that should work. I can go ahead and make the code change, if that's ok.
from basemap.
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).
from basemap.
Related Issues (20)
- install basemap HOT 2
- matplotlib < 3.7 requirement? HOT 3
- basemap with mac m2 issues HOT 32
- Function "addcyclic": IndexError HOT 2
- ETOPO failed to show with pseudocyl projection HOT 3
- Issue with basemap installation on cygwin HOT 16
- Problem with installation on linux/arm64 conda environment HOT 10
- Basemap installation failure in MacOS - Jupyter Notebook HOT 5
- Any way to control shapefile alpha? HOT 2
- show a warning when projection is wrongly parameterized
- Geoslib Import HOT 3
- Segmentation Fault due To build conflicts HOT 2
- AttributeError: module 'numpy' has no attribute 'float'. HOT 7
- Basemap install fails after python upgrade HOT 4
- arcgisimage doesn't work HOT 4
- FAQ refers to file that was replaced HOT 2
- AttributeError: can't set attribute HOT 5
- Basemap fails to install using pip on macOS (M1) HOT 3
- Basemap: solving environment failed HOT 4
- shiftdata docs reverse return values HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from basemap.