使用底图和matplotlib对一个国家的某些城市进行彩色绘图

时间:2019-02-25 05:14:49

标签: python matplotlib matplotlib-basemap

我想显示一个具有特定值的每个城市/地区的地图作为颜色变量。 我有一个城市列表及其相应的值;

cities = [["Auckland City",5],
          ["Opotiki District",10],
          ["Kaikoura District",15],
          ["Christchurch City",25]]

我希望从取自一个形状文件的多边形中填充城市的颜色; https://koordinates.com/layer/1247-nz-territorial-authorities-2006-census/

但是我似乎无法找出一种方法来完成,或者找到类似的案例/示例。 我只成功绘制了一张以NZ为边界的地图;

map = Basemap(llcrnrlon = 166, llcrnrlat = -47.4,
              urcrnrlon = 178.6, urcrnrlat = -34,
              resolution  = 'i', projection = 'lcc'
              ,lat_1=-37.5,lat_2=-44.5,lon_0=173, lat_0=-41)

# load the shapefile, use the name 'states'
map.readshapefile('nz-territorial-authorities-2006-censusWGS84', name='states', drawbounds=True)

P.S。我还用它来转换我下载的shapefile,从将地图投影坐标转换​​为地理坐标;

import geopandas as gpd

tmp = gpd.GeoDataFrame.from_file('nz-territorial-authorities-2006-census.shp')

tmpWGS84 = tmp.to_crs({'proj':'longlat', 'ellps':'WGS84', 'datum':'WGS84'})

tmpWGS84.to_file('nz-territorial-authorities-2006-censusWGS84.shp')

0 个答案:

没有答案