13 geopandas
Adding a GeoPandas GeoDataFrame to the map with a single line of code
Uncomment the following line to install leafmap if needed. You can also use conda to create a new environment to install geopandas and leafmap.
conda create geo -n python=3.8
conda activate geo
conda install geopandas
conda install mamba -c conda-forge
mamba install leafmap -c conda-forge
In [1]:
Copied!
# !pip install leafmap
# !pip install leafmap
In [2]:
Copied!
# !pip install geopandas
# !pip install geopandas
In [3]:
Copied!
import leafmap
import geopandas as gpd
import leafmap
import geopandas as gpd
In [4]:
Copied!
# leafmap.update_package()
# leafmap.update_package()
Use GeoPandas to read a GeoJSON from an HTTP URL and return it as a GeoDataFrame.
Sample data: https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson
In [5]:
Copied!
gdf = gpd.read_file(
"https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson"
)
gdf = gpd.read_file(
"https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson"
)
Skipping field coordinates: unsupported OGR type: 3
Add a GeoDataFrame to the map.
In [6]:
Copied!
m = leafmap.Map()
m.add_gdf(gdf, layer_name="Cable lines")
m
m = leafmap.Map()
m.add_gdf(gdf, layer_name="Cable lines")
m
Out[6]: