[GIS] Can’t import shapefile in Python

importmatplotlibmatplotlib-basemappythonshapefile

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?

Best Answer

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()