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.

readshapefile() raises incorrect error msg regarding shpproj and shapelib

See original GitHub issue

When plotting a shapefile using readshapefile()

m.readshapefile(shapefile_path, 'roads')

I received this error message:

ValueError: shapefile must have lat/lon vertices - it looks like this one has vertices in map projection coordinates. You can convert the shapefile to geographic coordinates using the shpproj utility from the shapelib tools (http://shapelib.maptools.org/shapelib-tools.html)

However, it appears that the specified module “shapelib” is no longer maintained or available. To add to the confusion, there is a completely different module that also goes by the name “shapelib” available on pypi and github, but that does not contain the functionality suggested above.

In regard to a suggested solution. I found the fix on this site to be useful for converting the shapefile and getting past this readshapefile() error. http://fascicul.us/convert-display-shapefile-matplotlib.html

However, this conversion sometimes leads to a new error:

ValueError: readshapefile can only handle 2D shape types

Which I have yet to find a way to resolve

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nishadhkacommented, Jun 3, 2017

Hi, This error was getting resolved by using geopandas and setting the shape file crs to null as follows

import geopandas as gpd
stateshp = gpd.read_file('shapefile.shp')
#print stateshp1.crs
stateshp1.crs={}
stateshp1.to_file('shapefile1.shp', driver='ESRI Shapefile')

Using the resultant shape file resolves the error.

0reactions
shalevalecommented, Apr 21, 2020

I just want to add (for anyone who can help in the future) that I resolve this problem converting my shapefile through this web: https://mygeodata.cloud/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to load a shapefile with Basemap - GIS Stack Exchange
I am on Ubuntu and the code I'm using is pretty simple I guess: ... as plt map = Basemap() map.drawmapboundary(fill_color='aqua') ...
Read more >
mpl_toolkits.basemap — issm 4.12 documentation
locals() # unsupported projection error message. ... is None or lon_0 is None: raise ValueError('must specify lat_1 or lat_0 and lon_0 for %s...
Read more >
removing null values from dbf file for error in Matplotlib ...
I can't seem to send shapefiles to matplotlib or mpl_toolkits without using Basemap, but basemap keeps giving me these errors. Here is some...
Read more >
https://svn.ssec.wisc.edu/repos/davidh/patch/matpl...
locals() # unsupported projection error message. ... msg='must specify lon_0 and lat_0 for near-sided perspective Basemap' raise ValueError(msg) if width is ...
Read more >
File: __init__.py - Debian Sources
locals() # unsupported projection error message. ... is None or lon_0 is None: raise ValueError('must specify lat_1 or lat_0 and lon_0 for %s...
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