build_map.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:crime_prediction 作者: livenb 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号