Create interactive maps¶
In [1]:
Copied!
import geogradev
import geogradev
In [2]:
Copied!
import ipyleaflet
from ipyleaflet import TileLayer
from ipyleaflet import GeoJSON
import json
import geopandas as gpd
import ipyleaflet
from ipyleaflet import TileLayer
from ipyleaflet import GeoJSON
import json
import geopandas as gpd
In [3]:
Copied!
m = ipyleaflet.Map(center=(20, 0), zoom=2)
url = "https://github.com/opengeos/datasets/releases/download/world/continents.geojson"
gdf = gpd.read_file(url)
data = gdf.__geo_interface__
gj = GeoJSON(data=data)
m.add_layer(gj)
bounds = gdf.total_bounds
m.fit_bounds([[bounds[1], bounds[0]], [bounds[3], bounds[2]]])
m
m = ipyleaflet.Map(center=(20, 0), zoom=2)
url = "https://github.com/opengeos/datasets/releases/download/world/continents.geojson"
gdf = gpd.read_file(url)
data = gdf.__geo_interface__
gj = GeoJSON(data=data)
m.add_layer(gj)
bounds = gdf.total_bounds
m.fit_bounds([[bounds[1], bounds[0]], [bounds[3], bounds[2]]])
m
Out[3]:
In [4]:
Copied!
gdf.total_bounds
gdf.total_bounds
Out[4]:
array([-179.99998854, -89. , 179.99998854, 83.62360016])
In [5]:
Copied!
m.fit_bounds(
[
[gdf.total_bounds[1], gdf.total_bounds[0]],
[gdf.total_bounds[3], gdf.total_bounds[2]],
]
)
m.fit_bounds(
[
[gdf.total_bounds[1], gdf.total_bounds[0]],
[gdf.total_bounds[3], gdf.total_bounds[2]],
]
)
In [6]:
Copied!
m = ipyleaflet.Map(center=(20, 0), zoom=2)
url = "https://github.com/opengeos/datasets/releases/download/us/us_southeast.geojson"
gdf = gpd.read_file(url)
data = gdf.__geo_interface__
gj = GeoJSON(data=data)
m.add_layer(gj)
bounds = gdf.total_bounds
m.fit_bounds([[bounds[1], bounds[0]], [bounds[3], bounds[2]]])
m
m = ipyleaflet.Map(center=(20, 0), zoom=2)
url = "https://github.com/opengeos/datasets/releases/download/us/us_southeast.geojson"
gdf = gpd.read_file(url)
data = gdf.__geo_interface__
gj = GeoJSON(data=data)
m.add_layer(gj)
bounds = gdf.total_bounds
m.fit_bounds([[bounds[1], bounds[0]], [bounds[3], bounds[2]]])
m
Out[6]:
In [7]:
Copied!
import geogradev
import geogradev