在lat / long点表中绘制python中热图的地图上的自定义多边形?

问题描述 投票:0回答:1

我有一个panda列有zip_code,sub_region,index,lat,long,center_lat,center_long。在子区域是邮政编码的连续子区域的情况下,索引是创建多边形的纬度/长点的顺序,纬度和长列用于每个点,中心纬度和中心长度是每个子的中心区域。我正在尝试为每个次区域制作热图。我一直在挖掘情节,地图和地图,但到目前为止还没有能够做到这一点。有没有人对如何做到这一点有任何想法或想法?

python plotly geopandas cartopy
1个回答
0
投票
geometry = [Point(xy) for xy in zip(zip_shape.latitude, zip_shape.longitude)]
df1 = zip_shape.drop(['latitude', 'longitude'], axis=1)
gdf1 = GeoDataFrame(df1, geometry=geometry).sort_values(['zip_code','subregion','indx'])

gdf1['geometry']=gdf1['geometry'].apply(lambda x: x.coords[0])
df2 = gdf1.groupby(['zip_code','subregion'])['geometry'].apply(lambda x: Polygon(x.tolist())).reset_index()

gdf2 = gpd.GeoDataFrame(df2, geometry = 'geometry')
gdf.to_file('Geo1.shp', driver='ESRI Shapefile')

gdf2.plot()
© www.soinside.com 2019 - 2024. All rights reserved.