Saturday, 30 October 2021

How to display a heatmap on a specific parameter with geopandas?

In my very simple case I would like to display the heatmap of the points in the points GeoJSON file but not on the geographic density (lat, long). In the points file each point has a confidence property (a value from 0 to 1), how to display the heatmap on this parameter? weight=points.confidence don't seem to work.

for exemple:

#points.geojson

{ "type": "Feature", "properties": { "label": "triangle", "confidence": 0.67000001668930054, "longitude": 38.703471404215918, "latitude": 25.541625492300206, "area": 345.31, "id": 0, "icon": "play" }, "geometry": { "type": "Point", "coordinates": [ 38.703471404215918, 25.541625492300192 ] } },
...

The image below shows my result but it is on the geographic density not confidence score density.

import geoplot as gplt
import geopandas as gpd
import geoplot.crs as gcrs
import matplotlib.pyplot as plt

points = gpd.read_file('points.geojson')
polygons = gpd.read_file('polygons.geojson')

ax = gplt.polyplot(polygons, projection=gcrs.AlbersEqualArea(), zorder=1)
gplt.kdeplot(points, cmap='Reds', shade=True, clip=polygons, ax=ax) 
#weight=points.confidence don’t work inside kdeplot()

plt.show()

enter image description here



from How to display a heatmap on a specific parameter with geopandas?

No comments:

Post a Comment