Can Basemap draw a detailed coastline at the city level?
I'm trying to draw a detailed coastline of the NYC area using Basemap in Python. Using the full resolution dataset, Manhattan looks like rectangle, and the Hudson doesn't show up at all about midtown.
Here's the code I'm using. Any suggestions?
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
m = Basemap(projection='merc',llcrnrlat=40.55,urcrnrlat=40.82,\
llcrnrlon=-74.1, urcrnrlon=-73.82, lat_ts=40.5,resolution='f')
m.drawcoastlines()
m.drawrivers()
m.fillcontinents(color='coral',lake_color='aqua')
m.drawmapboundary(fill_color='aqua')
plt.show()
EDIT
On further exploration, it looks like my issue is with the rivers, specifically. I can get the detailed boundaries of the oceanic coastline, but there is still no Hudson river and no Harlem river. Current code:
m = Basemap(projection='merc',llcrnrlat=40.55,urcrnrlat=40.82,\
llcrnrlon=-74.1, urcrnrlon=-73.82, lat_ts=40.5,resolution='f')
m.drawmapboundary(fill_color='#85A6D9')
m.drawcoastlines(color='#6D5F47', linewidth=.4)
m.drawrivers(color='#6D5F47', 开发者_如何学编程linewidth=.4)
m.fillcontinents(color='white',lake_color='#85A6D9')
plt.show()
The data shipped with basemap is quite low resolution (high resolution data takes up quite a lot of space).
You can load shapefiles to display with basemap. I've borrowed code from this tutorial to do that before. The tutorial also links to GADM, where you can download high resolution shapefiles for any country.
You should try to put the area threshold to 0.1, e.g:
m = Basemap(projection='merc',
# ...
area_thresh = 0.1)
精彩评论