Python Altair和GeoJSON文件
我将此网站用作指南: 但是,使用伦敦各区略有不同的数据: 特别是此形状文件:/ESRI/London_Borough_,不包括_MHW.shp 然而,当我试图获得基本层时,我得到了一个非常奇怪的输出: 当我使用教程中使用的数据时,我得到的数据与教程完全相同。那么,这是伦敦各区的档案中的东西吗 到目前为止,我的代码是:Python Altair和GeoJSON文件,python,geojson,altair,Python,Geojson,Altair,我将此网站用作指南: 但是,使用伦敦各区略有不同的数据: 特别是此形状文件:/ESRI/London_Borough_,不包括_MHW.shp 然而,当我试图获得基本层时,我得到了一个非常奇怪的输出: 当我使用教程中使用的数据时,我得到的数据与教程完全相同。那么,这是伦敦各区的档案中的东西吗 到目前为止,我的代码是: map_df = gpd.read_file("/statistical-gis-boundaries-london/ESRI/London_Borough_Excludin
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
我犯了明显的错误。我需要更改坐标参考系:
test_map = map_df.to_crs(epsg=4326)