0

I have a geopandas dataframe where each record is a point. I am making an application using Flask and Python and would like to display an interactive map in HTML where the points would be transformed into a raster or into polygons from centroids. Each pixel would have an onclick event. I used geopandas simplify and dissolve and buffer (separately) to create polygons from the points with ok-looking results but then I can only display the map as a static image in HTML. I tried Bokeh but the best I can get is square points on a map which do not look good because I want them to be touching as a continuous structure but do not know the scale in advance so cannot set the right size of the point.
Ultimately, I would like it to be like a grid in this tutorial (but they use polygons): https://automating-gis-processes.github.io/2016/Lesson5-interactive-map-bokeh.html
enter image description here Would anyone have an idea how to go about this?

1

I have finally found a satisfactory solution to this. I check the distance between any two random points in the geopandas dataframe. They are all spaced evenly. Then I apply a buffer on all points using using half of the distance calculated in the previous step. Then, I apply the envelope() method on each point which results in a geodataframe of even polygons touching on the edges so it looks like a raster. I could not create a map from geopandas dataframe directly in Bokeh so I used Pandas-Bokeh library and it gave good results, including a hover method for each 'pixel'/ polygon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.