def build_map_obj(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=(coords[0] + coords[2])/2,
lat_0=(coords[1] + coords[3])/2,
ellps='helmert',
llcrnrlon=coords[0] - w * 0.01,
llcrnrlat=coords[1] - extra + 0.01 * h,
urcrnrlon=coords[2] + w * 0.01,
urcrnrlat=coords[3] + extra + 0.01 * h,
resolution='i',
suppress_ticks=True
)
m.readshapefile(shapefile,
'SF',
color='black',
zorder=2
)
return m, coords
评论列表
文章目录