Geopatra¶
[1]:
import random
import geopatra
import geopandas
[2]:
world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
cities = geopandas.read_file(geopandas.datasets.get_path('naturalearth_cities'))
cities['value'] = [int(random.randint(10, 1000)) for i in range(len(cities))]
[3]:
world.head()
[3]:
pop_est | continent | name | iso_a3 | gdp_md_est | geometry | |
---|---|---|---|---|---|---|
0 | 920938 | Oceania | Fiji | FJI | 8374.0 | MULTIPOLYGON (((180.00000 -16.06713, 180.00000... |
1 | 53950935 | Africa | Tanzania | TZA | 150600.0 | POLYGON ((33.90371 -0.95000, 34.07262 -1.05982... |
2 | 603253 | Africa | W. Sahara | ESH | 906.5 | POLYGON ((-8.66559 27.65643, -8.66512 27.58948... |
3 | 35623680 | North America | Canada | CAN | 1674000.0 | MULTIPOLYGON (((-122.84000 49.00000, -122.9742... |
4 | 326625791 | North America | United States of America | USA | 18560000.0 | MULTIPOLYGON (((-122.84000 49.00000, -120.0000... |
[4]:
cities.head()
[4]:
name | geometry | value | |
---|---|---|---|
0 | Vatican City | POINT (12.45339 41.90328) | 934 |
1 | San Marino | POINT (12.44177 43.93610) | 202 |
2 | Vaduz | POINT (9.51667 47.13372) | 33 |
3 | Luxembourg | POINT (6.13000 49.61166) | 466 |
4 | Palikir | POINT (158.14997 6.91664) | 649 |
Interactive maps with folium¶
Map geodataframes with Folium
Supported Maps¶
- Geojson plots (Plot the geometries in geodataframes)
- Choropleth maps (Colors and Jazz)
- Markercluster (Count, Sum, Average)
- Heatmaps (Oooh 🔥)
Geojson maps¶
[5]:
cities.folium.plot()
[5]:
Make this Notebook Trusted to load map: File -> Trust Notebook
[6]:
# Directly interact with the function
m = geopatra.folium.geojson(cities, zoom=5)
Circle Maps¶
[7]:
cities.folium.circle(
tooltip=["name"],
radius=10,
fill=True,
fill_color='red',
zoom=100
)
[7]:
Make this Notebook Trusted to load map: File -> Trust Notebook
[8]:
# Directly interact with the function
m = geopatra.folium.circle(cities, zoom=5)
Choropleth maps¶
[9]:
world.folium.choropleth(color_by= 'pop_est',
tooltip=['name'],
color= 'green',
zoom= 1,
style = {'color': 'black',
'weight': 1,
'dashArray': '10, 5',
'fillOpacity': 0.5,
})
[9]:
Make this Notebook Trusted to load map: File -> Trust Notebook