-2

我使用这个网站作为指南:

https://www.districtdatalabs.com/altair-choropleth-viz/

然而,伦敦自治市使用略有不同的数据:

https://data.london.gov.uk/dataset/statistical-gis-boundary-files-london

特别是这个形状文件:/ESRI/London_Borough_Excluding_MHW.shp

但是,当我尝试获取基础层时,我得到了一个非常奇怪的输出:

奇怪的基础层

当我使用教程中使用的数据时,我得到的数据与教程完全相同。那么它是伦敦自治市镇形状文件中的东西吗?

到目前为止我的代码:

map_df = gpd.read_file("/statistical-gis-boundaries-london/ESRI/London_Borough_Excluding_MHW.shp")
#Change to match Borough names in previous DFs
Bnames = {"Kingston upon Thames" : "KingstonUponThames",
      "Richmond upon Thames" : "RichmondUponThames",
      "Hammersmith and Fulham" : "HammersmithFulham",
      "Kensington and Chelsea" : "KensingtonChelsea",
      "Tower Hamlets" : "TowerHamlets",
      "Barking and Dagenham" : "BarkingDagenham",
      "City of London" : "CityOfLondon"
     }
map_df['Borough'] = map_df['NAME'].map(Bnames)
map_df['Borough'] = map_df['Borough'].fillna(map_df['NAME'])


merged = map_df.merge(FreqMalCall[['Borough','MalCall']], how='left', on='Borough')

map_df['centroid_lon'] = map_df['geometry'].centroid.x
map_df['centroid_lat'] = map_df['geometry'].centroid.y


 choro_json = json.loads(map_df.to_json())
 choro_data = alt.Data(values=choro_json['features'])

def gen_base(geojson):
'''Generates baselayer of DC ANC map'''
base = alt.Chart(alt.Data(values=geojson)).mark_geoshape(
    stroke='black',
    strokeWidth=1
).encode(
).properties(
    width=400,
    height=400
)
return base


base_layer = gen_base(geojson=choro_json)
base_layer
4

1 回答 1

1

我的明显错误。我需要更改坐标参考系:

 test_map = map_df.to_crs(epsg=4326)
于 2018-12-17T23:54:33.217 回答