def get_basemap(shapefile):
shp = fiona.open(shapefile+'.shp')
bds = shp.bounds
shp.close()
extra = 0.01
ll = (bds[0], bds[1])
ur = (bds[2], bds[3])
coords = list(chain(ll, ur))
w, h = coords[2] - coords[0], coords[3] - coords[1]
m = Basemap(projection='tmerc',
lon_0= -118.2437,
lat_0= 34.0522,
ellps = 'WGS84',
llcrnrlon=coords[0],
# llcrnrlat=coords[1] - extra + 0.01 * h,
llcrnrlat=33.6,
urcrnrlon=coords[2],
urcrnrlat=coords[3],
lat_ts=0,
resolution='i',
suppress_ticks=True)
m.readshapefile(shapefile, 'LA', color='black', zorder=2)
return m, coords
# Convenience functions for working with colour ramps and bars
评论列表
文章目录