1

I am trying to plot district boundaries on a map of Nepal. For that I downloaded a shapefile of districts in Nepal from this site:

http://www.arcgis.com/home/item.html?id=d4ad6faa446b42bd9f1d42407db7b5ba

The folder name was NP_75DWGS84 and all the files within the folder had the files containing the same name. Then I used the following code:

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt


map = Basemap()    
map.drawmapboundary()
map.drawcoastlines()
map.readshapefile('/home/mala/NP_75DWGS84/NP_75DWGS84','NP_75DWGS84',linewidth=1.0,drawbounds = False)
plt.show()

It gives me total plot of world, but, it is not plotting shapefiles in the graph. There is also no error. What is wrong here?

13
  • Do you have a directory named "NP_75DWGS84" and a shapefile named "NP_75DWGS84" in that directory?
    – Aaron
    Commented Aug 15, 2017 at 3:42
  • @Aaron yes, I have the directory and the shape file Commented Aug 15, 2017 at 4:36
  • Please be more specifiy. Your title is about not being able to "import" a Shapefile but reading the rest suggests you are getting no errors but just an empty plot? Is that correct? Do your basemap extents and the data coincide? Commented Aug 15, 2017 at 8:08
  • @bugmenot123 .I am ploting domain of nepal and the basemap is of that specific domain. The shape file are of the boundary within the country .I think It should coincide but I don't know how to find out weather it coincides or not. Commented Aug 15, 2017 at 12:11
  • 1
    Try "drawbounds = True" or delete this parameter? When drawbounds is false the shapefile is not drawn, returning the geometry instead for you to add to the plot as needed. Commented Aug 16, 2017 at 15:46

1 Answer 1

1

Try specifying the extent of the map when you create the Basemap() object, by setting the lower left and upper right corner coordinates, e.g.:

map = Basemap(llcrnrlon=80.0,llcrnrlat=26.2,urcrnrlon=88.3,urcrnrlat=30.6)
map.drawmapboundary()
map.readshapefile('/home/mala/NP_75DWGS84/NP_75DWGS84','NP_75DWGS84',linewidth=1.0,drawbounds = False)
plt.show()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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