我需要在地图上画一个散点图。我有图形文件来绘制地图,但我需要将图形文件(多边形)的信息转换为lon和lat坐标。这是我的密码:
borough = gpd.read_file('London_Borough_Excluding_MHW.shp')
borough.crs #{'init': 'epsg:27700'}
crs = {'init': 'epsg:27700'}
gdf = gpd.GeoDataFrame(
df2, crs=crs, geometry=gpd.points_from_xy(df2.lat, df2.lon))
ax = gdf.plot(marker='*', markersize=0.2)
borough.plot(ax=ax)
plt.show
我的df2看起来像这样: $type additionalProperties子级childrenurl commonName id lat lon placeType url
0 Tfl.Api.Presentation.Entities.Place, Tfl.Api.P... [{'$type': 'Tfl.Api.Presentation.Entities.Addi... [] [] River Street , Clerkenwell BikePoints_1 51.529163 -0.109970 BikePoint /Place/BikePoints_1
1 Tfl.Api.Presentation.Entities.Place, Tfl.Api.P... [{'$type': 'Tfl.Api.Presentation.Entities.Addi... [] [] Phillimore Gardens, Kensington BikePoints_2 51.499606 -0.197574 BikePoint /Place/BikePoints_2
我的形状文件如下所示:
NAME GSS_CODE HECTARES NONLD_AREA ONS_INNER SUB_2009 SUB_2006 geometry
0 Kingston upon Thames E09000021 3726.117 0.000 F None None POLYGON ((516401.6 160201.8, 516407.3 160210.5...
1 Croydon E09000008 8649.441 0.000 F None None POLYGON ((535009.2 159504.7, 535005.5 159502, ...
2 Bromley E09000006 15013.487 0.000 F None None POLYGON ((540373.6 157530.4, 540361.2 157551.9...
我刚下载了shp文件和散乱数据。你只需要正确地转换CRS
仅供参考数据源说明分散数据在WGS1984中(EPSG 4326)
结果(我没有绘制所有点,需要一个API键,所以我只是复制了您的数据片段)
编辑标签行政区(你必须格式化使其更漂亮)
相关问题 更多 >
编程相关推荐