6

I'm try to load this shapefile with Basemap in order to plot it in Python:

http://geodata.gov.gr/en/dataset/periphereies-elladas/resource/7c80a2c1-93b7-4814-9fc4-245e775acaa6

But I get the following error:

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

I tried using shpproj or ogr2ogr as another answer in this site suggested, but for the life of me I can not figure out what parameters I should pass to those programs, as I have zero knowledge about GIS in general. So if anyone here could help me with the conversion command that would be great.

I am on Ubuntu and the code I'm using is pretty simple I guess:

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
map = Basemap()

map.drawmapboundary(fill_color='aqua')
map.fillcontinents(color='#ddaa66',lake_color='aqua')
map.drawcoastlines()

map.readshapefile('periphereies/periphereies', 'periphereies')

plt.show()
3
+100

Because a projection file (*.prj) is attached to the shapefile (i.e. "GGRS87 / Greek Grid" aka EPSG:2100, source: EPSG Geodetic Parameter Registry), we can easily transform it to WGS84 (EPSG:4326) using ogr2ogr without declaring the source SRS:

ogr2ogr -t_srs EPSG:4326 periphereies_WGS84.shp periphereies.shp

where periphereies_WGS84.shp is the transformed shapefile.

  • Thanks, this works! The code only works with Python 2 (not 3), but this must be a problem with basemap – mavroprovato Mar 17 '17 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.