TransWikia.com

Folium heatmap not displaying

Geographic Information Systems Asked on June 15, 2021

I have an output file data.json

 [{"5403": 2, "9734": 1, "2565": 5, "5087": 2, "9061": 1, "1761": 4, "4811": 7 "1111": 5, "3891": 3, "1962": 3}]

and a shapefile converted to geojson https://www.dropbox.com/s/uou0jxhpklgt8r6/pc4.json?dl=0

I use this code to generate the map in ipython notebook:

import folium
import numpy as np
from IPython.display import IFrame
from IPython.core.display import HTML

def inline_map(m, width=650, height=500):
    """Takes a folium instance and embed HTML."""
    m._build_map()
    srcdoc = m.HTML.replace('"', '"')
    embed = HTML('<iframe srcdoc="{}" '
                 'style="width: {}px; height: {}px; '
                 'border: none"></iframe>'.format(srcdoc, width, height))
    return embed

    mapa = folium.Map(width=900, height=600, zoom_start=7, location=[52.3, 5], tiles='Mapbox Bright')

mapa.geo_json(geo_path='pc4.json', 
              data_out='data.json', 
              data=pcs, 
              columns=["PC4","Count"], 
              key_on="feature.properties.PC4",
              fill_color='PuRd',
              fill_opacity=1, 
              line_opacity=1,
              legend_name='Demand',
              reset="True")

mapa.create_map('test.html')
IFrame('test.html', width=1000, height=700)

It creates the map fine, just as the output file, but it doesn’t overlay any heatmap. It does show the legend though, but nothing else.

I know this question is similar to Geopandas/folium map not displaying but his solution doesn’t do anything for me.

One Answer

you may try using folium.plugins.HeatMap()

this source has converted geo.json to feature group for using HeatMap() method. You may have a look: https://ocefpaf.github.io/python4oceanographers/blog/2015/11/16/folium_quiver/

Answered by Tasfia Shermin on June 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP