Display of geographical data which is not points (markers) - howto?

Hello all

I am working with geographical datasets on my local machine. I think that now I have understood how to work from my local server with anvil uplink to get my resulting (geo) data pointset in an Anvil table and get it displayed with the Anvil web app. For the display, I am using mapbox.

But maybe I make a heatmap or a choropleth on my local machine.
So even if originally the geo dataset is a pointset (markers with coordinates), the end product is not a pointset anymore.

How can my heatmap then be displayed in my mapbox in my Anvil app if it doesn’t go through an Anvil table?

Has anyone tried that?
Or something similar?

Cheers
Anne

Hi there,

In case it helps, I use Folium to create interactive maps (including heat maps and choropleth) that can be saved as an html file. I can then display the html in an iframe within an Anvil app.

App:
https://GVH4AGGPAZNZJKRO.anvil.app/E5GNT5JCGLH237YQYJQ5UGLT

You should see:

Clone (you will need the iframe component as a dependency)

iframe component:

3 Likes

@alcampopiano That’s beautiful!


Getting heatmaps into Anvil

@AnneEst Once you’ve constructed the heatmap locally, what is its format? Is it a Mapbox Layer object?

Sending data over a network usually means converting it into a format that’s serializable. Anvil can pass some of its own objects without any conversion, but at present most third-party objects need to be serialized. Here’s the list of things that can be returned from an anvil.server.callable function. Perhaps MapBox layers have a serialize method? Or perhaps there’s some serializable data that uniquely defines them?

If there’s no way to serialize a MapBox Layer object, I think your best bet is to pass the original geo data into Anvil and construct the Layer in Anvil.