'Display map from Folium/Geopandas saved in HMTL format (using Colab)
I'm using Geopandas and Folium to plot an interactive map using the following code in Google Colab:
mapa_interactivo = mapa1.explore(column="Tasa_Paro",
cmap="OrRd",)
m=folium.Map(location=[40.463667, -3.74922], zoom_start=5))
And I can save the information into HTML format, download it and display it on Google Chrome or Microsft Edge, for example. To save and download the HTML file I use this code:
mapa_interactivo.save("Mapa_Tasa_Paro_Provincias_Geopandas_Interactivo.html")
from google.colab import files
files.download("Mapa_Tasa_Paro_Provincias_Geopandas_Interactivo.html")
However, I'm not able to display the map directly on Colab.
I've used the following options to achieve it, but none of them work:
folium.element.IFrame(html="Mapa_Tasa_Paro_Provincias_Geopandas_Interactivo.html", width=500, height=300)
from IPython.display import display
display(mapa_interactivo)
from IPython.display import HTML, display
mapa_interactivo._build_map()
width, height = (400,500) # width and height of the displayed iFrame, in pixels
srcdoc = mapa_interactivo.HTML.replace('"', '"')
embed = HTML('<iframe srcdoc="{}" '
'style="width: {}px; height: {}px; display:block; width: 50%; margin: 0 auto; '
'border: none"></iframe>'.format(srcdoc, width, height))
embed
from IPython.display import display, HTML
display(HTML("C:/Users/alex9_000/Downloads/Mapa_Tasa_Paro_Provincias_Geopandas_Interactivo.html"))
from IPython.display import IFrame
IFrame(src='C:/Users/alex9_000/Downloads/Mapa_Tasa_Paro_Provincias_Geopandas_Interactivo.html', width=900, height=600)
from IPython.display import HTML
HTML(data = '<iframe src=Mapa_Tasa_Paro_Provincias_Geopandas_Interactivo.org width=700 height=350></iframe>')
%%html
'<iframe src=Mapa_Tasa_Paro_Provincias_Geopandas_Interactivo.org width=700 height=350></iframe>'
Any ideas?
(By the way, I'm using Folium 0.12.1.post1 version)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
