Folium Demo¶
In [3]:
Copied!
import portgeo.foliumap as portgeo
import geopandas as gpd
import pandas as pd
import numpy as np
import portgeo.foliumap as portgeo
import geopandas as gpd
import pandas as pd
import numpy as np
In [2]:
Copied!
m = portgeo.Map()
url = "https://github.com/opengeos/datasets/releases/download/world/continents.geojson"
m.add_geojson(
url,
name="Continents",
center=(20, 0),
zoom=1,
key_on="CONTINENT",
tooltip_fields=["CONTINENT"],
tooltip_aliases=["Continent"],
style={"color": "blue", "weight": 2, "fillOpacity": 0.2},
)
m.add_layer_control()
m
m = portgeo.Map()
url = "https://github.com/opengeos/datasets/releases/download/world/continents.geojson"
m.add_geojson(
url,
name="Continents",
center=(20, 0),
zoom=1,
key_on="CONTINENT",
tooltip_fields=["CONTINENT"],
tooltip_aliases=["Continent"],
style={"color": "blue", "weight": 2, "fillOpacity": 0.2},
)
m.add_layer_control()
m
Out[2]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [8]:
Copied!
url = "https://github.com/opengeos/datasets/releases/download/us/us_states.geojson"
gdf = gpd.read_file(url)
gdf["value"] = np.random.randint(0, 100, size=len(gdf))
gdf.head()
url = "https://github.com/opengeos/datasets/releases/download/us/us_states.geojson"
gdf = gpd.read_file(url)
gdf["value"] = np.random.randint(0, 100, size=len(gdf))
gdf.head()
Out[8]:
id | name | geometry | value | |
---|---|---|---|---|
0 | AL | Alabama | MULTIPOLYGON (((-87.3593 35.00118, -85.60668 3... | 77 |
1 | AK | Alaska | MULTIPOLYGON (((-131.60202 55.11798, -131.5691... | 49 |
2 | AZ | Arizona | MULTIPOLYGON (((-109.0425 37.00026, -109.04798... | 87 |
3 | AR | Arkansas | MULTIPOLYGON (((-94.47384 36.50186, -90.15254 ... | 92 |
4 | CA | California | MULTIPOLYGON (((-123.23326 42.00619, -122.3788... | 46 |
In [9]:
Copied!
m = portgeo.Map(center=(40, -100), zoom=4)
m.add_choropleth(
gdf=gdf,
column="value",
join_col="name",
key_on="feature.properties.name",
fill_color="YlOrRd",
legend_name="US States",
tooltip_fields=["name", "value"],
tooltip_alias={"name": "State", "value": "Value"},
name="US States",
)
m.add_layer_control()
m
m = portgeo.Map(center=(40, -100), zoom=4)
m.add_choropleth(
gdf=gdf,
column="value",
join_col="name",
key_on="feature.properties.name",
fill_color="YlOrRd",
legend_name="US States",
tooltip_fields=["name", "value"],
tooltip_alias={"name": "State", "value": "Value"},
name="US States",
)
m.add_layer_control()
m
Out[9]:
Make this Notebook Trusted to load map: File -> Trust Notebook