diff --git a/Dockerfile b/Dockerfile
index 4503ff4bff..2e0dccfbdd 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -5,8 +5,8 @@ RUN mamba install -c conda-forge leafmap geopandas "localtileserver>=0.10.0" osm
fix-permissions "/home/${NB_USER}"
RUN mkdir ./examples
-COPY /examples/notebooks ./examples/notebooks
-COPY /examples/workshops ./examples/workshops
+COPY /docs/notebooks ./examples/notebooks
+COPY /docs/workshops ./examples/workshops
COPY /examples/data ./examples/data
COPY /examples/README.md ./examples/README.md
diff --git a/docs/faq.md b/docs/faq.md
index 46d3674f09..375dbde810 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -11,7 +11,7 @@ with Google Colab, `import leafmap` will automatically use the `folium` plotting
## How to use a specific plotting backend
-`leafmap` has three plotting backends: [folium](https://github.com/python-visualization/folium), [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet), and [here-map-widget-for-jupyter](https://github.com/heremaps/here-map-widget-for-jupyter). If you are using `leafmap` with Jupyter installed locally, `import leafmap` will use the `ipyleaflet` plotting backend by default. If you are using `leafmap` with [Google Colab](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/01_leafmap_intro.ipynb), `import leafmap` will use the `folium` plotting backend by default. Note that Google Colab does not yet support `ipyleaflet` ([source](https://github.com/googlecolab/colabtools/issues/498#issuecomment-695335421)). Therefore, you won't be able to access the `leafmap` toolbar in Colab. Note that the backends do not offer equal functionality. Some interactive functionality in `ipyleaflet` might not be available in `folium` or `heremap`. To use a specific plotting backend, use one of the following:
+`leafmap` has three plotting backends: [folium](https://github.com/python-visualization/folium), [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet), and [here-map-widget-for-jupyter](https://github.com/heremaps/here-map-widget-for-jupyter). If you are using `leafmap` with Jupyter installed locally, `import leafmap` will use the `ipyleaflet` plotting backend by default. If you are using `leafmap` with [Google Colab](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/01_leafmap_intro.ipynb), `import leafmap` will use the `folium` plotting backend by default. Note that Google Colab does not yet support `ipyleaflet` ([source](https://github.com/googlecolab/colabtools/issues/498#issuecomment-695335421)). Therefore, you won't be able to access the `leafmap` toolbar in Colab. Note that the backends do not offer equal functionality. Some interactive functionality in `ipyleaflet` might not be available in `folium` or `heremap`. To use a specific plotting backend, use one of the following:
- `import leafmap.leafmap as leafmap`
- `import leafmap.foliumap as leafmap`
diff --git a/docs/notebooks/01_leafmap_intro.ipynb b/docs/notebooks/01_leafmap_intro.ipynb
index 2d56ffa743..6a53c8c7ca 100644
--- a/docs/notebooks/01_leafmap_intro.ipynb
+++ b/docs/notebooks/01_leafmap_intro.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/01_leafmap_intro.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/01_leafmap_intro.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/01_leafmap_intro.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Introducing the leafmap Python package for interactive mapping**\n",
diff --git a/docs/notebooks/02_using_basemaps.ipynb b/docs/notebooks/02_using_basemaps.ipynb
index decc205ab1..0e4c9e693a 100644
--- a/docs/notebooks/02_using_basemaps.ipynb
+++ b/docs/notebooks/02_using_basemaps.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/02_using_basemaps.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/02_using_basemaps.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/02_using_basemaps.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Using basemaps in leafmap**\n",
diff --git a/docs/notebooks/03_cog_stac.ipynb b/docs/notebooks/03_cog_stac.ipynb
index 545ca2f742..0d53c780fa 100644
--- a/docs/notebooks/03_cog_stac.ipynb
+++ b/docs/notebooks/03_cog_stac.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/03_cog_stac.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/03_cog_stac.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/03_cog_stac.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Using Cloud Optimized GeoTIFF (COG) and SpatioTemporal Asset Catalog (STAC)**\n",
diff --git a/docs/notebooks/04_cog_mosaic.ipynb b/docs/notebooks/04_cog_mosaic.ipynb
index d1d5344203..3386e19529 100644
--- a/docs/notebooks/04_cog_mosaic.ipynb
+++ b/docs/notebooks/04_cog_mosaic.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/04_cog_mosaic.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/04_cog_mosaic.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/04_cog_mosaic.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Creating a virtual mosaic of Cloud Optimized GeoTIFFs (COG)**\n",
diff --git a/docs/notebooks/05_load_raster.ipynb b/docs/notebooks/05_load_raster.ipynb
index 1a131afa89..a5dfa1ecc3 100644
--- a/docs/notebooks/05_load_raster.ipynb
+++ b/docs/notebooks/05_load_raster.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/05_load_raster.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/05_load_raster.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/05_load_raster.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Loading local raster datasets with leafmap**\n",
diff --git a/docs/notebooks/06_legend.ipynb b/docs/notebooks/06_legend.ipynb
index 09dd6f7595..d617b1d253 100644
--- a/docs/notebooks/06_legend.ipynb
+++ b/docs/notebooks/06_legend.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/06_legend.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/06_legend.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/06_legend.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Adding custom legends to the map**\n",
diff --git a/docs/notebooks/07_colorbar.ipynb b/docs/notebooks/07_colorbar.ipynb
index 234b3b06c3..ed2c858350 100644
--- a/docs/notebooks/07_colorbar.ipynb
+++ b/docs/notebooks/07_colorbar.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/07_colorbar.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/07_colorbar.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/07_colorbar.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Adding custom colorbars to the map**\n",
diff --git a/docs/notebooks/08_whitebox.ipynb b/docs/notebooks/08_whitebox.ipynb
index a8f3bf3010..32136626d1 100644
--- a/docs/notebooks/08_whitebox.ipynb
+++ b/docs/notebooks/08_whitebox.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/08_whitebox.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/08_whitebox.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/08_whitebox.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Using WhiteboxTools with leafmap**\n",
diff --git a/docs/notebooks/09_csv_to_points.ipynb b/docs/notebooks/09_csv_to_points.ipynb
index d335aa4a99..085c778d27 100644
--- a/docs/notebooks/09_csv_to_points.ipynb
+++ b/docs/notebooks/09_csv_to_points.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/09_csv_to_points.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/09_csv_to_points.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/09_csv_to_points.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Converting CSV to points**\n",
diff --git a/docs/notebooks/10_add_vector.ipynb b/docs/notebooks/10_add_vector.ipynb
index 0b72972227..12f3f24949 100644
--- a/docs/notebooks/10_add_vector.ipynb
+++ b/docs/notebooks/10_add_vector.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/10_add_vector.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/10_add_vector.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/10_add_vector.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Adding local vector data (e.g., shp, geojson, kml) to the map**\n",
diff --git a/docs/notebooks/11_linked_maps.ipynb b/docs/notebooks/11_linked_maps.ipynb
index 4f88ee0cfe..f52f12f4fb 100644
--- a/docs/notebooks/11_linked_maps.ipynb
+++ b/docs/notebooks/11_linked_maps.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/11_linked_maps.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/11_linked_maps.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/11_linked_maps.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Creating linked maps for visualizing multiple maps simultaneously**\n",
diff --git a/docs/notebooks/12_split_map.ipynb b/docs/notebooks/12_split_map.ipynb
index 92be8b95ea..198d965b20 100644
--- a/docs/notebooks/12_split_map.ipynb
+++ b/docs/notebooks/12_split_map.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/12_split_map.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/12_split_map.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/12_split_map.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Creating a split-panel map with only one line of code**\n",
diff --git a/docs/notebooks/13_geopandas.ipynb b/docs/notebooks/13_geopandas.ipynb
index f40f919886..03e7270773 100644
--- a/docs/notebooks/13_geopandas.ipynb
+++ b/docs/notebooks/13_geopandas.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/13_geopandas.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/13_geopandas.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/13_geopandas.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Adding a GeoPandas GeoDataFrame to the map with a single line of code**\n",
diff --git a/docs/notebooks/14_postgis.ipynb b/docs/notebooks/14_postgis.ipynb
index 0a7f28c6a8..c3b5728ace 100644
--- a/docs/notebooks/14_postgis.ipynb
+++ b/docs/notebooks/14_postgis.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/14_postgis.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/14_postgis.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/14_postgis.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Adding data from a PostGIS database to the map**\n",
diff --git a/docs/notebooks/15_openstreetmap.ipynb b/docs/notebooks/15_openstreetmap.ipynb
index 83e866a124..332db01775 100644
--- a/docs/notebooks/15_openstreetmap.ipynb
+++ b/docs/notebooks/15_openstreetmap.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/15_openstreetmap.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/15_openstreetmap.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/15_openstreetmap.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Downloading OpenStreetMap data with a single line of code**\n",
diff --git a/docs/notebooks/16_heremap.ipynb b/docs/notebooks/16_heremap.ipynb
index 6e2c05b749..5200e59d02 100644
--- a/docs/notebooks/16_heremap.ipynb
+++ b/docs/notebooks/16_heremap.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/16_heremap.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/16_heremap.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/16_heremap.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Using [HERE Map Widget for Jupyter](https://github.com/heremaps/here-map-widget-for-jupyter) as a plotting backend**\n",
diff --git a/docs/notebooks/17_vector_tile_layer.ipynb b/docs/notebooks/17_vector_tile_layer.ipynb
index f757db8bbc..ee0eb30421 100644
--- a/docs/notebooks/17_vector_tile_layer.ipynb
+++ b/docs/notebooks/17_vector_tile_layer.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/17_vector_tile_layer.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/17_vector_tile_layer.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/17_vector_tile_layer.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Adding a vector tile layer to the map**\n",
diff --git a/docs/notebooks/18_point_layer.ipynb b/docs/notebooks/18_point_layer.ipynb
index dd865773ae..13070a8c1b 100644
--- a/docs/notebooks/18_point_layer.ipynb
+++ b/docs/notebooks/18_point_layer.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/18_point_layer.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/18_point_layer.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/18_point_layer.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Adding a point layer with popup attributes to the map**\n",
diff --git a/docs/notebooks/19_map_to_html.ipynb b/docs/notebooks/19_map_to_html.ipynb
index 7eea911bbc..d489728174 100644
--- a/docs/notebooks/19_map_to_html.ipynb
+++ b/docs/notebooks/19_map_to_html.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/19_map_to_html.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/19_map_to_html.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/19_map_to_html.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Saving maps as a html file**\n",
diff --git a/docs/notebooks/20_planet_imagery.ipynb b/docs/notebooks/20_planet_imagery.ipynb
index 9393a4c20a..e0b3c278df 100644
--- a/docs/notebooks/20_planet_imagery.ipynb
+++ b/docs/notebooks/20_planet_imagery.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/20_planet_imagery.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/20_planet_imagery.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/20_planet_imagery.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Adding Planet global monthly and quarterly mosaic**\n",
diff --git a/docs/notebooks/21_ts_inspector.ipynb b/docs/notebooks/21_ts_inspector.ipynb
index afa62281c5..511b6e7cef 100644
--- a/docs/notebooks/21_ts_inspector.ipynb
+++ b/docs/notebooks/21_ts_inspector.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/21_ts_inspector.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/21_ts_inspector.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/21_ts_inspector.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Using timeseries inspector with a single click**\n",
diff --git a/docs/notebooks/22_time_slider.ipynb b/docs/notebooks/22_time_slider.ipynb
index 384bfc624c..14fea25cad 100644
--- a/docs/notebooks/22_time_slider.ipynb
+++ b/docs/notebooks/22_time_slider.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/22_time_slider.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/22_time_slider.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/22_time_slider.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Using time slider for visualizing timeseries images**\n",
diff --git a/docs/notebooks/23_colormaps.ipynb b/docs/notebooks/23_colormaps.ipynb
index 02b16069a0..df2787b860 100644
--- a/docs/notebooks/23_colormaps.ipynb
+++ b/docs/notebooks/23_colormaps.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/23_colormaps.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/23_colormaps.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/23_colormaps.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Creating colormaps with a single line of code**\n",
diff --git a/docs/notebooks/24_heatmap.ipynb b/docs/notebooks/24_heatmap.ipynb
index 064e0a91d0..cb4378a7fb 100644
--- a/docs/notebooks/24_heatmap.ipynb
+++ b/docs/notebooks/24_heatmap.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/24_heatmap.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/24_heatmap.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/24_heatmap.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Creating heat maps from csv**\n",
diff --git a/docs/notebooks/25_map_title.ipynb b/docs/notebooks/25_map_title.ipynb
index aa7616335a..dbb7d244a7 100644
--- a/docs/notebooks/25_map_title.ipynb
+++ b/docs/notebooks/25_map_title.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/25_map_title.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/25_map_title.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/25_map_title.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Creating a population heat map with a colorbar and map title**\n",
diff --git a/docs/notebooks/26_kepler_gl.ipynb b/docs/notebooks/26_kepler_gl.ipynb
index 8232ed0ea9..ca1beb150a 100644
--- a/docs/notebooks/26_kepler_gl.ipynb
+++ b/docs/notebooks/26_kepler_gl.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/26_kepler_gl.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/26_kepler_gl.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/26_kepler_gl.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/27_basemap_gallery.ipynb b/docs/notebooks/27_basemap_gallery.ipynb
index 08d9bc2403..d6da19d541 100644
--- a/docs/notebooks/27_basemap_gallery.ipynb
+++ b/docs/notebooks/27_basemap_gallery.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/27_basemap_gallery.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/27_basemap_gallery.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/27_basemap_gallery.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/28_publish_map.ipynb b/docs/notebooks/28_publish_map.ipynb
index 1bfbae36e4..ceafbcafbd 100644
--- a/docs/notebooks/28_publish_map.ipynb
+++ b/docs/notebooks/28_publish_map.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/28_publish_map.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/28_publish_map.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/28_publish_map.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/29_pydeck.ipynb b/docs/notebooks/29_pydeck.ipynb
index 03f32f5689..965053ec5b 100644
--- a/docs/notebooks/29_pydeck.ipynb
+++ b/docs/notebooks/29_pydeck.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/29_pydeck.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/29_pydeck.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/29_pydeck.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/30_census_data.ipynb b/docs/notebooks/30_census_data.ipynb
index 879528c17c..a08f469fb0 100644
--- a/docs/notebooks/30_census_data.ipynb
+++ b/docs/notebooks/30_census_data.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/30_census_data.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/30_census_data.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/30_census_data.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/31_search_basemaps.ipynb b/docs/notebooks/31_search_basemaps.ipynb
index 89e64a44b3..d23ca08430 100644
--- a/docs/notebooks/31_search_basemaps.ipynb
+++ b/docs/notebooks/31_search_basemaps.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/31_search_basemaps.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/31_search_basemaps.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/31_search_basemaps.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/32_local_tile.ipynb b/docs/notebooks/32_local_tile.ipynb
index 6ef3007ccb..49a38cb4dd 100644
--- a/docs/notebooks/32_local_tile.ipynb
+++ b/docs/notebooks/32_local_tile.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/32_local_tile.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/32_local_tile.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/32_local_tile.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Using local raster datasets or remote Cloud Optimized GeoTIFFs (COG) with leafmap**\n",
diff --git a/docs/notebooks/33_image_overlay.ipynb b/docs/notebooks/33_image_overlay.ipynb
index cecf81b517..47394e1071 100644
--- a/docs/notebooks/33_image_overlay.ipynb
+++ b/docs/notebooks/33_image_overlay.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/33_image_overlay.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/33_image_overlay.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/33_image_overlay.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/34_add_points_from_xy.ipynb b/docs/notebooks/34_add_points_from_xy.ipynb
index a0ae025ee8..92c4f0ea1f 100644
--- a/docs/notebooks/34_add_points_from_xy.ipynb
+++ b/docs/notebooks/34_add_points_from_xy.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/34_add_points_from_xy.ipynb)\n",
- "\n",
+ "\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
]
diff --git a/docs/notebooks/35_circle_markers.ipynb b/docs/notebooks/35_circle_markers.ipynb
index 30de546190..35795ad15b 100644
--- a/docs/notebooks/35_circle_markers.ipynb
+++ b/docs/notebooks/35_circle_markers.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/35_circle_markers.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/35_circle_markers.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/35_circle_markers.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/36_add_labels.ipynb b/docs/notebooks/36_add_labels.ipynb
index 5cfb7ff8f9..141d57d8d2 100644
--- a/docs/notebooks/36_add_labels.ipynb
+++ b/docs/notebooks/36_add_labels.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/36_add_labels.ipynb)\n",
- "\n",
+ "\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
]
diff --git a/docs/notebooks/37_planetary_computer.ipynb b/docs/notebooks/37_planetary_computer.ipynb
index db725a6b56..ff3251c709 100644
--- a/docs/notebooks/37_planetary_computer.ipynb
+++ b/docs/notebooks/37_planetary_computer.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/37_planetary_computer.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/37_planetary_computer.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/37_planetary_computer.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/38_plotly.ipynb b/docs/notebooks/38_plotly.ipynb
index a14480b05f..8306272ec0 100644
--- a/docs/notebooks/38_plotly.ipynb
+++ b/docs/notebooks/38_plotly.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/38_plotly.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/38_plotly.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/38_plotly.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/39_inspector_tool.ipynb b/docs/notebooks/39_inspector_tool.ipynb
index bde19e32c9..373f54d263 100644
--- a/docs/notebooks/39_inspector_tool.ipynb
+++ b/docs/notebooks/39_inspector_tool.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/39_inspector_tool.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/39_inspector_tool.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/39_inspector_tool.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/40_plotly_gui.ipynb b/docs/notebooks/40_plotly_gui.ipynb
index 594fbaf942..16814b1239 100644
--- a/docs/notebooks/40_plotly_gui.ipynb
+++ b/docs/notebooks/40_plotly_gui.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/40_plotly_gui.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/40_plotly_gui.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/40_plotly_gui.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/41_raster_gui.ipynb b/docs/notebooks/41_raster_gui.ipynb
index 6f1519a946..4b83b0c946 100644
--- a/docs/notebooks/41_raster_gui.ipynb
+++ b/docs/notebooks/41_raster_gui.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/41_raster_gui.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/41_raster_gui.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/41_raster_gui.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/42_create_cog.ipynb b/docs/notebooks/42_create_cog.ipynb
index 9ff0396eee..d032d724da 100644
--- a/docs/notebooks/42_create_cog.ipynb
+++ b/docs/notebooks/42_create_cog.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/42_create_cog.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/42_create_cog.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/42_create_cog.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/43_search_control.ipynb b/docs/notebooks/43_search_control.ipynb
index 6bb7bb1ba9..ac7a4730d0 100644
--- a/docs/notebooks/43_search_control.ipynb
+++ b/docs/notebooks/43_search_control.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/43_search_control.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/43_search_control.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/43_search_control.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/44_attribute_table.ipynb b/docs/notebooks/44_attribute_table.ipynb
index 760835e5dc..d05c8fc44e 100644
--- a/docs/notebooks/44_attribute_table.ipynb
+++ b/docs/notebooks/44_attribute_table.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/44_attribute_table.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/44_attribute_table.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/44_attribute_table.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/45_create_vector.ipynb b/docs/notebooks/45_create_vector.ipynb
index 23230273cc..72a70d2934 100644
--- a/docs/notebooks/45_create_vector.ipynb
+++ b/docs/notebooks/45_create_vector.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/45_create_vector.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/45_create_vector.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/45_create_vector.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/46_edit_vector.ipynb b/docs/notebooks/46_edit_vector.ipynb
index 34a74e85db..f0ce2223eb 100644
--- a/docs/notebooks/46_edit_vector.ipynb
+++ b/docs/notebooks/46_edit_vector.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/46_edit_vector.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/46_edit_vector.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/46_edit_vector.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/47_numpy_to_cog.ipynb b/docs/notebooks/47_numpy_to_cog.ipynb
index bcbf15b539..26411b03ee 100644
--- a/docs/notebooks/47_numpy_to_cog.ipynb
+++ b/docs/notebooks/47_numpy_to_cog.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/47_numpy_to_cog.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/47_numpy_to_cog.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/47_numpy_to_cog.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Create a fresh conda env to run this example if needed.\n",
diff --git a/docs/notebooks/48_lidar.ipynb b/docs/notebooks/48_lidar.ipynb
index 79b303d01c..c835d6cb11 100644
--- a/docs/notebooks/48_lidar.ipynb
+++ b/docs/notebooks/48_lidar.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/48_lidar.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/48_lidar.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/48_lidar.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Visualizing LiDAR data in 3D with only one line of code**\n",
diff --git a/docs/notebooks/49_split_control.ipynb b/docs/notebooks/49_split_control.ipynb
index 6ecbc04c20..b98519a751 100644
--- a/docs/notebooks/49_split_control.ipynb
+++ b/docs/notebooks/49_split_control.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/49_split_control.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/49_split_control.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/49_split_control.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Creating a split-panel map**\n",
diff --git a/docs/notebooks/50_marker_cluster.ipynb b/docs/notebooks/50_marker_cluster.ipynb
index f3ecbe9a45..83ef9f37cc 100644
--- a/docs/notebooks/50_marker_cluster.ipynb
+++ b/docs/notebooks/50_marker_cluster.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/50_marker_cluster.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/50_marker_cluster.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/50_marker_cluster.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Creating a marker cluster with custom icons**\n",
diff --git a/docs/notebooks/51_clip_image.ipynb b/docs/notebooks/51_clip_image.ipynb
index 463f309737..69724d9624 100644
--- a/docs/notebooks/51_clip_image.ipynb
+++ b/docs/notebooks/51_clip_image.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/51_clip_image.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/51_clip_image.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/51_clip_image.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/52_netcdf.ipynb b/docs/notebooks/52_netcdf.ipynb
index ef9e079816..06b6b278ac 100644
--- a/docs/notebooks/52_netcdf.ipynb
+++ b/docs/notebooks/52_netcdf.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/52_netcdf.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/52_netcdf.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/52_netcdf.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Visualizing NetCDF data**\n",
diff --git a/docs/notebooks/53_choropleth.ipynb b/docs/notebooks/53_choropleth.ipynb
index 7f34618ce5..b3cf6b4dc2 100644
--- a/docs/notebooks/53_choropleth.ipynb
+++ b/docs/notebooks/53_choropleth.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/53_choropleth.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/53_choropleth.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/53_choropleth.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/54_plot_raster.ipynb b/docs/notebooks/54_plot_raster.ipynb
index db14f1c341..1c4e1ff1c8 100644
--- a/docs/notebooks/54_plot_raster.ipynb
+++ b/docs/notebooks/54_plot_raster.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/54_plot_raster.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/54_plot_raster.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/54_plot_raster.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/55_lidar.ipynb b/docs/notebooks/55_lidar.ipynb
index 7ea95c7bcd..6cd2d2487c 100644
--- a/docs/notebooks/55_lidar.ipynb
+++ b/docs/notebooks/55_lidar.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/55_lidar.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/55_lidar.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/55_lidar.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**LiDAR data analysis and visualization with whitebox and leafmap**\n",
diff --git a/docs/notebooks/56_download_ned.ipynb b/docs/notebooks/56_download_ned.ipynb
index d87cc33e45..82acb50a36 100644
--- a/docs/notebooks/56_download_ned.ipynb
+++ b/docs/notebooks/56_download_ned.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/56_download_ned.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/56_download_ned.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/56_download_ned.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Downloading 10-m National Elevation Dataset (NED) with only one line of code**"
diff --git a/docs/notebooks/57_national_map.ipynb b/docs/notebooks/57_national_map.ipynb
index b4a4300e9f..6f8848bb6f 100644
--- a/docs/notebooks/57_national_map.ipynb
+++ b/docs/notebooks/57_national_map.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/57_national_map.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/57_national_map.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/57_national_map.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"### Downloading various shapes from the National Map\n",
diff --git a/docs/notebooks/58_bokeh.ipynb b/docs/notebooks/58_bokeh.ipynb
index ab8717f345..f1701ebf47 100644
--- a/docs/notebooks/58_bokeh.ipynb
+++ b/docs/notebooks/58_bokeh.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/58_bokeh.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/58_bokeh.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/58_bokeh.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/59_create_legend.ipynb b/docs/notebooks/59_create_legend.ipynb
index 20b8d9bbc7..b15c60cc05 100644
--- a/docs/notebooks/59_create_legend.ipynb
+++ b/docs/notebooks/59_create_legend.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/59_create_legend.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/59_create_legend.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/59_create_legend.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/60_add_widget.ipynb b/docs/notebooks/60_add_widget.ipynb
index 2574e51a25..1724c21565 100644
--- a/docs/notebooks/60_add_widget.ipynb
+++ b/docs/notebooks/60_add_widget.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/60_add_widget.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/60_add_widget.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/60_add_widget.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/61_vector_to_gif.ipynb b/docs/notebooks/61_vector_to_gif.ipynb
index 5eed9ddb34..808a878499 100644
--- a/docs/notebooks/61_vector_to_gif.ipynb
+++ b/docs/notebooks/61_vector_to_gif.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/61_vector_to_gif.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/61_vector_to_gif.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/61_vector_to_gif.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Creating animated GIF from vector data**\n",
diff --git a/docs/notebooks/62_folium_colorbar.ipynb b/docs/notebooks/62_folium_colorbar.ipynb
index bc0c985673..e145f1d57e 100644
--- a/docs/notebooks/62_folium_colorbar.ipynb
+++ b/docs/notebooks/62_folium_colorbar.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/62_folium_colorbar.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/62_folium_colorbar.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/62_folium_colorbar.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Adding colorbars to a folium map**\n",
diff --git a/docs/notebooks/63_arcgis.ipynb b/docs/notebooks/63_arcgis.ipynb
index a0564f4322..f952e4de4b 100644
--- a/docs/notebooks/63_arcgis.ipynb
+++ b/docs/notebooks/63_arcgis.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/63_arcgis.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/63_arcgis.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/63_arcgis.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/64_stac_search.ipynb b/docs/notebooks/64_stac_search.ipynb
index a291780efa..e2f6fcb3b4 100644
--- a/docs/notebooks/64_stac_search.ipynb
+++ b/docs/notebooks/64_stac_search.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/zz_notebook_template.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/64_stac_search.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/64_stac_search.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/65_sagemaker.ipynb b/docs/notebooks/65_sagemaker.ipynb
index 97d97d4ae1..847e9305c8 100644
--- a/docs/notebooks/65_sagemaker.ipynb
+++ b/docs/notebooks/65_sagemaker.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/65_sagemaker.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/65_sagemaker.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/65_sagemaker.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)"
]
},
diff --git a/docs/notebooks/66_gradio.ipynb b/docs/notebooks/66_gradio.ipynb
index d811807ade..4171b729b8 100644
--- a/docs/notebooks/66_gradio.ipynb
+++ b/docs/notebooks/66_gradio.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/66_gradio.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/66_gradio.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/66_gradio.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Developing interactive web apps with gradio and leafmap**\n",
diff --git a/docs/notebooks/67_maxar_open_data.ipynb b/docs/notebooks/67_maxar_open_data.ipynb
index a1dad323ab..2caaddd562 100644
--- a/docs/notebooks/67_maxar_open_data.ipynb
+++ b/docs/notebooks/67_maxar_open_data.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/67_maxar_open_data.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/67_maxar_open_data.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/67_maxar_open_data.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Visualizing Maxar Open Data with Leafmap**\n",
diff --git a/docs/notebooks/68_openaerialmap.ipynb b/docs/notebooks/68_openaerialmap.ipynb
index 19679cdc6d..17ad76ecd9 100644
--- a/docs/notebooks/68_openaerialmap.ipynb
+++ b/docs/notebooks/68_openaerialmap.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/68_openaerialmap.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/68_openaerialmap.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/68_openaerialmap.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Searching and visualizing OpenAerialMap imagery interactively**\n",
diff --git a/docs/notebooks/69_turkey_earthquake.ipynb b/docs/notebooks/69_turkey_earthquake.ipynb
index 052cbef77d..b781c97f90 100644
--- a/docs/notebooks/69_turkey_earthquake.ipynb
+++ b/docs/notebooks/69_turkey_earthquake.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/69_turkey_earthquake.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/69_turkey_earthquake.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/69_turkey_earthquake.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Visualizing Maxar Open Data for the 2023 Turkey-Syria Earthquake**\n",
diff --git a/docs/notebooks/70_zonal_stats.ipynb b/docs/notebooks/70_zonal_stats.ipynb
index 776cb9e557..b9f75e476f 100644
--- a/docs/notebooks/70_zonal_stats.ipynb
+++ b/docs/notebooks/70_zonal_stats.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/70_zonal_stats.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/70_zonal_stats.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/70_zonal_stats.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Calculating zonal statistics - summarizing geospatial raster datasets based on vector geometries**\n",
diff --git a/docs/notebooks/71_aws_s3.ipynb b/docs/notebooks/71_aws_s3.ipynb
index 0ded5269a7..bee069278f 100644
--- a/docs/notebooks/71_aws_s3.ipynb
+++ b/docs/notebooks/71_aws_s3.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/71_aws_s3.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/71_aws_s3.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/71_aws_s3.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Loading geospatial datasets from an AWS S3 bucket**\n",
diff --git a/docs/notebooks/72_timelapse.ipynb b/docs/notebooks/72_timelapse.ipynb
index b4c638954f..fc62c80d7a 100644
--- a/docs/notebooks/72_timelapse.ipynb
+++ b/docs/notebooks/72_timelapse.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/72_timelapse.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/72_timelapse.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/72_timelapse.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Creating timelapse animations from satellite imagery timeseries**\n",
diff --git a/docs/notebooks/73_custom_stac.ipynb b/docs/notebooks/73_custom_stac.ipynb
index 329f1647d4..bac95d015e 100644
--- a/docs/notebooks/73_custom_stac.ipynb
+++ b/docs/notebooks/73_custom_stac.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/73_custom_stac.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/73_custom_stac.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/73_custom_stac.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Searching Geospatial Data Interactively with Custom STAC API Endpoints**\n",
diff --git a/docs/notebooks/74_map_tiles_to_geotiff.ipynb b/docs/notebooks/74_map_tiles_to_geotiff.ipynb
index 4caafb9310..7cdc97aadc 100644
--- a/docs/notebooks/74_map_tiles_to_geotiff.ipynb
+++ b/docs/notebooks/74_map_tiles_to_geotiff.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/74_map_tiles_to_geotiff.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/74_map_tiles_to_geotiff.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/74_map_tiles_to_geotiff.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Downloading maps tiles and converting them to a GeoTIFF file**\n",
diff --git a/docs/notebooks/75_segment_anything.ipynb b/docs/notebooks/75_segment_anything.ipynb
index 8ed0e450d5..f1849823d5 100644
--- a/docs/notebooks/75_segment_anything.ipynb
+++ b/docs/notebooks/75_segment_anything.ipynb
@@ -8,7 +8,7 @@
"# Segment Anything Model for Geospatial Data \n",
"\n",
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/75_segment_anything.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/75_segment_anything.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/75_segment_anything.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"This notebook shows how to use segment satellite imagery using the Segment Anything Model (SAM) with a few lines of code. \n",
diff --git a/docs/notebooks/76_image_comparison.ipynb b/docs/notebooks/76_image_comparison.ipynb
index c04043b552..54daaa2947 100644
--- a/docs/notebooks/76_image_comparison.ipynb
+++ b/docs/notebooks/76_image_comparison.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/76_image_comparison.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/76_image_comparison.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/76_image_comparison.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Comparing images with an interactive slider**\n",
diff --git a/docs/notebooks/77_split_raster.ipynb b/docs/notebooks/77_split_raster.ipynb
index 1a8b38203d..6d7622eb29 100644
--- a/docs/notebooks/77_split_raster.ipynb
+++ b/docs/notebooks/77_split_raster.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/77_split_raster.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/77_split_raster.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/77_split_raster.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/78_read_raster.ipynb b/docs/notebooks/78_read_raster.ipynb
index 830b4042b5..7d1d9cca1b 100644
--- a/docs/notebooks/78_read_raster.ipynb
+++ b/docs/notebooks/78_read_raster.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/78_read_raster.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/78_read_raster.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/78_read_raster.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Interactive Extraction and Visualization of AWS Open Geospatial Data**\n",
diff --git a/docs/notebooks/79_timeseries.ipynb b/docs/notebooks/79_timeseries.ipynb
index 312e34cf39..e2e025238e 100644
--- a/docs/notebooks/79_timeseries.ipynb
+++ b/docs/notebooks/79_timeseries.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/79_timeseries.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/79_timeseries.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/79_timeseries.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Visualizing time series images interactively with a time slider**\n",
diff --git a/docs/notebooks/80_solar.ipynb b/docs/notebooks/80_solar.ipynb
index 1174001b75..66989ef903 100644
--- a/docs/notebooks/80_solar.ipynb
+++ b/docs/notebooks/80_solar.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/80_solar.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/80_solar.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/80_solar.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/notebooks/81_buildings.ipynb b/docs/notebooks/81_buildings.ipynb
index d6b0920622..067eaabb20 100644
--- a/docs/notebooks/81_buildings.ipynb
+++ b/docs/notebooks/81_buildings.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/81_buildings.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/81_buildings.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/81_buildings.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Downloading Microsoft and Google Building Footprints**\n",
diff --git a/docs/notebooks/82_pmtiles.ipynb b/docs/notebooks/82_pmtiles.ipynb
index 66598fd6e0..01db983485 100644
--- a/docs/notebooks/82_pmtiles.ipynb
+++ b/docs/notebooks/82_pmtiles.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/82_pmtiles.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/82_pmtiles.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/82_pmtiles.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"\n",
diff --git a/docs/notebooks/83_vector_viz.ipynb b/docs/notebooks/83_vector_viz.ipynb
index 3b9029bba0..9ca759216c 100644
--- a/docs/notebooks/83_vector_viz.ipynb
+++ b/docs/notebooks/83_vector_viz.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/83_vector_viz.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/83_vector_viz.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/83_vector_viz.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Visualizing large vector datasets with lonboard**\n",
diff --git a/docs/notebooks/84_read_parquet.ipynb b/docs/notebooks/84_read_parquet.ipynb
index 2260561f26..c45ee0ce25 100644
--- a/docs/notebooks/84_read_parquet.ipynb
+++ b/docs/notebooks/84_read_parquet.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/84_read_parquet.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/84_read_parquet.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/84_read_parquet.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Reading GeoParquet files and visualizing vector data interactively**\n",
diff --git a/docs/notebooks/85_gedi.ipynb b/docs/notebooks/85_gedi.ipynb
index 3da76079c4..0ab627afe2 100644
--- a/docs/notebooks/85_gedi.ipynb
+++ b/docs/notebooks/85_gedi.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/85_gedi.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/85_gedi.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/85_gedi.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**How to search and download GEDI L4A dataset interactively**\n",
diff --git a/docs/notebooks/86_add_markers.ipynb b/docs/notebooks/86_add_markers.ipynb
index e545be9e80..dae792186e 100644
--- a/docs/notebooks/86_add_markers.ipynb
+++ b/docs/notebooks/86_add_markers.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/86_add_markers.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/86_add_markers.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/86_add_markers.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Adding markers to the map**\n",
diff --git a/docs/notebooks/87_actinia.ipynb b/docs/notebooks/87_actinia.ipynb
index 01af645bfe..a860eaccfd 100644
--- a/docs/notebooks/87_actinia.ipynb
+++ b/docs/notebooks/87_actinia.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/87_actinia.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/87_actinia.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/87_actinia.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Cloud-based geoprocessing with Actinia**"
diff --git a/docs/notebooks/88_nasa_earth_data.ipynb b/docs/notebooks/88_nasa_earth_data.ipynb
index b3bab018a1..6d081f32bf 100644
--- a/docs/notebooks/88_nasa_earth_data.ipynb
+++ b/docs/notebooks/88_nasa_earth_data.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/88_nasa_earth_data.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/88_nasa_earth_data.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/88_nasa_earth_data.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Searching and downloading NASA Earth science data products**\n",
diff --git a/docs/notebooks/89_image_array_viz.ipynb b/docs/notebooks/89_image_array_viz.ipynb
index 1307dbddb7..63c4e99685 100644
--- a/docs/notebooks/89_image_array_viz.ipynb
+++ b/docs/notebooks/89_image_array_viz.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/89_image_array_viz.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/89_image_array_viz.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/89_image_array_viz.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Visualizing in-memory raster datasets and image arrays**"
diff --git a/docs/notebooks/90_pixel_inspector.ipynb b/docs/notebooks/90_pixel_inspector.ipynb
index c8585fa235..9f9e5632bc 100644
--- a/docs/notebooks/90_pixel_inspector.ipynb
+++ b/docs/notebooks/90_pixel_inspector.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/90_pixel_inspector.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/90_pixel_inspector.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/90_pixel_inspector.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"## Interactive pixel inspector \n",
diff --git a/docs/notebooks/91_raster_viz_gui.ipynb b/docs/notebooks/91_raster_viz_gui.ipynb
index 16e6260d1a..fa973b545d 100644
--- a/docs/notebooks/91_raster_viz_gui.ipynb
+++ b/docs/notebooks/91_raster_viz_gui.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/91_raster_viz_gui.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/91_raster_viz_gui.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/91_raster_viz_gui.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Visualizing raster data interactively**\n",
diff --git a/docs/notebooks/92_maplibre.ipynb b/docs/notebooks/92_maplibre.ipynb
index fa8f5862ed..61218281fa 100644
--- a/docs/notebooks/92_maplibre.ipynb
+++ b/docs/notebooks/92_maplibre.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/92_maplibre.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/92_maplibre.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/92_maplibre.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Creating 3D maps with MapLibre**\n",
diff --git a/docs/notebooks/93_maplibre_pmtiles.ipynb b/docs/notebooks/93_maplibre_pmtiles.ipynb
index 2d6ea40d13..320e547f30 100644
--- a/docs/notebooks/93_maplibre_pmtiles.ipynb
+++ b/docs/notebooks/93_maplibre_pmtiles.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/93_maplibre_pmtiles.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/93_maplibre_pmtiles.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/93_maplibre_pmtiles.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"\n",
diff --git a/docs/notebooks/94_mapbox.ipynb b/docs/notebooks/94_mapbox.ipynb
index 5ee61cdae5..bfd2963fd6 100644
--- a/docs/notebooks/94_mapbox.ipynb
+++ b/docs/notebooks/94_mapbox.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/94_mapbox.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/94_mapbox.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/94_mapbox.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"**Creating 3D maps with Mapbox**"
diff --git a/docs/notebooks/95_edit_vector.ipynb b/docs/notebooks/95_edit_vector.ipynb
index 7071dff59e..98f8ba97b1 100644
--- a/docs/notebooks/95_edit_vector.ipynb
+++ b/docs/notebooks/95_edit_vector.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/95_edit_vector.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/95_edit_vector.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/95_edit_vector.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"# Edit Vector Data Interactively\n",
diff --git a/docs/notebooks/zz_notebook_template.ipynb b/docs/notebooks/zz_notebook_template.ipynb
index 5b4a4c601e..50320f620e 100644
--- a/docs/notebooks/zz_notebook_template.ipynb
+++ b/docs/notebooks/zz_notebook_template.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/zz_notebook_template.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/zz_notebook_template.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/zz_notebook_template.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
diff --git a/docs/workshops/EarthCube_2023.ipynb b/docs/workshops/EarthCube_2023.ipynb
index d39d50145a..9982548412 100644
--- a/docs/workshops/EarthCube_2023.ipynb
+++ b/docs/workshops/EarthCube_2023.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/EarthCube_2023.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/workshops/EarthCube_2023.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/workshops/EarthCube_2023.ipynb)\n",
"\n",
"**Interactive Geospatial Analysis and Data Visualization with Leafmap**\n",
"\n",
diff --git a/docs/workshops/FOSS4G_2021.ipynb b/docs/workshops/FOSS4G_2021.ipynb
index c89fc955fa..edfc4ca155 100644
--- a/docs/workshops/FOSS4G_2021.ipynb
+++ b/docs/workshops/FOSS4G_2021.ipynb
@@ -85,7 +85,7 @@
"Click the button below to open this notebook in Google Colab and execute code interactively.\n",
"\n",
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/FOSS4G_2021.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/workshops/foss4g_2021.ipynb)"
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/workshops/foss4g_2021.ipynb)"
]
},
{
diff --git a/docs/workshops/ICRW_2023.ipynb b/docs/workshops/ICRW_2023.ipynb
index 9ce4b8a630..2663d1d786 100644
--- a/docs/workshops/ICRW_2023.ipynb
+++ b/docs/workshops/ICRW_2023.ipynb
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/ICRW_2023.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/workshops/ICRW_2023.ipynb)\n",
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/workshops/ICRW_2023.ipynb)\n",
"\n",
"**An Introduction to Watershed Analysis with Leafmap and WhiteboxTools**\n",
"\n",
diff --git a/docs/workshops/SIGSPATIAL_2021.ipynb b/docs/workshops/SIGSPATIAL_2021.ipynb
index 7a3f4c3648..c92efad312 100644
--- a/docs/workshops/SIGSPATIAL_2021.ipynb
+++ b/docs/workshops/SIGSPATIAL_2021.ipynb
@@ -7,8 +7,6 @@
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/SIGSPATIAL_2021.ipynb)\n",
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://gishub.org/acm-colab)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/acm-binder)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/acm-binder-nb)\n",
"![](https://i.imgur.com/uKiXeCl.png)"
]
},
diff --git a/docs/workshops/YouthMappers_2021.ipynb b/docs/workshops/YouthMappers_2021.ipynb
index a2fabe5256..31af7e03e0 100644
--- a/docs/workshops/YouthMappers_2021.ipynb
+++ b/docs/workshops/YouthMappers_2021.ipynb
@@ -83,7 +83,7 @@
"Click the button below to open this notebook in Google Colab and execute code interactively.\n",
"\n",
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/YouthMappers_2021.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/workshops/YouthMappers_2021.ipynb)"
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/workshops/YouthMappers_2021.ipynb)"
]
},
{
diff --git a/examples/README.md b/examples/README.md
index 2d69547e7e..016983c067 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -112,6 +112,8 @@
91. Visualizing raster data interactively ([notebook](https://leafmap.org/notebooks/91_raster_viz_gui))
92. Creating 3D maps with the MapLibre mapping backend ([notebook](https://leafmap.org/notebooks/92_maplibre))
93. Visualizing PMTiles with Leafmap and MapLibre ([notebook](https://leafmap.org/notebooks/93_maplibre_pmtiles))
+94. Creating 3D maps with Mapbox ([notebook](https://leafmap.org/notebooks/94_mapbox))
+95. Editing vector data interactively ([notebook](https://leafmap.org/notebooks/95_edit_vector))
## Demo
diff --git a/examples/notebooks/00_key_features.ipynb b/examples/notebooks/00_key_features.ipynb
deleted file mode 100644
index 6a44a28f07..0000000000
--- a/examples/notebooks/00_key_features.ipynb
+++ /dev/null
@@ -1,542 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "# Key Features\n",
- "\n",
- "You can try out leafmap by using the cloud-computing platforms below without having to install anything on your computer:\n",
- "\n",
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/00_key_features.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "1",
- "metadata": {},
- "source": [
- "## Install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap geopandas pycrs osmnx"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "## Use ipyleaflet plotting backend"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "## Create an interactive map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(40, -100), zoom=4)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "## Customize map height"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(height=\"400px\", width=\"800px\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "## Set control visibility"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " draw_control=False,\n",
- " measure_control=False,\n",
- " fullscreen_control=False,\n",
- " attribution_control=True,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "## Change basemaps"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "## Add XYZ tile layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_tile_layer(\n",
- " url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\",\n",
- " name=\"Google Satellite\",\n",
- " attribution=\"Google\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "## Add WMS tile layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4)\n",
- "naip_url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?\"\n",
- "m.add_wms_layer(\n",
- " url=naip_url,\n",
- " layers=\"NLCD_2019_Land_Cover_L48\",\n",
- " name=\"NLCD 2019\",\n",
- " attribution=\"MRLC\",\n",
- " format=\"image/png\",\n",
- " shown=True,\n",
- ")\n",
- "m.add_legend(title=\"NLCD Land Cover Type\", builtin_legend=\"NLCD\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "## Add COG layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- "m.add_cog_layer(url, name=\"Fire (pre-event)\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "## Add STAC layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\"\n",
- "m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"False color\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "## Add legend"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2016_Land_Cover_L48/wms?\"\n",
- "m.add_wms_layer(\n",
- " url,\n",
- " layers=\"NLCD_2016_Land_Cover_L48\",\n",
- " name=\"NLCD 2016 CONUS Land Cover\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "m.add_legend(builtin_legend=\"NLCD\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "## Add colorbar"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"USGS 3DEP Elevation\")\n",
- "colors = [\"006633\", \"E5FFCC\", \"662A00\", \"D8D8D8\", \"F5F5F5\"]\n",
- "vmin = 0\n",
- "vmax = 4000\n",
- "m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "25",
- "metadata": {},
- "source": [
- "## Add GeoJSON"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "in_geojson = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cable_geo.geojson\"\n",
- "m.add_geojson(in_geojson, layer_name=\"Cable lines\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "27",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Add a GeoJSON with random filled color to the map.\n",
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "style = {\"fillOpacity\": 0.5}\n",
- "m.add_geojson(\n",
- " url,\n",
- " layer_name=\"Countries\",\n",
- " style=style,\n",
- " fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"],\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Use custom style and hover_style functions.\n",
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "style = {\n",
- " \"stroke\": True,\n",
- " \"color\": \"#0000ff\",\n",
- " \"weight\": 2,\n",
- " \"opacity\": 1,\n",
- " \"fill\": True,\n",
- " \"fillColor\": \"#0000ff\",\n",
- " \"fillOpacity\": 0.1,\n",
- "}\n",
- "hover_style = {\"fillOpacity\": 0.7}\n",
- "m.add_geojson(url, layer_name=\"Countries\", style=style, hover_style=hover_style)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "29",
- "metadata": {},
- "source": [
- "## Add shapefile"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "30",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "in_shp = \"https://github.com/opengeos/leafmap/raw/master/examples/data/countries.zip\"\n",
- "m.add_shp(in_shp, layer_name=\"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "31",
- "metadata": {},
- "source": [
- "## Add KML"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "32",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " import geopandas\n",
- "except ImportError:\n",
- " print(\"Installing geopandas ...\")\n",
- " subprocess.check_call([\"python\", \"-m\", \"pip\", \"install\", \"geopandas\"])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "33",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "in_kml = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_states.kml\"\n",
- "m.add_kml(in_kml, layer_name=\"US States KML\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "34",
- "metadata": {},
- "source": [
- "## Add GeoDataFrame"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "35",
- "metadata": {},
- "outputs": [],
- "source": [
- "import geopandas as gpd\n",
- "\n",
- "m = leafmap.Map()\n",
- "gdf = gpd.read_file(\n",
- " \"https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson\"\n",
- ")\n",
- "m.add_gdf(gdf, layer_name=\"Cable lines\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "36",
- "metadata": {},
- "source": [
- "## Create heat map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "37",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "in_csv = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.csv\"\n",
- "m.add_heatmap(\n",
- " in_csv,\n",
- " latitude=\"latitude\",\n",
- " longitude=\"longitude\",\n",
- " value=\"pop_max\",\n",
- " name=\"Heat map\",\n",
- " radius=20,\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "38",
- "metadata": {},
- "outputs": [],
- "source": [
- "colors = [\"blue\", \"lime\", \"red\"]\n",
- "vmin = 0\n",
- "vmax = 10000\n",
- "m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)\n",
- "m.add_title(\"World Population Heat Map\", font_size=\"20px\", align=\"center\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "39",
- "metadata": {},
- "source": [
- "## Save map to HTML"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "40",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"Esri.NatGeoWorldMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "41",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.to_html(\"mymap.html\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "42",
- "metadata": {},
- "source": [
- "## Add Planet imagery"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "43",
- "metadata": {},
- "outputs": [],
- "source": [
- "os.environ[\"PLANET_API_KEY\"] = \"your-api-key\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "44",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_planet_by_month(year=2020, month=8)\n",
- "m.add_planet_by_quarter(year=2019, quarter=2)\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/01_leafmap_intro.ipynb b/examples/notebooks/01_leafmap_intro.ipynb
deleted file mode 100644
index 2d56ffa743..0000000000
--- a/examples/notebooks/01_leafmap_intro.ipynb
+++ /dev/null
@@ -1,199 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/01_leafmap_intro.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/01_leafmap_intro.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Introducing the leafmap Python package for interactive mapping**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "`leafmap` has four plotting backends: [folium](https://github.com/python-visualization/folium), [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet), [here-map](https://github.com/heremaps/here-map-widget-for-jupyter), and [kepler.gl](https://docs.kepler.gl/docs/keplergl-jupyter). Note that the backends do not offer equal functionality. Some interactive functionality in `ipyleaflet` might not be available in other plotting backends. To use a specific plotting backend, use one of the following:\n",
- "\n",
- "- `import leafmap.leafmap as leafmap`\n",
- "- `import leafmap.foliumap as leafmap`\n",
- "- `import leafmap.heremap as leafmap`\n",
- "- `import leafmap.kepler as leafmap`"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Specify the default map center and zoom level."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[50, 19], zoom=4) # center=[lat, lon]\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Set the visibility of map controls."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " draw_control=False,\n",
- " measure_control=False,\n",
- " fullscreen_control=False,\n",
- " attribution_control=True,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Change the map width and height."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(height=\"450px\", width=\"800px\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Use the `ipyleaflet` plotting backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.leafmap as leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Use the `folium` plotting backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/02_using_basemaps.ipynb b/examples/notebooks/02_using_basemaps.ipynb
deleted file mode 100644
index decc205ab1..0000000000
--- a/examples/notebooks/02_using_basemaps.ipynb
+++ /dev/null
@@ -1,195 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/02_using_basemaps.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/02_using_basemaps.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Using basemaps in leafmap**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Specify a Google basemap to use, can be one of [\"ROADMAP\", \"TERRAIN\", \"SATELLITE\", \"HYBRID\"]."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(google_map=\"HYBRID\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(google_map=\"TERRAIN\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Add a basemap using the `add_basemap()` function."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"HYBRID\")\n",
- "m.add_basemap(\"Esri.NatGeoWorldMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Add an XYZ tile layer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_tile_layer(\n",
- " url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\",\n",
- " name=\"Google Satellite\",\n",
- " attribution=\"Google\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Add a WMS tile layer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "naip_url = \"https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url=naip_url, layers=\"0\", name=\"NAIP Imagery\", format=\"image/png\", shown=True\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Add a legend to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(google_map=\"HYBRID\")\n",
- "\n",
- "url1 = \"https://www.fws.gov/wetlands/arcgis/services/Wetlands/MapServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url1, layers=\"1\", format=\"image/png\", transparent=True, name=\"NWI Wetlands Vector\"\n",
- ")\n",
- "\n",
- "url2 = \"https://www.fws.gov/wetlands/arcgis/services/Wetlands_Raster/ImageServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url2, layers=\"0\", format=\"image/png\", transparent=True, name=\"NWI Wetlands Raster\"\n",
- ")\n",
- "\n",
- "m.add_legend(builtin_legend=\"NWI\")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/03_cog_stac.ipynb b/examples/notebooks/03_cog_stac.ipynb
deleted file mode 100644
index 4ff6de6840..0000000000
--- a/examples/notebooks/03_cog_stac.ipynb
+++ /dev/null
@@ -1,390 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/03_cog_stac.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/03_cog_stac.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Using Cloud Optimized GeoTIFF (COG) and SpatioTemporal Asset Catalog (STAC)**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "**Working with Cloud Optimized GeoTIFF (COG)**\n",
- "\n",
- "A Cloud Optimized GeoTIFF (COG) is a regular GeoTIFF file, aimed at being hosted on a HTTP file server, with an internal organization that enables more efficient workflows on the cloud. It does this by leveraging the ability of clients issuing HTTP GET range requests to ask for just the parts of a file they need. \n",
- "\n",
- "More information about COG can be found at \n",
- "\n",
- "Some publicly available Cloud Optimized GeoTIFFs:\n",
- "\n",
- "* https://stacindex.org/\n",
- "* https://cloud.google.com/storage/docs/public-datasets/landsat\n",
- "* https://www.digitalglobe.com/ecosystem/open-data\n",
- "* https://earthexplorer.usgs.gov/\n",
- "\n",
- "For this demo, we will use data from https://www.maxar.com/open-data/california-colorado-fires for mapping California and Colorado fires. A List of COGs can be found [here](https://github.com/opengeos/leafmap/blob/master/examples/data/cog_files.txt)."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/pE4mxwf.gif)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Use the TiTiler demo endpoint. Replace this if needed.\n",
- "os.environ[\"TITILER_ENDPOINT\"] = \"https://titiler.xyz\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map = leafmap.Map()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Retrieve the bounding box coordinates of the COG file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.cog_bounds(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Retrieve the centroid coordinates of the COG file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.cog_center(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Retrieve the band names of the COG file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.cog_bands(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Retrieves the tile layer URL of the COG file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.cog_tile(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "Add a COG layer to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map.add_cog_layer(url, name=\"Fire (pre-event)\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "url2 = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-09-13.tif\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map.add_cog_layer(url2, name=\"Fire (post-event)\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "22",
- "metadata": {},
- "source": [
- "**Working with SpatioTemporal Asset Catalog (STAC)**\n",
- "\n",
- "The SpatioTemporal Asset Catalog (STAC) specification provides a common language to describe a range of geospatial information, so it can more easily be indexed and discovered. A 'spatiotemporal asset' is any file that represents information about the earth captured in a certain space and time. The initial focus is primarily remotely-sensed imagery (from satellites, but also planes, drones, balloons, etc), but the core is designed to be extensible to SAR, full motion video, point clouds, hyperspectral, LiDAR and derived data like NDVI, Digital Elevation Models, mosaics, etc. More information about STAC can be found at https://stacspec.org/\n",
- "\n",
- "Some publicly available SpatioTemporal Asset Catalog (STAC):\n",
- "\n",
- "* https://stacindex.org\n",
- "\n",
- "For this demo, we will use STAC assets from https://stacindex.org/catalogs/spot-orthoimages-canada-2005#/?t=catalogs"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map = leafmap.Map()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "26",
- "metadata": {},
- "source": [
- "Retrieve the bounding box coordinates of the STAC file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "27",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_bounds(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "28",
- "metadata": {},
- "source": [
- "Retrieve the centroid coordinates of the STAC file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "29",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_center(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "30",
- "metadata": {},
- "source": [
- "Retrieve the band names of the STAC file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "31",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_bands(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "32",
- "metadata": {},
- "source": [
- "Retrieve the tile layer URL of the STAC file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "33",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_tile(url, bands=[\"B3\", \"B2\", \"B1\"])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "34",
- "metadata": {},
- "source": [
- "Add a STAC layer to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "35",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map.add_stac_layer(url, bands=[\"pan\"], name=\"Panchromatic\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "36",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"False color\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "37",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/04_cog_mosaic.ipynb b/examples/notebooks/04_cog_mosaic.ipynb
deleted file mode 100644
index d1d5344203..0000000000
--- a/examples/notebooks/04_cog_mosaic.ipynb
+++ /dev/null
@@ -1,210 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/04_cog_mosaic.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/04_cog_mosaic.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Creating a virtual mosaic of Cloud Optimized GeoTIFFs (COG)**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed.\n",
- "\n",
- "**Important Note:** This notebook no longer works. The `add_cog_mosaic()` has been removed from leafmap. See https://github.com/opengeos/leafmap/issues/180"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.update_package()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "For this demo, we will use data from https://www.maxar.com/open-data/california-colorado-fires for mapping California and Colorado fires. A List of COGs can be found at:\n",
- "\n",
- "- Pre-event: https://github.com/opengeos/leafmap/blob/master/examples/data/cog_pre_event.txt\n",
- "- Post-event: https://github.com/opengeos/leafmap/blob/master/examples/data/cog_post_event.txt"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "pre_fire_url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cog_pre_event.txt\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Create an XYZ tile layer based on a txt file containing a list of COG URLs."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.cog_mosaic_from_file(pre_fire_url)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "post_fire_url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cog_post_event.txt\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.cog_mosaic_from_file(post_fire_url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Add a COG mosaic tile layer to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.add_cog_mosaic_from_file(pre_fire_url, name=\"Pre-event\", show_footprints=True) #This line might take a while to run"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.add_cog_mosaic_from_file(post_fire_url, name=\"Post-event\", show_footprints=True) #This line might take a while to run"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "pre_event_tile = (\n",
- " \"https://titiler.xyz/mosaicjson/anonymous.layer_pqmra/tiles/{z}/{x}/{y}@1x?\"\n",
- ")\n",
- "m.add_tile_layer(pre_event_tile, name=\"Pre-event\", attribution=\"Maxar\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "post_event_tile = (\n",
- " \"https://titiler.xyz/mosaicjson/anonymous.layer_qdano/tiles/{z}/{x}/{y}@1x?\"\n",
- ")\n",
- "m.add_tile_layer(post_event_tile, name=\"Post-event\", attribution=\"Maxar\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.set_center(-122.0828, 37.0317, 11)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/05_load_raster.ipynb b/examples/notebooks/05_load_raster.ipynb
deleted file mode 100644
index 1a131afa89..0000000000
--- a/examples/notebooks/05_load_raster.ipynb
+++ /dev/null
@@ -1,177 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/05_load_raster.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/05_load_raster.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Loading local raster datasets with leafmap**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "To follow this tutorial, you need to install the [leafmap](https://leafmap.org) and [xarray_leaflet](https://github.com/davidbrochart/xarray_leaflet) Python packages. Use the following conda commands to create a conda env and install packages. Note that `xarray_leaflet` does not work properly on Windows ([source](https://github.com/davidbrochart/xarray_leaflet/issues/30)). Also, the `add_raster` function is only available for the ipyleaflet plotting backend. Therefore, Google Colab is not supported. Use the binder link above instead. \n",
- "\n",
- "- `conda create -n gee python`\n",
- "- `conda activate gee`\n",
- "- `conda install mamba -c conda-forge`\n",
- "- `mamba install leafmap xarray_leaflet -c conda-forge`"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Use the ipyleaflet plotting backend. The folium plotting backend does not support the `add_raster` function."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap.leafmap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Specify input raster datasets"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "landsat = \"landsat.tif\"\n",
- "dem = \"dem.tif\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Download samples raster datasets\n",
- "\n",
- "More datasets can be downloaded from https://viewer.nationalmap.gov/basic/"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "url1 = \"https://open.gishub.org/data/raster/landsat7.tif\"\n",
- "url2 = \"https://open.gishub.org/data/raster/srtm90.tif\"\n",
- "satellite = leafmap.download_file(url1, \"landsat.tif\")\n",
- "dem = leafmap.download_file(url2, \"dem.tif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Create an interactive map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Add local raster datasets to the map\n",
- "\n",
- "More colormap can be found at https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(dem, colormap=\"terrain\", layer_name=\"DEM\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(landsat, bands=[5, 4, 3], layer_name=\"Landsat\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Display the map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/06_legend.ipynb b/examples/notebooks/06_legend.ipynb
deleted file mode 100644
index 09dd6f7595..0000000000
--- a/examples/notebooks/06_legend.ipynb
+++ /dev/null
@@ -1,240 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/06_legend.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/06_legend.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Adding custom legends to the map**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "List available built-in legends."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "legends = leafmap.builtin_legends\n",
- "for legend in legends:\n",
- " print(legend)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "National Land Cover Database (NLCD)\n",
- "\n",
- "https://developers.google.com/earth-engine/datasets/catalog/USGS_NLCD"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map = leafmap.Map()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Add a WMS layer and built-in legend to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2016_Land_Cover_L48/wms?\"\n",
- "Map.add_wms_layer(\n",
- " url,\n",
- " layers=\"NLCD_2016_Land_Cover_L48\",\n",
- " name=\"NLCD 2016 CONUS Land Cover\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "Map.add_legend(builtin_legend=\"NLCD\")\n",
- "\n",
- "Map"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Add National Wetlands Inventory to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map = leafmap.Map(google_map=\"HYBRID\")\n",
- "\n",
- "url1 = \"https://www.fws.gov/wetlands/arcgis/services/Wetlands/MapServer/WMSServer?\"\n",
- "Map.add_wms_layer(\n",
- " url1, layers=\"1\", format=\"image/png\", transparent=True, name=\"NWI Wetlands Vector\"\n",
- ")\n",
- "\n",
- "url2 = \"https://www.fws.gov/wetlands/arcgis/services/Wetlands_Raster/ImageServer/WMSServer?\"\n",
- "Map.add_wms_layer(\n",
- " url2, layers=\"0\", format=\"image/png\", transparent=True, name=\"NWI Wetlands Raster\"\n",
- ")\n",
- "\n",
- "Map.add_legend(builtin_legend=\"NWI\")\n",
- "Map"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "**Add custom legends**\n",
- "\n",
- "There are two ways you can add custom legends:\n",
- "\n",
- "1. Define legend labels and colors\n",
- "2. Define legend dictionary\n",
- "\n",
- "Define legend keys and colors"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map = leafmap.Map()\n",
- "\n",
- "labels = [\"One\", \"Two\", \"Three\", \"Four\", \"etc\"]\n",
- "# color can be defined using either hex code or RGB (0-255, 0-255, 0-255)\n",
- "colors = [\"#8DD3C7\", \"#FFFFB3\", \"#BEBADA\", \"#FB8072\", \"#80B1D3\"]\n",
- "# colors = [(255, 0, 0), (127, 255, 0), (127, 18, 25), (36, 70, 180), (96, 68, 123)]\n",
- "\n",
- "Map.add_legend(title=\"Legend\", labels=labels, colors=colors)\n",
- "Map"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Define a legend dictionary."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map = leafmap.Map()\n",
- "\n",
- "url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2016_Land_Cover_L48/wms?\"\n",
- "Map.add_wms_layer(\n",
- " url,\n",
- " layers=\"NLCD_2016_Land_Cover_L48\",\n",
- " name=\"NLCD 2016 CONUS Land Cover\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "\n",
- "legend_dict = {\n",
- " \"11 Open Water\": \"466b9f\",\n",
- " \"12 Perennial Ice/Snow\": \"d1def8\",\n",
- " \"21 Developed, Open Space\": \"dec5c5\",\n",
- " \"22 Developed, Low Intensity\": \"d99282\",\n",
- " \"23 Developed, Medium Intensity\": \"eb0000\",\n",
- " \"24 Developed High Intensity\": \"ab0000\",\n",
- " \"31 Barren Land (Rock/Sand/Clay)\": \"b3ac9f\",\n",
- " \"41 Deciduous Forest\": \"68ab5f\",\n",
- " \"42 Evergreen Forest\": \"1c5f2c\",\n",
- " \"43 Mixed Forest\": \"b5c58f\",\n",
- " \"51 Dwarf Scrub\": \"af963c\",\n",
- " \"52 Shrub/Scrub\": \"ccb879\",\n",
- " \"71 Grassland/Herbaceous\": \"dfdfc2\",\n",
- " \"72 Sedge/Herbaceous\": \"d1d182\",\n",
- " \"73 Lichens\": \"a3cc51\",\n",
- " \"74 Moss\": \"82ba9e\",\n",
- " \"81 Pasture/Hay\": \"dcd939\",\n",
- " \"82 Cultivated Crops\": \"ab6c28\",\n",
- " \"90 Woody Wetlands\": \"b8d9eb\",\n",
- " \"95 Emergent Herbaceous Wetlands\": \"6c9fb8\",\n",
- "}\n",
- "\n",
- "Map.add_legend(title=\"NLCD Land Cover Classification\", legend_dict=legend_dict)\n",
- "Map"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/07_colorbar.ipynb b/examples/notebooks/07_colorbar.ipynb
deleted file mode 100644
index 234b3b06c3..0000000000
--- a/examples/notebooks/07_colorbar.ipynb
+++ /dev/null
@@ -1,158 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/07_colorbar.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/07_colorbar.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Adding custom colorbars to the map**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "**Continuous colorbar**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Add a WMS layer to the map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map = leafmap.Map()\n",
- "\n",
- "url = \"https://elevation.nationalmap.gov/arcgis/services/3DEPElevation/ImageServer/WMSServer?\"\n",
- "Map.add_wms_layer(\n",
- " url,\n",
- " layers=\"3DEPElevation:Hillshade Elevation Tinted\",\n",
- " name=\"USGS 3DEP Elevation\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Add a continuous colorbar with a custom palette to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "colors = [\"006633\", \"E5FFCC\", \"662A00\", \"D8D8D8\", \"F5F5F5\"]\n",
- "vmin = 0\n",
- "vmax = 4000\n",
- "\n",
- "Map.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)\n",
- "\n",
- "Map"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "**Categorical colorbar**\n",
- "\n",
- "Add a WMS layer to the map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map = leafmap.Map()\n",
- "\n",
- "url = \"https://elevation.nationalmap.gov/arcgis/services/3DEPElevation/ImageServer/WMSServer?\"\n",
- "Map.add_wms_layer(\n",
- " url,\n",
- " layers=\"3DEPElevation:Hillshade Elevation Tinted\",\n",
- " name=\"USGS 3DEP Elevation\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Add a categorical colorbar with a custom palette to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "colors = [\"006633\", \"E5FFCC\", \"662A00\", \"D8D8D8\", \"F5F5F5\"]\n",
- "vmin = 0\n",
- "vmax = 4000\n",
- "\n",
- "Map.add_colorbar(colors=colors, vmin=vmin, vmax=vmax, categorical=True, step=4)\n",
- "Map"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/08_whitebox.ipynb b/examples/notebooks/08_whitebox.ipynb
deleted file mode 100644
index a8f3bf3010..0000000000
--- a/examples/notebooks/08_whitebox.ipynb
+++ /dev/null
@@ -1,187 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/08_whitebox.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/08_whitebox.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Using WhiteboxTools with leafmap**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Download a sample DEM dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_dir = os.getcwd()\n",
- "dem = os.path.join(out_dir, \"dem.tif\")\n",
- "dem_url = (\n",
- " \"https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing\"\n",
- ")\n",
- "leafmap.download_file(dem_url, \"dem.tif\", unzip=False)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map = leafmap.Map()\n",
- "Map"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Use the built-in toolbox to perform geospatial analysis. For example, you can perform depression filling using the sample DEM dataset downloaded in the above step."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/KGHly63.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Display the toolbox using the default mode."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.whiteboxgui()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Display the toolbox using the collapsible tree mode. Note that the tree mode does not support Google Colab."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.whiteboxgui(tree=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Perform geospatial analysis using the [whitebox](https://github.com/opengeos/whitebox-python) package."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import pkg_resources"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt = leafmap.WhiteboxTools()\n",
- "wbt.verbose = False"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "# identify the sample data directory of the package\n",
- "data_dir = os.path.dirname(pkg_resources.resource_filename(\"whitebox\", \"testdata/\"))\n",
- "wbt.set_working_dir(data_dir)\n",
- "\n",
- "wbt.feature_preserving_smoothing(\"DEM.tif\", \"smoothed.tif\", filter=9)\n",
- "wbt.breach_depressions(\"smoothed.tif\", \"breached.tif\")"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/09_csv_to_points.ipynb b/examples/notebooks/09_csv_to_points.ipynb
deleted file mode 100644
index d335aa4a99..0000000000
--- a/examples/notebooks/09_csv_to_points.ipynb
+++ /dev/null
@@ -1,174 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/09_csv_to_points.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/09_csv_to_points.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Converting CSV to points**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "This notebook example requires the ipyleaflet plotting backend. Folium is not supported."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap.leafmap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Read a CSV as a Pandas DataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "in_csv = \"https://raw.githubusercontent.com/opengeos/data/main/world/world_cities.csv\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "df = leafmap.csv_to_df(in_csv)\n",
- "df"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Create a point layer from a CSV file containing lat/long information."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map = leafmap.Map()\n",
- "Map.add_xy_data(in_csv, x=\"longitude\", y=\"latitude\", layer_name=\"World Cities\")\n",
- "Map"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Set the output directory."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_dir = os.path.expanduser(\"~/Downloads\")\n",
- "if not os.path.exists(out_dir):\n",
- " os.makedirs(out_dir)\n",
- "out_shp = os.path.join(out_dir, \"world_cities.shp\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Convert a CSV file containing lat/long information to a shapefile."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.csv_to_shp(in_csv, out_shp)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_geojson = os.path.join(out_dir, \"world_cities.geojson\")\n",
- "leafmap.csv_to_geojson(in_csv, out_geojson)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Convert a CSV file containing lat/long information to a GeoPandas GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "# gdf = leafmap.csv_to_gdf(in_csv)\n",
- "# gdf"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/10_add_vector.ipynb b/examples/notebooks/10_add_vector.ipynb
deleted file mode 100644
index 0b72972227..0000000000
--- a/examples/notebooks/10_add_vector.ipynb
+++ /dev/null
@@ -1,319 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/10_add_vector.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/10_add_vector.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Adding local vector data (e.g., shp, geojson, kml) to the map**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "This demo is based on the ipyleaflet plotting backend. The folium plotting backend does not have the interactive GUI for loading local vector data."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/hnaTPZa.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Add a GeoJSON to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "\n",
- "in_geojson = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cable_geo.geojson\"\n",
- "m.add_geojson(in_geojson, layer_name=\"Cable lines\")\n",
- "\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Add a GeoJSON with random filled color to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "m.add_geojson(\n",
- " url, layer_name=\"Countries\", fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"]\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Use the `style_callback`function for assigning a random color to each polygon."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "import random\n",
- "\n",
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "\n",
- "\n",
- "def random_color(feature):\n",
- " return {\n",
- " \"color\": \"black\",\n",
- " \"fillColor\": random.choice([\"red\", \"yellow\", \"green\", \"orange\"]),\n",
- " }\n",
- "\n",
- "\n",
- "m.add_geojson(url, layer_name=\"Countries\", style_callback=random_color)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Use custom `style` and `hover_style` functions."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "\n",
- "style = {\n",
- " \"stroke\": True,\n",
- " \"color\": \"#0000ff\",\n",
- " \"weight\": 2,\n",
- " \"opacity\": 1,\n",
- " \"fill\": True,\n",
- " \"fillColor\": \"#0000ff\",\n",
- " \"fillOpacity\": 0.1,\n",
- "}\n",
- "\n",
- "hover_style = {\"fillOpacity\": 0.7}\n",
- "\n",
- "m.add_geojson(url, layer_name=\"Countries\", style=style, hover_style=hover_style)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Add a shapefile to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "\n",
- "in_shp = \"../data/countries.shp\"\n",
- "m.add_shp(in_shp, layer_name=\"Countries\")\n",
- "\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "Add a KML to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "in_kml = \"../data/us_states.kml\"\n",
- "m.add_kml(in_kml, layer_name=\"US States KML\")\n",
- "\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "The `add_vector` function supports any vector data format supported by GeoPandas."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "m.add_vector(\n",
- " url, layer_name=\"Countries\", fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"]\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "in_shp = \"../data/countries.shp\"\n",
- "in_geojson = \"../data/us_states.json\"\n",
- "in_kml = \"../data/us_states.kml\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_shp(in_shp, layer_name=\"Shapefile\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "23",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_geojson(in_geojson, layer_name=\"GeoJSON\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_kml(in_kml, layer_name=\"KML\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/11_linked_maps.ipynb b/examples/notebooks/11_linked_maps.ipynb
deleted file mode 100644
index 4f88ee0cfe..0000000000
--- a/examples/notebooks/11_linked_maps.ipynb
+++ /dev/null
@@ -1,155 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/11_linked_maps.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/11_linked_maps.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Creating linked maps for visualizing multiple maps simultaneously**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "This notebook example requires the ipyleaflet plotting backend. Folium is not supported."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.leafmap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Print out the list of available basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "print(leafmap.basemaps.keys())"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Specify the number of rows and columns to create a linked map. The `layers` parameter accepts a list of two XYZ tile layers, which can be chosen from the basemap names, or any custom XYZ tile layer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = [\"ROADMAP\", \"HYBRID\"]\n",
- "leafmap.linked_maps(rows=1, cols=2, height=\"400px\", layers=layers)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/9qwmgPR.jpg)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = [\"Esri.WorldTopoMap\", \"OpenTopoMap\"]\n",
- "leafmap.linked_maps(rows=1, cols=2, height=\"400px\", layers=layers)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/tx89sKu.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Create a 2 * 2 linked map to visualize land cover change. Specify the `center` and `zoom` parameters to change the default map center and zoom level."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = [str(f\"NLCD {year} CONUS Land Cover\") for year in [2001, 2006, 2011, 2016]]\n",
- "labels = [str(f\"NLCD {year}\") for year in [2001, 2006, 2011, 2016]]\n",
- "leafmap.linked_maps(\n",
- " rows=2,\n",
- " cols=2,\n",
- " height=\"300px\",\n",
- " layers=layers,\n",
- " labels=labels,\n",
- " center=[36.1, -115.2],\n",
- " zoom=9,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/VUp7H3m.png)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/12_split_map.ipynb b/examples/notebooks/12_split_map.ipynb
deleted file mode 100644
index 92be8b95ea..0000000000
--- a/examples/notebooks/12_split_map.ipynb
+++ /dev/null
@@ -1,145 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/12_split_map.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/12_split_map.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Creating a split-panel map with only one line of code**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "This notebook example requires the ipyleaflet plotting backend. Folium is not supported."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.leafmap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Print out the list of available basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "print(leafmap.basemaps.keys())"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Create a split-panel map by specifying the `left_layer` and `right_layer`, which can be chosen from the basemap names, or any custom XYZ tile layer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_map(left_layer=\"ROADMAP\", right_layer=\"HYBRID\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Hide the zoom control from the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_map(\n",
- " left_layer=\"Esri.WorldTopoMap\", right_layer=\"OpenTopoMap\", zoom_control=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Add labels to the map and change the default map center and zoom level."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_map(\n",
- " left_layer=\"NLCD 2001 CONUS Land Cover\",\n",
- " right_layer=\"NLCD 2016 CONUS Land Cover\",\n",
- " left_label=\"2001\",\n",
- " right_label=\"2016\",\n",
- " label_position=\"bottom\",\n",
- " center=[36.1, -114.9],\n",
- " zoom=10,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/ICuhdzW.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/13_geopandas.ipynb b/examples/notebooks/13_geopandas.ipynb
deleted file mode 100644
index 39a5a090c7..0000000000
--- a/examples/notebooks/13_geopandas.ipynb
+++ /dev/null
@@ -1,209 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/13_geopandas.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/13_geopandas.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Adding a GeoPandas GeoDataFrame to the map with a single line of code**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed. You can also use conda to create a new environment to install geopandas and leafmap.\n",
- "\n",
- "```\n",
- "conda create geo -n python=3.8\n",
- "conda activate geo\n",
- "conda install geopandas\n",
- "conda install mamba -c conda-forge\n",
- "mamba install leafmap -c conda-forge\n",
- "```"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install geopandas"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "import geopandas as gpd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.update_package()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Use GeoPandas to read a GeoJSON from an HTTP URL and return it as a GeoDataFrame.\n",
- "\n",
- "Sample data: https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = gpd.read_file(\n",
- " \"https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson\"\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Add a GeoDataFrame to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_gdf(gdf, layer_name=\"Cable lines\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "The following example requires the ipyleaflet plotting backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.leafmap as leafmap # for ipyleaflet only"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Read the GeoPandas sample dataset as a GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "path_to_data = (\n",
- " \"https://github.com/opengeos/datasets/releases/download/vector/nybb.geojson\"\n",
- ")\n",
- "gdf = gpd.read_file(path_to_data)\n",
- "gdf"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Convert the GeoDataFrame to GeoJSON. Users can then use `add_geojson()` to add the GeoJSON to the map. Alternatively, users can directly use the `add_gdf()` function to add a GeoDataFrame to the map. Note you when hovering the mouse over the layer, an information box is shown at the lower right corner of the map. This feature is only available for the ipyleaflet plotting backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "geojson = leafmap.gdf_to_geojson(gdf, epsg=\"4326\")\n",
- "# geojson"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "One can provide a list of colors (`fill_colors`) to randomly fill the polygons."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_gdf(gdf, layer_name=\"New York boroughs\", fill_colors=[\"red\", \"green\", \"blue\"])\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/lfAkjdt.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "name": "python",
- "version": "3.1.-1"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/14_postgis.ipynb b/examples/notebooks/14_postgis.ipynb
deleted file mode 100644
index 0a7f28c6a8..0000000000
--- a/examples/notebooks/14_postgis.ipynb
+++ /dev/null
@@ -1,162 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/14_postgis.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/14_postgis.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Adding data from a PostGIS database to the map**\n",
- "\n",
- "Setting up the conda env:\n",
- "\n",
- "```\n",
- "conda create -n geo python=3.8\n",
- "conda activate geo\n",
- "conda install geopandas\n",
- "conda install mamba -c conda-forge\n",
- "mamba install leafmap sqlalchemy psycopg2 -c conda-forge\n",
- "```\n",
- "\n",
- "Sample dataset:\n",
- "- [nyc_data.zip](https://github.com/giswqs/postgis/raw/master/data/nyc_data.zip) (Watch this [video](https://youtu.be/fROzLrjNDrs) to load data into PostGIS)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "**Connecting to the database**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "You can directly pass in the user name and password to access the database. Alternative, you can define environment variables. The default environment variables for user and password are `SQL_USER` and `SQL_PASSWORD`, respectively."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "The `try...except...` statements are only used for building the documentation website (https://leafmap.org) because the PostGIS database is not available on GitHub. If you are running the notebook with Jupyter installed locally and PostGIS set up properly, you don't need these `try...except...` statements."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " con = leafmap.connect_postgis(\n",
- " database=\"nyc\", host=\"localhost\", user=None, password=None, use_env_var=True\n",
- " )\n",
- "except:\n",
- " pass"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Create a GeoDataFrame from a sql query."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "sql = \"SELECT * FROM nyc_neighborhoods\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " gdf = leafmap.read_postgis(sql, con)\n",
- " display(gdf)\n",
- "except:\n",
- " pass"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Display the GeoDataFrame on the interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " m = leafmap.Map()\n",
- " m.add_gdf_from_postgis(\n",
- " sql, con, layer_name=\"NYC Neighborhoods\", fill_colors=[\"red\", \"green\", \"blue\"]\n",
- " )\n",
- " display(m)\n",
- "except:\n",
- " pass"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/mAXaBCv.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/15_openstreetmap.ipynb b/examples/notebooks/15_openstreetmap.ipynb
deleted file mode 100644
index 83e866a124..0000000000
--- a/examples/notebooks/15_openstreetmap.ipynb
+++ /dev/null
@@ -1,274 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/15_openstreetmap.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/15_openstreetmap.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Downloading OpenStreetMap data with a single line of code**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install geopandas osmnx"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Add OSM data of place(s) by name or ID to the map. Note that the leafmap custom layer control does not support GeoJSON, we need to use the ipyleaflet built-in layer control."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_geocode(\"New York City\", layer_name=\"NYC\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_geocode(\"Chicago, Illinois\", layer_name=\"Chicago, IL\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Show OSM feature tags.\n",
- "\n",
- "https://wiki.openstreetmap.org/wiki/Map_features"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.osm_tags_list()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Add OSM entities within some distance N, S, E, W of address to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_address(\n",
- " address=\"New York City\", tags={\"amenity\": \"bar\"}, dist=1500, layer_name=\"NYC bars\"\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_address(\n",
- " address=\"New York City\",\n",
- " tags={\"landuse\": [\"retail\", \"commercial\"], \"building\": True},\n",
- " dist=1000,\n",
- " layer_name=\"NYC buildings\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Add OSM entities within a N, S, E, W bounding box to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "north, south, east, west = 40.7551, 40.7454, -73.9738, -73.9965\n",
- "m.add_osm_from_bbox(\n",
- " north, south, east, west, tags={\"amenity\": \"bar\"}, layer_name=\"NYC bars\"\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Add OSM entities within some distance N, S, E, W of a point to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " center=[46.7808, -96.0156], zoom=12, toolbar_control=False, layers_control=True\n",
- ")\n",
- "m.add_osm_from_point(\n",
- " center_point=(46.7808, -96.0156),\n",
- " tags={\"natural\": \"water\"},\n",
- " dist=10000,\n",
- " layer_name=\"Lakes\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " center=[39.9170, 116.3908], zoom=15, toolbar_control=False, layers_control=True\n",
- ")\n",
- "m.add_osm_from_point(\n",
- " center_point=(39.9170, 116.3908),\n",
- " tags={\"building\": True, \"natural\": \"water\"},\n",
- " dist=1000,\n",
- " layer_name=\"Beijing\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "Add OSM entities within the current map view to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.set_center(-73.9854, 40.7500, 16)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "The `add_osm_from_view()` is only available for the ipyleaflet plotting backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.add_osm_from_view(tags={\"amenity\": \"bar\", \"building\": True}, layer_name=\"New York\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "Create a GeoPandas GeoDataFrame from place."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = leafmap.osm_gdf_from_place(\"New York City\", tags={\"amenity\": \"bar\"})\n",
- "gdf"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/16_heremap.ipynb b/examples/notebooks/16_heremap.ipynb
deleted file mode 100644
index 6e2c05b749..0000000000
--- a/examples/notebooks/16_heremap.ipynb
+++ /dev/null
@@ -1,468 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/16_heremap.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/16_heremap.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Using [HERE Map Widget for Jupyter](https://github.com/heremaps/here-map-widget-for-jupyter) as a plotting backend**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "## Prerequisites\n",
- "Before you run the below cells make sure you have:\n",
- "- A HERE developer account, free and available under [HERE Developer Portal](https://developer.here.com)\n",
- "- An [API key](https://developer.here.com/documentation/identity-access-management/dev_guide/topics/dev-apikey.html) from the [HERE Developer Portal](https://developer.here.com)\n",
- "- Export API key into environment variable `HEREMAPS_API_KEY`\n",
- "\n",
- " ```bash\n",
- " export HEREMAPS_API_KEY=YOUR-ACTUAL-API-KEY\n",
- " ```"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap.heremap as leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Read api_key from environment\n",
- "\n",
- "api_key = os.environ[\"HEREMAPS_API_KEY\"]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "## HERE default basemap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(api_key=api_key)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Specify the default map center and zoom level."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(api_key=api_key, center=[50, 19], zoom=4) # center=[lat, lon]\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Set the visibility of map controls."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(api_key=api_key, fullscreen_control=False)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Change the map width and height."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(api_key=api_key, height=\"450px\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "## Basemaps"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Use built-in basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(api_key=api_key, basemap=\"HERE_RASTER_TERRAIN_MAP\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "### zoom to bounds"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "Zoom to map to a bounding box [South, West, North, East]."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.zoom_to_bounds((-9.0882278, -55.3228175, 168.2249543, 72.2460938)) #"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_basemap(basemap=\"Esri.WorldTopoMap\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "Add a custom XYZ tile layer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(api_key=api_key, layers_control=True)\n",
- "m.add_tile_layer(\n",
- " url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\",\n",
- " name=\"Google Satellite\",\n",
- " attribution=\"Google\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "## Add vector data\n",
- "**How to add GeoJSON to the map**"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "24",
- "metadata": {},
- "source": [
- "Add a GeoJSON from an HTTP URL to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=2, layers_control=True)\n",
- "\n",
- "in_geojson = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cable_geo.geojson\"\n",
- "m.add_geojson(in_geojson, layer_name=\"Cable lines\")\n",
- "\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "26",
- "metadata": {},
- "source": [
- "Add a local GeoJSON file to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "27",
- "metadata": {},
- "outputs": [],
- "source": [
- "import json\n",
- "\n",
- "m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=2)\n",
- "with open(\"../data/countries.geojson\") as fh:\n",
- " geo = json.load(fh)\n",
- "m.add_geojson(geo, layer_name=\"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "28",
- "metadata": {},
- "source": [
- "Customize style for the GeoJSON layer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "29",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=2)\n",
- "\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "\n",
- "style = {\n",
- " \"fillColor\": \"rgba(0, 0, 255, 0.2)\",\n",
- " \"strokeColor\": \"blue\",\n",
- "}\n",
- "\n",
- "hover_style = {\"fillColor\": \"rgba(0, 0, 255, 0.7)\"}\n",
- "\n",
- "m.add_geojson(url, layer_name=\"Countries\", style=style, hover_style=hover_style)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "30",
- "metadata": {},
- "outputs": [],
- "source": [
- "in_shp = \"../data/countries.shp\"\n",
- "in_geojson = \"../data/us_states.json\"\n",
- "in_kml = \"../data/us_states.kml\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "31",
- "metadata": {},
- "source": [
- "Add a shapefile to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "32",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=2)\n",
- "m.add_shp(in_shp, layer_name=\"Shapefile\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "33",
- "metadata": {},
- "source": [
- "Add a KML file to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "34",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(api_key=api_key, center=[40.273502, -86.126976], zoom=4)\n",
- "m.add_kml(in_kml, layer_name=\"KML\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "35",
- "metadata": {},
- "source": [
- "The add_vector function supports any vector data format supported by GeoPandas."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "36",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "m.add_vector(url, layer_name=\"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "37",
- "metadata": {},
- "source": [
- "### Point style for GeoJSON"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "38",
- "metadata": {},
- "source": [
- "Customize the style of point layers."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "39",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=2)\n",
- "\n",
- "url = \"http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_month.geojson\"\n",
- "point_style = {\n",
- " \"strokeColor\": \"white\",\n",
- " \"lineWidth\": 1,\n",
- " \"fillColor\": \"red\",\n",
- " \"fillOpacity\": 0.7,\n",
- " \"radius\": 5,\n",
- "}\n",
- "m.add_geojson(url, layer_name=\"Countries\", point_style=point_style, default_popup=True)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "40",
- "metadata": {},
- "outputs": [],
- "source": [
- "import geopandas\n",
- "import json\n",
- "import os\n",
- "\n",
- "countries = geopandas.read_file(geopandas.datasets.get_path(\"naturalearth_cities\"))\n",
- "point_style = {\n",
- " \"strokeColor\": \"white\",\n",
- " \"lineWidth\": 1,\n",
- " \"fillColor\": \"blue\",\n",
- " \"fillOpacity\": 0.7,\n",
- " \"radius\": 5,\n",
- "}\n",
- "\n",
- "m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=3)\n",
- "m.add_gdf(countries, zoom_to_layer=False, point_style=point_style, default_popup=True)\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/17_vector_tile_layer.ipynb b/examples/notebooks/17_vector_tile_layer.ipynb
deleted file mode 100644
index f757db8bbc..0000000000
--- a/examples/notebooks/17_vector_tile_layer.ipynb
+++ /dev/null
@@ -1,269 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/17_vector_tile_layer.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/17_vector_tile_layer.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Adding a vector tile layer to the map**\n",
- "\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "This notebook example requires the ipyleaflet plotting backend. Folium is not supported."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(52.204793, 360.121558), zoom=9)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "The URL to the vector tile."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://tile.nextzen.org/tilezen/vector/v1/512/all/{z}/{x}/{y}.mvt?api_key=gCZXZglvRQa6sB2z7JzL1w\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Attribution of the vector tile."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "attribution = \"Nextzen\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "One can customize the vector tile layer style if needed. More info can be found at \n",
- "https://ipyleaflet.readthedocs.io/en/latest/layers/vector_tile.html \n",
- "\n",
- "Conditional styling ([example here](https://github.com/iwpnd/folium-vectorgrid)) currently works only with folium. Use:\n",
- "\n",
- "```python\n",
- "import leafmap.foliumap as leafmap \n",
- "```"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "water_style = dict(\n",
- " fill=\"true\",\n",
- " weight=1,\n",
- " fillColor=\"#06cccc\",\n",
- " color=\"#06cccc\",\n",
- " fillOpacity=0.2,\n",
- " opacity=0.4,\n",
- ")\n",
- "\n",
- "waterway_style = dict(\n",
- " weight=1, fillColor=\"#2375e0\", color=\"#2375e0\", fillOpacity=0.2, opacity=0.4\n",
- ")\n",
- "\n",
- "admin_style = dict(\n",
- " weight=1, fillColor=\"pink\", color=\"pink\", fillOpacity=0.2, opacity=0.4\n",
- ")\n",
- "\n",
- "landcover_style = dict(\n",
- " fill=\"true\",\n",
- " weight=1,\n",
- " fillColor=\"#53e033\",\n",
- " color=\"#53e033\",\n",
- " fillOpacity=0.2,\n",
- " opacity=0.4,\n",
- ")\n",
- "\n",
- "landuse_style = dict(\n",
- " fill=\"true\",\n",
- " weight=1,\n",
- " fillColor=\"#e5b404\",\n",
- " color=\"#e5b404\",\n",
- " fillOpacity=0.2,\n",
- " opacity=0.4,\n",
- ")\n",
- "\n",
- "park_style = dict(\n",
- " fill=\"true\",\n",
- " weight=1,\n",
- " fillColor=\"#84ea5b\",\n",
- " color=\"#84ea5b\",\n",
- " fillOpacity=0.2,\n",
- " opacity=0.4,\n",
- ")\n",
- "\n",
- "boundary_style = dict(\n",
- " weight=1, fillColor=\"#c545d3\", color=\"#c545d3\", fillOpacity=0.2, opacity=0.4\n",
- ")\n",
- "\n",
- "\n",
- "aeroway = dict(\n",
- " weight=1, fillColor=\"#51aeb5\", color=\"#51aeb5\", fillOpacity=0.2, opacity=0.4\n",
- ")\n",
- "\n",
- "road = dict(\n",
- " weight=1, fillColor=\"#f2b648\", color=\"#f2b648\", fillOpacity=0.2, opacity=0.4\n",
- ")\n",
- "\n",
- "transit = dict(\n",
- " weight=0.5, fillColor=\"#f2b648\", color=\"#f2b648\", fillOpacity=0.2, opacity=0.4\n",
- ")\n",
- "\n",
- "buildings = dict(\n",
- " fill=\"true\",\n",
- " weight=1,\n",
- " fillColor=\"#2b2b2b\",\n",
- " color=\"#2b2b2b\",\n",
- " fillOpacity=0.2,\n",
- " opacity=0.4,\n",
- ")\n",
- "\n",
- "water_name = dict(\n",
- " weight=1, fillColor=\"#022c5b\", color=\"#022c5b\", fillOpacity=0.2, opacity=0.4\n",
- ")\n",
- "\n",
- "transportation_name = dict(\n",
- " weight=1, fillColor=\"#bc6b38\", color=\"#bc6b38\", fillOpacity=0.2, opacity=0.4\n",
- ")\n",
- "\n",
- "place = dict(\n",
- " weight=1, fillColor=\"#f20e93\", color=\"#f20e93\", fillOpacity=0.2, opacity=0.4\n",
- ")\n",
- "\n",
- "housenumber = dict(\n",
- " weight=1, fillColor=\"#ef4c8b\", color=\"#ef4c8b\", fillOpacity=0.2, opacity=0.4\n",
- ")\n",
- "\n",
- "poi = dict(weight=1, fillColor=\"#3bb50a\", color=\"#3bb50a\", fillOpacity=0.2, opacity=0.4)\n",
- "\n",
- "earth = dict(\n",
- " fill=\"true\",\n",
- " weight=1,\n",
- " fillColor=\"#c0c0c0\",\n",
- " color=\"#c0c0c0\",\n",
- " fillOpacity=0.2,\n",
- " opacity=0.4,\n",
- ")\n",
- "\n",
- "vector_tile_layer_styles = dict(\n",
- " water=water_style,\n",
- " waterway=waterway_style,\n",
- " admin=admin_style,\n",
- " andcover=landcover_style,\n",
- " landuse=landuse_style,\n",
- " park=park_style,\n",
- " boundaries=boundary_style,\n",
- " aeroway=aeroway,\n",
- " roads=road,\n",
- " transit=transit,\n",
- " buildings=buildings,\n",
- " water_name=water_name,\n",
- " transportation_name=transportation_name,\n",
- " places=place,\n",
- " housenumber=housenumber,\n",
- " pois=poi,\n",
- " earth=earth,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Add the vector tile layer to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_vector_tile_layer(url, vector_tile_layer_styles, attribution=attribution)\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/18_point_layer.ipynb b/examples/notebooks/18_point_layer.ipynb
deleted file mode 100644
index dd865773ae..0000000000
--- a/examples/notebooks/18_point_layer.ipynb
+++ /dev/null
@@ -1,118 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/18_point_layer.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/18_point_layer.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Adding a point layer with popup attributes to the map**\n",
- "\n",
- "The notebook requires the ipyleaflet plotting backend. Folium is not supported. The point dataset can be any geopandas-supported file stored locally or online. \n",
- "\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Use the toolbar GUI to open a point-type vector dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Display a single popup attribute."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_point_layer(\"../data/us_cities.geojson\", popup=\"name\", layer_name=\"US Cities\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Display multiple popup attributes."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.geojson\"\n",
- "m.add_point_layer(url, popup=[\"name\", \"pop_max\"], layer_name=\"US Cities\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/1QVEtlN.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/19_map_to_html.ipynb b/examples/notebooks/19_map_to_html.ipynb
deleted file mode 100644
index 7eea911bbc..0000000000
--- a/examples/notebooks/19_map_to_html.ipynb
+++ /dev/null
@@ -1,113 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/19_map_to_html.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/19_map_to_html.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Saving maps as a html file**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"HYBRID\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Specify the output HTML file name to save the map as a web page."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.to_html(\"mymap.html\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "If the output HTML file name is not provided, the function will return a string containing contain the source code of the HTML file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "html = m.to_html()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "# print(html)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/20_planet_imagery.ipynb b/examples/notebooks/20_planet_imagery.ipynb
deleted file mode 100644
index 9393a4c20a..0000000000
--- a/examples/notebooks/20_planet_imagery.ipynb
+++ /dev/null
@@ -1,256 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/20_planet_imagery.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/20_planet_imagery.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Adding Planet global monthly and quarterly mosaic**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "First, you need to sign up a Planet account and get an API key. See https://developers.planet.com/quickstart/apis.\n",
- "Uncomment the following line to pass in your API key."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "# os.environ[\"PLANET_API_KEY\"] = \"12345\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Determine the tile format based on the plotting backend being use. It can be either ipyleaflet or folium."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "tile_format = \"ipyleaflet\"\n",
- "\n",
- "if os.environ.get(\"USE_MKDOCS\") is not None:\n",
- " tile_format = \"folium\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Generate Planet quarterly imagery URLs."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.planet_quarterly()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Generate Planet monthly imagery URLs."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.planet_monthly()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Generates Planet bi-annual and monthly imagery URLs."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.planet_catalog()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Generate Planet quarterly imagery TileLayer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "quarterly_tiles = leafmap.planet_quarterly_tiles(tile_format=tile_format)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Generate Planet monthly imagery TileLayer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "monthly_tiles = leafmap.planet_monthly_tiles(tile_format=tile_format)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "Print out the quarterly tile URLs."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "for tile in quarterly_tiles:\n",
- " print(tile)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "Print out the monthly tile URLs."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "for tile in monthly_tiles:\n",
- " print(tile)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "Add a Planet monthly mosaic by specifying year and month."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_planet_by_month(year=2020, month=8)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "Add a Planet quarterly mosaic by specifying year and quarter."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_planet_by_quarter(year=2019, quarter=2)\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/21_ts_inspector.ipynb b/examples/notebooks/21_ts_inspector.ipynb
deleted file mode 100644
index afa62281c5..0000000000
--- a/examples/notebooks/21_ts_inspector.ipynb
+++ /dev/null
@@ -1,220 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/21_ts_inspector.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/21_ts_inspector.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Using timeseries inspector with a single click**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "This notebook requires the ipyleaflet plotting backend. Folium is not supported."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.update_package()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "First, you need to sign up a Planet account and get an API key. See https://developers.planet.com/quickstart/apis.\n",
- "Uncomment the following line to pass in your API key."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "# os.environ[\"PLANET_API_KEY\"] = \"12345\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Create a list of Planet monthly mosaic tile layers."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "monthly_tiles = leafmap.planet_monthly_tiles()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Use the timeseries inspector to visualize images side by side with a split-panel map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.ts_inspector(monthly_tiles)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Create a list of Planet quarterly mosaic tile layers."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "quarterly_tiles = leafmap.planet_quarterly_tiles()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Use the timeseries inspector to visualize images side by side with a split-panel map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.ts_inspector(quarterly_tiles)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Create a list of Planet quarterly and monthly mosaic tile layers."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "tiles = leafmap.planet_tiles()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "Use the timeseries inspector to visualize images side by side with a split-panel map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.ts_inspector(tiles)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "Use the toolbar GUI to activate the timeseries inspector."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/cEilgvb.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/22_time_slider.ipynb b/examples/notebooks/22_time_slider.ipynb
deleted file mode 100644
index 384bfc624c..0000000000
--- a/examples/notebooks/22_time_slider.ipynb
+++ /dev/null
@@ -1,208 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/22_time_slider.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/22_time_slider.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Using time slider for visualizing timeseries images**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "This notebook requires the ipyleaflet plotting backend. Folium is not supported."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "First, you need to sign up a Planet account and get an API key. See https://developers.planet.com/quickstart/apis.\n",
- "Uncomment the following line to pass in your API key."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "# os.environ[\"PLANET_API_KEY\"] = \"12345\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/ipVJ4cb.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Specify the map center and zoom level."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[38.2659, -103.2447], zoom=13)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Use the time slider to visualize Planet quarterly mosaic."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "layers_dict = leafmap.planet_quarterly_tiles()\n",
- "m.add_time_slider(layers_dict, time_interval=1)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Use the time slider to visualize basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.clear_layers()\n",
- "layers_dict = leafmap.basemap_xyz_tiles()\n",
- "m.add_time_slider(layers_dict, time_interval=1)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Use the time slider to visualize COG assets found within STAC items."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "import ipyleaflet\n",
- "import json\n",
- "import requests\n",
- "\n",
- "stac_api = \"https://earth-search.aws.element84.com/v0\"\n",
- "search_endpoint = f\"{stac_api}/search\"\n",
- "\n",
- "collection = \"sentinel-s2-l2a-cogs\"\n",
- "payload = {\n",
- " \"bbox\": [\n",
- " -102.83340454101562,\n",
- " 49.77860375256143,\n",
- " -102.41043090820312,\n",
- " 50.05273014900257,\n",
- " ],\n",
- " \"datetime\": \"2021-07-01T00:00:00Z/2021-10-01T12:31:12Z\",\n",
- " \"collections\": [collection],\n",
- " \"limit\": 10,\n",
- " \"query\": {\"eo:cloud_cover\": {\"gte\": 0, \"lte\": 10}},\n",
- "}\n",
- "\n",
- "headers = {\"Content-Type\": \"application/json\"}\n",
- "\n",
- "response = requests.request(\n",
- " \"POST\", search_endpoint, headers=headers, data=json.dumps(payload)\n",
- ")\n",
- "\n",
- "features = response.json()[\"features\"]\n",
- "features.sort(key=lambda x: x[\"properties\"][\"datetime\"], reverse=False)\n",
- "\n",
- "layers_dict = {}\n",
- "for feature in features:\n",
- " feature_id = feature[\"id\"]\n",
- " print(feature_id)\n",
- "\n",
- " url = leafmap.stac_tile(\n",
- " f\"{stac_api}/collections/{collection}/items/{feature_id}\", bands=[\"visual\"]\n",
- " )\n",
- " tile_layer = ipyleaflet.TileLayer(\n",
- " url=url,\n",
- " name=feature_id,\n",
- " )\n",
- " layers_dict[feature_id] = tile_layer\n",
- "\n",
- "m = leafmap.Map(center=[50.093079, -103.152825], zoom=11)\n",
- "m.add_time_slider(layers_dict, time_interval=2)\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/23_colormaps.ipynb b/examples/notebooks/23_colormaps.ipynb
deleted file mode 100644
index 02b16069a0..0000000000
--- a/examples/notebooks/23_colormaps.ipynb
+++ /dev/null
@@ -1,338 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/23_colormaps.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/23_colormaps.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Creating colormaps with a single line of code**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "This notebook requires the ipyleaflet plotting backend. Folium is not supported."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap\n",
- "import leafmap.colormaps as cm"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Color palette for DEM data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.palettes.dem"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Show the DEM palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=cm.palettes.dem, axis_off=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Color palette for NDVI data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.palettes.ndvi"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Show the NDVI palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=cm.palettes.ndvi)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Specify the number of classes for a palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.get_palette(\"terrain\", n_class=8)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Show the terrain palette with 8 classes."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=cm.get_palette(\"terrain\", n_class=8))"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "Create a palette with custom colors, label, and font size."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=[\"red\", \"green\", \"blue\"], label=\"Temperature\", font_size=12)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "Create a discrete color palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(\n",
- " colors=[\"red\", \"green\", \"blue\"], discrete=True, label=\"Temperature\", font_size=12\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "20",
- "metadata": {},
- "source": [
- "Specify the width and height for the palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=8.0,\n",
- " height=0.4,\n",
- " orientation=\"horizontal\",\n",
- " vmin=0,\n",
- " vmax=1000,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "22",
- "metadata": {},
- "source": [
- "Change the orentation of the colormap to be vertical."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "23",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=0.4,\n",
- " height=4,\n",
- " orientation=\"vertical\",\n",
- " vmin=0,\n",
- " vmax=1000,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "24",
- "metadata": {},
- "source": [
- "Add a horizontal colorbar to an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=8.0,\n",
- " height=0.4,\n",
- " orientation=\"horizontal\",\n",
- " vmin=0,\n",
- " vmax=4000,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "26",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/tuB728Y.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27",
- "metadata": {},
- "source": [
- "Add a vertical colorbar to an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=0.4,\n",
- " height=4,\n",
- " orientation=\"vertical\",\n",
- " vmin=0,\n",
- " vmax=4000,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "29",
- "metadata": {},
- "source": [
- "Show all available colormaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "30",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormaps(width=12, height=0.4)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/24_heatmap.ipynb b/examples/notebooks/24_heatmap.ipynb
deleted file mode 100644
index 064e0a91d0..0000000000
--- a/examples/notebooks/24_heatmap.ipynb
+++ /dev/null
@@ -1,145 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/24_heatmap.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/24_heatmap.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Creating heat maps from csv**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "Specify the file path to the CSV. It can either be a file locally or on the Internet."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "filepath = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.csv\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Use the ipyleaflet plotting backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.leafmap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Specify the `latitude`, `longitude`, and `value` columns to create the heat map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_heatmap(\n",
- " filepath,\n",
- " latitude=\"latitude\",\n",
- " longitude=\"longitude\",\n",
- " value=\"pop_max\",\n",
- " name=\"Heat map\",\n",
- " radius=20,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Use the folium plotting backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Specify the `latitude`, `longitude`, and `value` columns to create the heat map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_heatmap(\n",
- " filepath,\n",
- " latitude=\"latitude\",\n",
- " longitude=\"longitude\",\n",
- " value=\"pop_max\",\n",
- " name=\"Heat map\",\n",
- " radius=20,\n",
- ")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/25_map_title.ipynb b/examples/notebooks/25_map_title.ipynb
deleted file mode 100644
index aa7616335a..0000000000
--- a/examples/notebooks/25_map_title.ipynb
+++ /dev/null
@@ -1,184 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/25_map_title.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/25_map_title.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Creating a population heat map with a colorbar and map title**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "The notebook requires the folium plotting backend. ipyleaflet is not supported."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Creates an interactive folium map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Specify the `latitude`, `longitude`, and `value` columns to create the heat map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "in_csv = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.csv\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Specify the file path to the CSV. It can either be a file locally or on the Internet."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_heatmap(\n",
- " in_csv,\n",
- " latitude=\"latitude\",\n",
- " longitude=\"longitude\",\n",
- " value=\"pop_max\",\n",
- " name=\"Heat map\",\n",
- " radius=20,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Adds a colorbar to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "colors = [\"blue\", \"lime\", \"red\"]\n",
- "vmin = 0\n",
- "vmax = 10000\n",
- "\n",
- "m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Adds a title to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_title(\"World Population Heat Map\", font_size=\"20px\", align=\"center\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Save the map as an HTML."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.to_html(\"heatmap.html\")"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/26_kepler_gl.ipynb b/examples/notebooks/26_kepler_gl.ipynb
deleted file mode 100644
index 8232ed0ea9..0000000000
--- a/examples/notebooks/26_kepler_gl.ipynb
+++ /dev/null
@@ -1,313 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/26_kepler_gl.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/26_kepler_gl.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.kepler as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create an interactive map. You can specify various parameters to initialize the map, such as `center`, `zoom`, `height`, and `widescreen`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=2, height=600, widescreen=False)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Save the map to an interactive html. To hide the side panel and disable map customization. Set `read_only=False`"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.to_html(outfile=\"../html/kepler.html\", read_only=False)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Display the interactive map in a notebook cell."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.static_map(width=950, height=600, read_only=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Add a CSV to the map. If you have a map config file, you can directly apply config to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[37.7621, -122.4143], zoom=12)\n",
- "in_csv = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/hex_data.csv\"\n",
- "config = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/hex_config.json\"\n",
- "m.add_csv(in_csv, layer_name=\"hex_data\", config=config)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Save the map configuration as a JSON file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.save_config(\"cache/config.json\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Save the map to an interactive html."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.to_html(outfile=\"../html/kepler_hex.html\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Add a GeoJSON to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[20, 0], zoom=1)\n",
- "lines = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cable_geo.geojson\"\n",
- "m.add_geojson(lines, layer_name=\"Cable lines\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.to_html(\"../html/kepler_lines.html\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "Add a GeoJSON with US state boundaries to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[50, -110], zoom=2)\n",
- "polygons = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_states.json\"\n",
- "m.add_geojson(polygons, layer_name=\"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.to_html(\"../html/kepler_states.html\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "Add a shapefile to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[20, 0], zoom=1)\n",
- "in_shp = \"https://github.com/opengeos/leafmap/raw/master/examples/data/countries.zip\"\n",
- "m.add_shp(in_shp, \"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "23",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.to_html(\"../html/kepler_countries.html\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "24",
- "metadata": {},
- "source": [
- "Add a GeoPandas GeoDataFrame to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "import geopandas as gpd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = gpd.read_file(\n",
- " \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.geojson\"\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "27",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[20, 0], zoom=1)\n",
- "m.add_gdf(gdf, \"World cities\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "29",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.to_html(\"../html/kepler_cities.html\")"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/27_basemap_gallery.ipynb b/examples/notebooks/27_basemap_gallery.ipynb
deleted file mode 100644
index 08d9bc2403..0000000000
--- a/examples/notebooks/27_basemap_gallery.ipynb
+++ /dev/null
@@ -1,100 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/27_basemap_gallery.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/27_basemap_gallery.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.leafmap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Select 100 basemaps"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = list(leafmap.basemaps.keys())[17:117]\n",
- "# layers"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Print out the labels"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "print(layers[:10])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Create linked maps of 100 basemaps"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.linked_maps(rows=20, cols=5, height=\"200px\", layers=layers, labels=layers)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/28_publish_map.ipynb b/examples/notebooks/28_publish_map.ipynb
deleted file mode 100644
index 1bfbae36e4..0000000000
--- a/examples/notebooks/28_publish_map.ipynb
+++ /dev/null
@@ -1,197 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/28_publish_map.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/28_publish_map.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "To follow this tutorial, you will need to [sign up](https://datapane.com/accounts/signup/) for an account with , then install and authenticate the `datapane` Python package. More information can be found [here](https://docs.datapane.com/tutorials/tut-getting-started). \n",
- "\n",
- "- `pip install datapane`\n",
- "- `datapane login`\n",
- "- `datapane ping`"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Create an elevation map of North America."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"USGS 3DEP Elevation\")\n",
- "colors = [\"006633\", \"E5FFCC\", \"662A00\", \"D8D8D8\", \"F5F5F5\"]\n",
- "vmin = 0\n",
- "vmax = 4000\n",
- "m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Publish the map to [datapane.com](https://datapane.com)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.publish(name=\"Elevation Map of North America\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Create a land use and land cover map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"NLCD 2016 CONUS Land Cover\")\n",
- "m.add_legend(builtin_legend=\"NLCD\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Publish the map to [datapane.com](https://datapane.com)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.publish(name=\"National Land Cover Database (NLCD) 2016\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Create a world population heat map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "in_csv = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.csv\"\n",
- "m.add_heatmap(\n",
- " in_csv,\n",
- " latitude=\"latitude\",\n",
- " longitude=\"longitude\",\n",
- " value=\"pop_max\",\n",
- " name=\"Heat map\",\n",
- " radius=20,\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "colors = [\"blue\", \"lime\", \"red\"]\n",
- "vmin = 0\n",
- "vmax = 10000\n",
- "m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Publish the map to [datapane.com](https://datapane.com)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.publish(name=\"World Population Heat Map\")"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/29_pydeck.ipynb b/examples/notebooks/29_pydeck.ipynb
deleted file mode 100644
index 03f32f5689..0000000000
--- a/examples/notebooks/29_pydeck.ipynb
+++ /dev/null
@@ -1,249 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/29_pydeck.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/29_pydeck.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.deck as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(40, -100), zoom=3)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Add basemap."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Add vector data to the map. It supports any GeoPandas supported format, such as GeoJSON, shapefile, KML."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "filename = (\n",
- " \"https://github.com/giswqs/streamlit-geospatial/raw/master/data/us_states.geojson\"\n",
- ")\n",
- "m.add_vector(filename, random_color_column=\"STATEFP\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Add a GeoPandas GeoDataFrame to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "import geopandas as gpd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = (\n",
- " \"https://github.com/giswqs/streamlit-geospatial/raw/master/data/us_counties.geojson\"\n",
- ")\n",
- "gdf = gpd.read_file(url)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_gdf(gdf, random_color_column=\"STATEFP\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Create a 3D view of the map. **Press Ctrl and hold down the left mouse button to rotate the 3D view.**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "initial_view_state = {\n",
- " \"latitude\": 40,\n",
- " \"longitude\": -100,\n",
- " \"zoom\": 3,\n",
- " \"pitch\": 45,\n",
- " \"bearing\": 10,\n",
- "}\n",
- "m = leafmap.Map(initial_view_state=initial_view_state)\n",
- "filename = (\n",
- " \"https://github.com/giswqs/streamlit-geospatial/raw/master/data/us_states.geojson\"\n",
- ")\n",
- "m.add_vector(\n",
- " filename,\n",
- " random_color_column=\"STATEFP\",\n",
- " extruded=True,\n",
- " get_elevation=\"ALAND\",\n",
- " elevation_scale=0.000001,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/LbCKhcM.gif)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(40, -100), zoom=3)\n",
- "DATA_URL = \"https://data.source.coop/cboettig/conservation-policy/Inflation_Reduction_Act_Projects.geojson\"\n",
- "gdf = gpd.read_file(DATA_URL)\n",
- "\n",
- "m.add_vector(\n",
- " gdf,\n",
- " layer_type=\"ColumnLayer\",\n",
- " get_position=[\"LONGITUDE\", \"LATITUDE\"],\n",
- " get_elevation=\"FUNDING_NUMERIC\",\n",
- " get_fill_color=[256, 256, 0, 140],\n",
- " elevation_scale=0.01,\n",
- " radius=10000,\n",
- " pickable=True,\n",
- " auto_highlight=True,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "import pydeck as pdk\n",
- "\n",
- "m = leafmap.Map(center=(40, -100), zoom=3)\n",
- "\n",
- "DATA_URL = \"https://data.source.coop/cboettig/conservation-policy/Inflation_Reduction_Act_Projects.geojson\"\n",
- "df = gpd.read_file(DATA_URL)\n",
- "\n",
- "column_layer = pdk.Layer(\n",
- " \"ColumnLayer\",\n",
- " data=df,\n",
- " get_position=[\"LONGITUDE\", \"LATITUDE\"],\n",
- " get_elevation=\"FUNDING_NUMERIC\",\n",
- " get_fill_color=[256, 256, 0, 140],\n",
- " elevation_scale=0.01,\n",
- " radius=10000,\n",
- " pickable=True,\n",
- " auto_highlight=True,\n",
- ")\n",
- "\n",
- "m.add_layer(column_layer)\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/30_census_data.ipynb b/examples/notebooks/30_census_data.ipynb
deleted file mode 100644
index 879528c17c..0000000000
--- a/examples/notebooks/30_census_data.ipynb
+++ /dev/null
@@ -1,131 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/30_census_data.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/30_census_data.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Get the Census data WMS tiles as a dictionary. More info can be found at https://tigerweb.geo.census.gov/tigerwebmain/TIGERweb_wms.html"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "census_data_dict = leafmap.get_census_dict()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Print out the list of US Census WMS."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "for key in census_data_dict:\n",
- " print(key)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Get the list of layers for a WMS."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "census_data_dict[\"Census 2020\"][\"layers\"]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Create an interactive map and add Census data layer to it. You might need to zoom in to see the data layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_census_data(wms=\"Census 2020\", layer=\"States\")\n",
- "m.add_census_data(wms=\"Census 2020\", layer=\"States_Labels49388\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Alternatively, you can use the toolbar to load Census data interactively without coding.\n",
- "\n",
- "![](https://i.imgur.com/nww2R1l.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/31_search_basemaps.ipynb b/examples/notebooks/31_search_basemaps.ipynb
deleted file mode 100644
index 89e64a44b3..0000000000
--- a/examples/notebooks/31_search_basemaps.ipynb
+++ /dev/null
@@ -1,137 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/31_search_basemaps.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/31_search_basemaps.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Search xyz tiles from [xyzservices](https://github.com/geopandas/xyzservices)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.search_xyz_services(keyword=\"esri\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Add an xyz tile to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_xyz_service(\"xyz.Esri.NatGeoWorldMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Search xyz tiles from [Quick Map Services](https://github.com/nextgis/quickmapservices)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.search_qms(keyword=\"google\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Add xyz tile to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_xyz_service(\"qms.Google Satellite Hybrid\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Search basemaps interactively without coding."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/WSxnAKY.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/32_local_tile.ipynb b/examples/notebooks/32_local_tile.ipynb
deleted file mode 100644
index 6ef3007ccb..0000000000
--- a/examples/notebooks/32_local_tile.ipynb
+++ /dev/null
@@ -1,220 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/32_local_tile.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/32_local_tile.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Using local raster datasets or remote Cloud Optimized GeoTIFFs (COG) with leafmap**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) and [localtileserver](https://github.com/banesullivan/localtileserver) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install localtileserver"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Specify input raster datasets"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "dem = \"dem.tif\"\n",
- "landsat = \"landsat.tif\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Download samples raster datasets."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "dem_url = (\n",
- " \"https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing\"\n",
- ")\n",
- "leafmap.download_file(dem_url, dem, unzip=False)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "landsat_url = \"https://github.com/opengeos/leafmap/raw/master/examples/data/cog.tif\"\n",
- "leafmap.download_file(landsat_url, landsat, unzip=False)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Add local raster datasets to the map. The available palettes can be found at https://jiffyclub.github.io/palettable/"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(landsat, indexes=[4, 3, 2], layer_name=\"Landsat\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(dem, colormap=\"viridis\", layer_name=\"DEM\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Add a remote Cloud Optimized GeoTIFF(COG) to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_cog_layer(url, name=\"Maxar\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "20",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/dy6LSq5.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/33_image_overlay.ipynb b/examples/notebooks/33_image_overlay.ipynb
deleted file mode 100644
index cecf81b517..0000000000
--- a/examples/notebooks/33_image_overlay.ipynb
+++ /dev/null
@@ -1,125 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/33_image_overlay.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/33_image_overlay.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "**Using local files**\n",
- "\n",
- "Download the sample png from https://i.imgur.com/06Q1fSz.png to your `Downloads` folder."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "filepath = \"weather.png\"\n",
- "url = \"https://open.gishub.org/data/images/weather.png\"\n",
- "if not os.path.exists(filepath):\n",
- " leafmap.download_file(url, filepath)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(25, -115), zoom=4)\n",
- "\n",
- "image = leafmap.ImageOverlay(url=filepath, bounds=((13, -130), (32, -100)))\n",
- "\n",
- "m.add_layer(image)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "**Using remote files**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(25, -115), zoom=4)\n",
- "\n",
- "image = leafmap.ImageOverlay(url=url, bounds=((13, -130), (32, -100)))\n",
- "\n",
- "m.add_layer(image)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Update image url"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "# image.url = \"https://i.imgur.com/J9qCf4E.png\""
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/34_add_points_from_xy.ipynb b/examples/notebooks/34_add_points_from_xy.ipynb
deleted file mode 100644
index a0ae025ee8..0000000000
--- a/examples/notebooks/34_add_points_from_xy.ipynb
+++ /dev/null
@@ -1,106 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/34_add_points_from_xy.ipynb)\n",
- "\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "import pandas as pd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.update_package()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Using a CSV file containing xy coordinates"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "data = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.csv\"\n",
- "m.add_points_from_xy(data, x=\"longitude\", y=\"latitude\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Using a Pandas DataFrame containing xy coordinates."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "data = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.csv\"\n",
- "df = pd.read_csv(data)\n",
- "m.add_points_from_xy(df, x=\"longitude\", y=\"latitude\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/35_circle_markers.ipynb b/examples/notebooks/35_circle_markers.ipynb
deleted file mode 100644
index 30de546190..0000000000
--- a/examples/notebooks/35_circle_markers.ipynb
+++ /dev/null
@@ -1,68 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/35_circle_markers.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/35_circle_markers.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "For a list of options for circle markers, see https://ipyleaflet.readthedocs.io/en/latest/api_reference/circle_marker.html"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4)\n",
- "data = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.csv\"\n",
- "m.add_circle_markers_from_xy(\n",
- " data, x=\"longitude\", y=\"latitude\", radius=10, color=\"blue\", fill_color=\"black\"\n",
- ")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/36_add_labels.ipynb b/examples/notebooks/36_add_labels.ipynb
deleted file mode 100644
index 5cfb7ff8f9..0000000000
--- a/examples/notebooks/36_add_labels.ipynb
+++ /dev/null
@@ -1,142 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/36_add_labels.ipynb)\n",
- "\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Update the package if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.update_package()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "data = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_states.json\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map = leafmap.Map(center=[40, -100], zoom=4, add_google_map=False, layers_control=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Labeling data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map.add_labels(\n",
- " data,\n",
- " \"id\",\n",
- " font_size=\"12pt\",\n",
- " font_color=\"blue\",\n",
- " font_family=\"arial\",\n",
- " font_weight=\"bold\",\n",
- ")\n",
- "Map"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Remove labels"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "Map.remove_labels()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/lELtitr.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/37_planetary_computer.ipynb b/examples/notebooks/37_planetary_computer.ipynb
deleted file mode 100644
index db725a6b56..0000000000
--- a/examples/notebooks/37_planetary_computer.ipynb
+++ /dev/null
@@ -1,313 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/37_planetary_computer.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/37_planetary_computer.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Add a STAC item via an HTTP URL"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_assets(url)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_bounds(url)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_center(url)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.stac_info(url)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.stac_stats(url)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"])\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Add a Microsoft Planetry Computer STAC item. The titiler endpoint can set in one of the ways below:\n",
- "\n",
- "```\n",
- "os.environ[\"TITILER_ENDPOINT\"] = \"planetary-computer\"\n",
- "titiler_endpoint=\"pc\"\n",
- "titiler_endpoint=\"planetary-computer\"\n",
- "```"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "# import os\n",
- "# os.environ[\"TITILER_ENDPOINT\"] = \"planetary-computer\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "collection = \"landsat-8-c2-l2\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "item = \"LC08_L2SP_047027_20201204_02_T1\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_assets(collection=collection, item=item, titiler_endpoint=\"pc\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_bounds(collection=collection, item=item)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_info(collection=collection, item=item, assets=\"SR_B7\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_stats(collection=collection, item=item, assets=\"SR_B7\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "Color infrared composite."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_stac_layer(\n",
- " collection=collection,\n",
- " item=item,\n",
- " assets=[\"SR_B5\", \"SR_B4\", \"SR_B3\"],\n",
- " name=\"Color infrared\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "False color composite."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_stac_layer(\n",
- " collection=collection, item=item, assets=\"SR_B7,SR_B5,SR_B4\", name=\"False color\"\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "Calculate NDVI."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_stac_layer(\n",
- " collection=collection,\n",
- " item=item,\n",
- " expression=\"(SR_B5-SR_B4)/(SR_B5+SR_B4)\",\n",
- " rescale=\"-1,1\",\n",
- " name=\"NDVI\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "25",
- "metadata": {},
- "source": [
- "Calculate NDVI and add a colormap. See available colormaps at https://planetarycomputer.microsoft.com/docs/reference/data/"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_stac_layer(\n",
- " collection=collection, item=item, assets=\"SR_B5,SR_B4,SR_B3\", name=\"Color infrared\"\n",
- ")\n",
- "m.add_stac_layer(\n",
- " collection=collection,\n",
- " item=item,\n",
- " expression=\"(SR_B5-SR_B4)/(SR_B5+SR_B4)\",\n",
- " rescale=\"-1,1\",\n",
- " colormap_name=\"greens\",\n",
- " name=\"NDVI Green\",\n",
- ")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/38_plotly.ipynb b/examples/notebooks/38_plotly.ipynb
deleted file mode 100644
index a14480b05f..0000000000
--- a/examples/notebooks/38_plotly.ipynb
+++ /dev/null
@@ -1,419 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/38_plotly.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/38_plotly.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.plotlymap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "If you run into an error saying \"FigureWidget - 'mapbox._derived' Value Error\" ([source](https://github.com/plotly/plotly.py/issues/2570#issuecomment-738735816)), uncomment the following line and run it."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.fix_widget_error()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Create an interactive map using default settings."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Change default setting when creating a map. \n",
- "\n",
- " Can be one of string from \"open-street-map\", \"carto-positron\", \"carto-darkmatter\", \"stamen-terrain\", \"stamen-toner\" or \"stamen-watercolor\" ."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(40, -100), zoom=3, basemap=\"stamen-terrain\", height=500)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Set map center and zoom level."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(basemap=\"stamen-watercolor\")\n",
- "m.set_center(lat=20, lon=0, zoom=2)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Print out available basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.basemaps.keys()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Add a basemap."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Add XYZ tile layer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "tile_url = \"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\"\n",
- "m.add_tile_layer(tile_url, name=\"Google Satellite\", attribution=\"Google\", opacity=1.0)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "Add a mapbox tile layer. You will need a mapbox token. The map style can be Can be \"basic\", \"streets\", \"outdoors\", \"light\", \"dark\", \"satellite\", or \"satellite-streets\"."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "# os.environ[\"MAPBOX_TOKEN\"] = \"your-mapbox-token\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_mapbox_layer(style=\"streets\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "Remove the modebar in the upper-right corner."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(basemap=\"stamen-toner\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "23",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.clear_controls()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "24",
- "metadata": {},
- "source": [
- "Add more buttons to the modebar."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(basemap=\"carto-positron\")\n",
- "controls = [\n",
- " \"drawline\",\n",
- " \"drawopenpath\",\n",
- " \"drawclosedpath\",\n",
- " \"drawcircle\",\n",
- " \"drawrect\",\n",
- " \"eraseshape\",\n",
- "]\n",
- "m.add_controls(controls)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "26",
- "metadata": {},
- "source": [
- "Add Cloud Optimized GeoTIFF."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "27",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- "m.add_cog_layer(url, name=\"Fire (pre-event)\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "28",
- "metadata": {},
- "source": [
- "Add a STAC item via HTTP URL."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "29",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\"\n",
- "m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"False color\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "30",
- "metadata": {},
- "source": [
- "Add a STAC item from Microsoft Planetary Computer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "31",
- "metadata": {},
- "outputs": [],
- "source": [
- "collection = \"landsat-8-c2-l2\"\n",
- "item = \"LC08_L2SP_047027_20201204_02_T1\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "32",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_stac_layer(\n",
- " collection=collection,\n",
- " item=item,\n",
- " bands=[\"SR_B7\", \"SR_B5\", \"SR_B4\"],\n",
- " titiler_endpoint=\"pc\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "33",
- "metadata": {},
- "source": [
- "Add a heat map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "34",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "35",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(basemap=\"stamen-terrain\")\n",
- "m.add_heatmap(\n",
- " url, latitude=\"Latitude\", longitude=\"Longitude\", z=\"Magnitude\", name=\"Earthquake\"\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "36",
- "metadata": {},
- "source": [
- "Add a choropleth map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "37",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "38",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(basemap=\"stamen-terrain\")\n",
- "m.add_choropleth_map(url, name=\"Pop\", z=\"POP_EST\", colorscale=\"Viridis\")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/39_inspector_tool.ipynb b/examples/notebooks/39_inspector_tool.ipynb
deleted file mode 100644
index bde19e32c9..0000000000
--- a/examples/notebooks/39_inspector_tool.ipynb
+++ /dev/null
@@ -1,130 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/39_inspector_tool.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/39_inspector_tool.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Add Cloud Optimized GeoTIFF (COG) from [Planetary Computer](https://planetarycomputer.microsoft.com/catalog)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "collection = \"landsat-8-c2-l2\"\n",
- "item = \"LC08_L2SP_047027_20201204_02_T1\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_stac_layer(\n",
- " collection=collection,\n",
- " item=item,\n",
- " assets=\"SR_B7,SR_B5,SR_B4\",\n",
- " name=\"Landsat Band-754\",\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_stac_layer(\n",
- " collection=collection,\n",
- " item=item,\n",
- " assets=\"SR_B5,SR_B4,SR_B3\",\n",
- " name=\"Landsat Band-543\",\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/Idfx767.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/40_plotly_gui.ipynb b/examples/notebooks/40_plotly_gui.ipynb
deleted file mode 100644
index 594fbaf942..0000000000
--- a/examples/notebooks/40_plotly_gui.ipynb
+++ /dev/null
@@ -1,111 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/40_plotly_gui.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/40_plotly_gui.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.plotlymap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "**Note:** For best experience, please use Jupyter notebook. The toolbar GUI is not working very well with JupyterLab at the moment."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_basemap(\"Esri.WorldTopoMap\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_heatmap_demo()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_scatter_plot_demo()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.show()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/BJZbi9U.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/41_raster_gui.ipynb b/examples/notebooks/41_raster_gui.ipynb
deleted file mode 100644
index 6f1519a946..0000000000
--- a/examples/notebooks/41_raster_gui.ipynb
+++ /dev/null
@@ -1,64 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/41_raster_gui.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/41_raster_gui.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/NGbqMwE.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/42_create_cog.ipynb b/examples/notebooks/42_create_cog.ipynb
deleted file mode 100644
index 9ff0396eee..0000000000
--- a/examples/notebooks/42_create_cog.ipynb
+++ /dev/null
@@ -1,159 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/42_create_cog.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/42_create_cog.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Provide a dataset path or URL."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/raster/srtm90.tif\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Validate COG."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.cog_validate(url)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.cog_validate(url, verbose=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Convert the image to tiled COG."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_cog = \"cog.tif\"\n",
- "leafmap.image_to_cog(url, out_cog)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Validate COG."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.cog_validate(out_cog)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.cog_validate(out_cog, verbose=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Add COG to map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(out_cog, palette=\"terrain\", layer_name=\"Local COG\")\n",
- "m.add_cog_layer(url, palette=\"gist_earth\", name=\"Remote COG\")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/43_search_control.ipynb b/examples/notebooks/43_search_control.ipynb
deleted file mode 100644
index 6bb7bb1ba9..0000000000
--- a/examples/notebooks/43_search_control.ipynb
+++ /dev/null
@@ -1,100 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/43_search_control.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/43_search_control.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Add a search control to the map. See the [Nominatim Usage Policy](https://operations.osmfoundation.org/policies/nominatim)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(draw_control=False)\n",
- "url = \"https://nominatim.openstreetmap.org/search?format=json&q={s}\"\n",
- "m.add_search_control(url)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Search for features in GeoJSON files or any GeoPandas supported vector data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(draw_control=False, layers_control=True)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "m.add_geojson(\n",
- " url,\n",
- " layer_name=\"Countries\",\n",
- " fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"],\n",
- " info_mode=None,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/LP0BElT.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/44_attribute_table.ipynb b/examples/notebooks/44_attribute_table.ipynb
deleted file mode 100644
index 760835e5dc..0000000000
--- a/examples/notebooks/44_attribute_table.ipynb
+++ /dev/null
@@ -1,84 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/44_attribute_table.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/44_attribute_table.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Add vector data to the map and use the GUI to open attribute table."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "m.add_geojson(\n",
- " url,\n",
- " layer_name=\"Countries\",\n",
- " fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"],\n",
- " info_mode=False,\n",
- ")\n",
- "\n",
- "in_geojson = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cable_geo.geojson\"\n",
- "m.add_geojson(in_geojson, layer_name=\"Cable lines\", info_mode=False)\n",
- "\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/IIoLVSG.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/45_create_vector.ipynb b/examples/notebooks/45_create_vector.ipynb
deleted file mode 100644
index 23230273cc..0000000000
--- a/examples/notebooks/45_create_vector.ipynb
+++ /dev/null
@@ -1,90 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/45_create_vector.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/45_create_vector.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create an interactive map and use the drawing tool to draw shapes on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Save the draw features as GeoJSON, Shapefile, or GeoPackage."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.save_draw_features(\"data.geojson\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/b9RbEqb.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/46_edit_vector.ipynb b/examples/notebooks/46_edit_vector.ipynb
deleted file mode 100644
index 34a74e85db..0000000000
--- a/examples/notebooks/46_edit_vector.ipynb
+++ /dev/null
@@ -1,102 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/46_edit_vector.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/46_edit_vector.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(37.712615, -122.386665), zoom=12)\n",
- "m.add_basemap(\"HYBRID\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Add existing vector data to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/training_samples.geojson\"\n",
- "m.edit_vector(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Edit the existing vector data using the drawing tools and save the resulting vector data as GeoJSON, Shapefile, or GeoPackage."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.save_draw_features(\"data.geojson\")"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/47_numpy_to_cog.ipynb b/examples/notebooks/47_numpy_to_cog.ipynb
deleted file mode 100644
index bcbf15b539..0000000000
--- a/examples/notebooks/47_numpy_to_cog.ipynb
+++ /dev/null
@@ -1,186 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/47_numpy_to_cog.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/47_numpy_to_cog.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Create a fresh conda env to run this example if needed.\n",
- "\n",
- "```\n",
- "conda create -n cog python=3.9\n",
- "conda install mamba -c conda-forge\n",
- "mamba install leafmap rio-cogeo -c conda-forge\n",
- "```"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install rio-cogeo"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://github.com/opengeos/leafmap/raw/master/examples/data/cog.tif\"\n",
- "in_cog = \"cog.tif\"\n",
- "out_cog = \"ndvi.tif\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Download a sample dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.download_from_url(url, in_cog)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Convert image to numpy array."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "arr = leafmap.image_to_numpy(in_cog)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "arr.shape"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Computer NDVI."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "ndvi = (arr[3] - arr[0]) / (arr[3] + arr[0])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "ndvi.shape"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Convert numpy array to COG."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.numpy_to_cog(ndvi, out_cog, profile=in_cog)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(in_cog, band=[4, 1, 2], layer_name=\"Color infrared\")\n",
- "m.add_raster(out_cog, palette=\"Greens\", layer_name=\"NDVI\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/OVaTyP3.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/48_lidar.ipynb b/examples/notebooks/48_lidar.ipynb
deleted file mode 100644
index 79b303d01c..0000000000
--- a/examples/notebooks/48_lidar.ipynb
+++ /dev/null
@@ -1,311 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/48_lidar.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/48_lidar.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Visualizing LiDAR data in 3D with only one line of code**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap[lidar] open3d"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Download a [sample LiDAR dataset](https://drive.google.com/file/d/1H_X1190vL63BoFYa_cVBDxtIa8rG-Usb/view?usp=sharing) from Google Drive. The zip file is 52.1 MB and the uncompressed LAS file is 109 MB."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/lidar/madison.zip\"\n",
- "filename = \"madison.las\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.download_file(url, \"madison.zip\", unzip=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Read the LiDAR data"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "las = leafmap.read_lidar(filename)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "The LAS header."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "las.header"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "The number of points."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "las.header.point_count"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "The list of features."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "list(las.point_format.dimension_names)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Inspect data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "las.X"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "las.Y"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "las.Z"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "las.intensity"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "20",
- "metadata": {},
- "source": [
- "Visualize LiDAR data using the [pyvista](https://github.com/pyvista/pyvista) backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.view_lidar(filename, cmap=\"terrain\", backend=\"pyvista\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "22",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/xezcgMP.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "Visualize LiDAR data using the [ipygany](https://github.com/QuantStack/ipygany) backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.view_lidar(filename, backend=\"ipygany\", background=\"white\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "25",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/MyMWW4I.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "26",
- "metadata": {},
- "source": [
- "Visualize LiDAR data using the [panel](https://github.com/holoviz/panel) backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "27",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.view_lidar(filename, cmap=\"terrain\", backend=\"panel\", background=\"white\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "28",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/XQGWbJk.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "29",
- "metadata": {},
- "source": [
- "Visualize LiDAR data using the [open3d](http://www.open3d.org) backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "30",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.view_lidar(filename, backend=\"open3d\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "31",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/rL85fbl.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/49_split_control.ipynb b/examples/notebooks/49_split_control.ipynb
deleted file mode 100644
index 6ecbc04c20..0000000000
--- a/examples/notebooks/49_split_control.ipynb
+++ /dev/null
@@ -1,226 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/49_split_control.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/49_split_control.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Creating a split-panel map**\n",
- "\n",
- "This notebook demonstrates how to add a split-panel map with leafmap anf folium. It also supports streamlit. Note that the ipyleaflet SplitControl does not support streamlit. \n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import folium\n",
- "import rioxarray\n",
- "import xarray as xr\n",
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "The split-panel map requires two layers: `left_layer` and `right_layer`. The layer instance can be a string representing a basemap, or an HTTP URL to a Cloud Optimized GeoTIFF (COG), or a folium TileLayer instance. \n",
- "\n",
- "**Using basemaps**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(height=500)\n",
- "m.split_map(left_layer=\"TERRAIN\", right_layer=\"OpenTopoMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Show available basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.basemaps.keys()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "**Using COG**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(height=600, center=[39.4948, -108.5492], zoom=12)\n",
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- "url2 = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-09-13.tif\"\n",
- "m.split_map(url, url2)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "**Using folium TileLayer**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4)\n",
- "\n",
- "url1 = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2001_Land_Cover_L48/wms?\"\n",
- "url2 = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?\"\n",
- "\n",
- "left_layer = folium.WmsTileLayer(\n",
- " url=url1,\n",
- " layers=\"NLCD_2001_Land_Cover_L48\",\n",
- " name=\"NLCD 2001\",\n",
- " attr=\"MRLC\",\n",
- " fmt=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "right_layer = folium.WmsTileLayer(\n",
- " url=url2,\n",
- " layers=\"NLCD_2019_Land_Cover_L48\",\n",
- " name=\"NLCD 2019\",\n",
- " attr=\"MRLC\",\n",
- " fmt=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "\n",
- "m.split_map(left_layer, right_layer)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "**Using xarrays**"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Download a sample dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/raster/srtm90.tif\"\n",
- "dem = leafmap.download_file(url, \"srtm90.tif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Use rioxarray to read the raster as a xarray DataArray and then classify the DEM into 2 elevation classes."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "dem_ds = rioxarray.open_rasterio(dem)\n",
- "dem_class = xr.where(dem_ds < 2000, 0, 1)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "Visualize the DEM and the elevation class image as a split map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[37.6, -119], zoom=9)\n",
- "m.split_map(\n",
- " dem_ds,\n",
- " dem_class,\n",
- " left_args={\"layer_name\": \"DEM\", \"colormap\": \"terrain\"},\n",
- " right_args={\"layer_name\": \"Classified DEM\", \"colormap\": \"coolwarm\"},\n",
- ")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/50_marker_cluster.ipynb b/examples/notebooks/50_marker_cluster.ipynb
deleted file mode 100644
index f3ecbe9a45..0000000000
--- a/examples/notebooks/50_marker_cluster.ipynb
+++ /dev/null
@@ -1,158 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/50_marker_cluster.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/50_marker_cluster.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Creating a marker cluster with custom icons**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Use sample datasets."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "cities = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.csv\"\n",
- "regions = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_regions.geojson\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Add a GeoJSON to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_geojson(regions, layer_name=\"US Regions\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Add a marker cluster to the map. The input can either be a string (representing file path or HTTP URL to a csv file) or a Pandas DataFrame.\n",
- "\n",
- "The list of available icon names can be found at .\n",
- "\n",
- "Please note that the `spin` parameter only supports the ipyleaflet backend. The folium backend does not support this."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_points_from_xy(\n",
- " cities,\n",
- " x=\"longitude\",\n",
- " y=\"latitude\",\n",
- " color_column=\"region\",\n",
- " icon_names=[\"gear\", \"map\", \"leaf\", \"globe\"],\n",
- " spin=True,\n",
- " add_legend=True,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Display the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/63LDhOx.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/51_clip_image.ipynb b/examples/notebooks/51_clip_image.ipynb
deleted file mode 100644
index 463f309737..0000000000
--- a/examples/notebooks/51_clip_image.ipynb
+++ /dev/null
@@ -1,226 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/51_clip_image.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/51_clip_image.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install rasterio fiona"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Download a sample raster dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/raster/srtm90.tif\"\n",
- "dem = \"dem.tif\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.download_file(url, dem, overwrite=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(dem, palette=\"terrain\", layer_name=\"DEM\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Define a mask to extract the image. The mask can be a string representing a file path to a vector dataset (e.g., geojson, shp), or a list of coordinates (e.g., `[[lon,lat], [lon,lat]]`), or a dictionary representing a feature (e.g., m.user_roi).\n",
- "\n",
- "For example, the mask can be a filepath to a vector dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "# mask = 'https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/mask.geojson'"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Or you can draw a polygon on the map, then use `m.user_roi` as the mask."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "# mask = m.user_roi"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Or specify a list of coordinates `[lon, lat]` as the mask."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "mask = [\n",
- " [-119.679565, 37.256566],\n",
- " [-119.679565, 38.061067],\n",
- " [-118.24585, 38.061067],\n",
- " [-118.24585, 37.256566],\n",
- " [-119.679565, 37.256566],\n",
- "]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Specify the output filename."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "output = \"clip.tif\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "Clip image by mask."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " leafmap.clip_image(dem, mask, output)\n",
- "except Exception as e:\n",
- " print(e)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "Add the clipped image to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " m.add_raster(output, palette=\"gist_earth\", layer_name=\"Clip Image\")\n",
- "except Exception as e:\n",
- " print(e)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/52_netcdf.ipynb b/examples/notebooks/52_netcdf.ipynb
deleted file mode 100644
index 6679376c14..0000000000
--- a/examples/notebooks/52_netcdf.ipynb
+++ /dev/null
@@ -1,225 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/52_netcdf.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/52_netcdf.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Visualizing NetCDF data**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install xarray rioxarray netcdf4 localtileserver"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Download a sample NetCDF dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://github.com/opengeos/datasets/releases/download/raster/wind_global.nc\"\n",
- "filename = \"wind_global.nc\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.download_file(url, output=filename)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Read the NetCDF dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "data = leafmap.read_netcdf(filename)\n",
- "data"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Convert the NetCDF dataset to GeoTIFF. Note that the longitude range of the NetCDF dataset is `[0, 360]`. We need to convert it to `[-180, 180]` by setting `shift_lon=True` so that it can be displayed on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "tif = \"wind_global.tif\"\n",
- "leafmap.netcdf_to_tif(filename, tif, variables=[\"u_wind\", \"v_wind\"], shift_lon=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Add the GeoTIFF to the map. We can also overlay the country boundary on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "geojson = (\n",
- " \"https://github.com/opengeos/leafmap/raw/master/examples/data/countries.geojson\"\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(layers_control=True)\n",
- "m.add_raster(tif, indexes=[1], palette=\"coolwarm\", layer_name=\"u_wind\")\n",
- "m.add_geojson(geojson, layer_name=\"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "You can also use the `add_netcdf()` function to add the NetCDF dataset to the map without having to convert it to GeoTIFF explicitly."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(layers_control=True)\n",
- "m.add_netcdf(\n",
- " filename,\n",
- " variables=[\"v_wind\"],\n",
- " palette=\"coolwarm\",\n",
- " shift_lon=True,\n",
- " layer_name=\"v_wind\",\n",
- " indexes=[1],\n",
- ")\n",
- "m.add_geojson(geojson, layer_name=\"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "Visualizing wind velocity."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(layers_control=True)\n",
- "m.add_basemap(\"CartoDB.DarkMatter\")\n",
- "m.add_velocity(\n",
- " filename,\n",
- " zonal_speed=\"u_wind\",\n",
- " meridional_speed=\"v_wind\",\n",
- " color_scale=[\n",
- " \"rgb(0,0,150)\",\n",
- " \"rgb(0,150,0)\",\n",
- " \"rgb(255,255,0)\",\n",
- " \"rgb(255,165,0)\",\n",
- " \"rgb(150,0,0)\",\n",
- " ],\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/oL5Mgeu.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/53_choropleth.ipynb b/examples/notebooks/53_choropleth.ipynb
deleted file mode 100644
index 7f34618ce5..0000000000
--- a/examples/notebooks/53_choropleth.ipynb
+++ /dev/null
@@ -1,146 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/53_choropleth.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/53_choropleth.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "data = leafmap.examples.datasets.countries_geojson"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Available classification schemes: \n",
- "* BoxPlot\n",
- "* EqualInterval\n",
- "* FisherJenks\n",
- "* FisherJenksSampled\n",
- "* HeadTailBreaks\n",
- "* JenksCaspall\n",
- "* JenksCaspallForced\n",
- "* JenksCaspallSampled\n",
- "* MaxP\n",
- "* MaximumBreaks\n",
- "* NaturalBreaks\n",
- "* Quantiles\n",
- "* Percentiles\n",
- "* StdMean\n",
- "* UserDefined"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_data(\n",
- " data, column=\"POP_EST\", scheme=\"Quantiles\", cmap=\"Blues\", legend_title=\"Population\"\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_data(\n",
- " data,\n",
- " column=\"POP_EST\",\n",
- " scheme=\"EqualInterval\",\n",
- " cmap=\"Blues\",\n",
- " legend_title=\"Population\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_data(\n",
- " data,\n",
- " column=\"POP_EST\",\n",
- " scheme=\"FisherJenks\",\n",
- " cmap=\"Blues\",\n",
- " legend_title=\"Population\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_data(\n",
- " data,\n",
- " column=\"POP_EST\",\n",
- " scheme=\"JenksCaspall\",\n",
- " cmap=\"Blues\",\n",
- " legend_title=\"Population\",\n",
- ")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/54_plot_raster.ipynb b/examples/notebooks/54_plot_raster.ipynb
deleted file mode 100644
index db14f1c341..0000000000
--- a/examples/notebooks/54_plot_raster.ipynb
+++ /dev/null
@@ -1,128 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/54_plot_raster.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/54_plot_raster.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Download a sample dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/raster/srtm90.tif\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "image = \"srtm90.tif\"\n",
- "if not os.path.exists(image):\n",
- " leafmap.download_file(url, image)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Plot the raster image in 2D."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.plot_raster(image, cmap=\"terrain\", figsize=(15, 10))"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/oDoivba.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Plot the raster image in 3D."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.plot_raster_3d(\"srtm90.tif\", factor=2, cmap=\"terrain\", background=\"gray\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/UQDbV2G.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/55_lidar.ipynb b/examples/notebooks/55_lidar.ipynb
deleted file mode 100644
index 7ea95c7bcd..0000000000
--- a/examples/notebooks/55_lidar.ipynb
+++ /dev/null
@@ -1,400 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/55_lidar.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/55_lidar.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**LiDAR data analysis and visualization with whitebox and leafmap**\n",
- "\n",
- "Create a new conda env to install required packages:\n",
- "\n",
- "```bash\n",
- "conda create -n geo python\n",
- "conda activate geo\n",
- "conda install -c conda-forge mamba\n",
- "mamba install -c conda-forge pygis\n",
- "pip install laspy[lazrs]\n",
- "```\n",
- "\n",
- "Uncomment the following line to install packages in Google Colab."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install laspy[lazrs]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "## Import libraries"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap\n",
- "import whitebox"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "## Set up whitebox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt = whitebox.WhiteboxTools()\n",
- "wbt.set_working_dir(os.getcwd())\n",
- "wbt.set_verbose_mode(False)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "## Download sample data"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/lidar/madison.zip\"\n",
- "filename = \"madison.las\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.download_file(url, \"madison.zip\", unzip=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "## Read LAS/LAZ data"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "laz = leafmap.read_lidar(filename)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "laz"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "str(laz.header.version)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "## Upgrade file version"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "las = leafmap.convert_lidar(laz, file_version=\"1.4\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "str(las.header.version)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "## Write LAS data"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.write_lidar(las, \"madison.las\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "## Histogram analysis"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.lidar_histogram(\"madison.las\", \"histogram.html\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "## Visualize LiDAR data"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.view_lidar(\"madison.las\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "## Remove outliers"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.lidar_elevation_slice(\"madison.las\", \"madison_rm.las\", minz=0, maxz=450)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "25",
- "metadata": {},
- "source": [
- "## Visualize LiDAR data after removing outliers"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.view_lidar(\"madison_rm.las\", cmap=\"terrain\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27",
- "metadata": {},
- "source": [
- "## Create DSM"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.lidar_digital_surface_model(\n",
- " \"madison_rm.las\", \"dsm.tif\", resolution=1.0, minz=0, maxz=450\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "29",
- "metadata": {
- "jp-MarkdownHeadingCollapsed": true
- },
- "outputs": [],
- "source": [
- "leafmap.add_crs(\"dsm.tif\", epsg=2255)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "30",
- "metadata": {},
- "source": [
- "## Visualize DSM"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "31",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(\"dsm.tif\", palette=\"terrain\", layer_name=\"DSM\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "32",
- "metadata": {},
- "source": [
- "## Create DEM"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "33",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.remove_off_terrain_objects(\"dsm.tif\", \"dem.tif\", filter=25, slope=15.0)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "34",
- "metadata": {},
- "source": [
- "## Visualize DEM"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "35",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(\"dem.tif\", palette=\"terrain\", layer_name=\"DEM\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "36",
- "metadata": {},
- "source": [
- "## Create CHM"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "37",
- "metadata": {},
- "outputs": [],
- "source": [
- "chm = wbt.subtract(\"dsm.tif\", \"dem.tif\", \"chm.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "38",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(\"chm.tif\", palette=\"gist_earth\", layer_name=\"CHM\")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/56_download_ned.ipynb b/examples/notebooks/56_download_ned.ipynb
deleted file mode 100644
index d87cc33e45..0000000000
--- a/examples/notebooks/56_download_ned.ipynb
+++ /dev/null
@@ -1,150 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/56_download_ned.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/56_download_ned.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Downloading 10-m National Elevation Dataset (NED) with only one line of code**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install geopandas rasterio"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap\n",
- "import shutil\n",
- "import sys"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "region = m.user_roi_bounds()\n",
- "if region is None:\n",
- " region = [-115.9689, 35.9758, -115.3619, 36.4721]\n",
- "print(region)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.download_ned(region, return_url=True)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_dir = \"data\"\n",
- "os.makedirs(out_dir, exist_ok=True)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "if \"google.colab\" in sys.modules:\n",
- " leafmap.download_ned(region, out_dir)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "if \"google.colab\" in sys.modules:\n",
- " mosaic = \"mosaic.tif\"\n",
- " leafmap.mosaic(images=out_dir, output=mosaic)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "if \"google.colab\" in sys.modules and (m.user_roi is not None):\n",
- " image = \"dem.tif\"\n",
- " leafmap.clip_image(mosaic, mask=m.user_roi, output=image)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_dir = \"/content/drive/MyDrive/Data\"\n",
- "if os.path.exists(out_dir) and os.path.exists(image):\n",
- " shutil.copyfile(image, os.path.join(out_dir, image))"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/57_national_map.ipynb b/examples/notebooks/57_national_map.ipynb
deleted file mode 100644
index b4a4300e9f..0000000000
--- a/examples/notebooks/57_national_map.ipynb
+++ /dev/null
@@ -1,497 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/57_national_map.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/57_national_map.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "### Downloading various shapes from the National Map\n",
- "\n",
- "The national map (TNM) is a catalog of *topological* datasources maintained by the USGS. \n",
- "\n",
- "- It contains a wide range of dataformats (such as GeoTiff, LAZ, ...) and datasets.\n",
- "- It provides an endpoint that can be used to search for published datasets and files.\n",
- "- This API supports a wide range of searchable parameters (bounding box, polygon, dates, keyword, ...)\n",
- "- It returns detailed information regarding the properties of datasets, file,\n",
- "- as well as various download links (file, thumbnail, xml descriptions, ...).\n",
- "\n",
- "We've created a thin wrapper to expose this treasure trove. \n",
- "\n",
- "- For more details about TNM, see https://apps.nationalmap.gov/tnmaccess/#/\n",
- "- The same data is also downloable using https://apps.nationalmap.gov/downloader/"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "### Usage\n",
- "\n",
- "A class groups the functionalities together."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "TNM = leafmap.The_national_map_USGS()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "### Datasets"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "TNM.datasets"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "### Formats\n",
- "\n",
- "Note that any format (f.e. 'All') is specific to one or more datasets."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "TNM.prodFormats"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "### Looking for files"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "TNM.find_details().keys(), TNM.find_details()[\"total\"]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "### A detail"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "TNM.find_details()[\"items\"][0]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "### Using parameters"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "params = {\n",
- " \"q\": \"National Elevation Dataset (NED) 1/3 arc-second\",\n",
- " \"polyCode\": \"01010002\",\n",
- " \"polyType\": \"huc8\",\n",
- "}\n",
- "\n",
- "TNM.find_details(**params)[\"total\"]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "params = {\n",
- " \"prodFormats\": \"LAS,LAZ\",\n",
- " \"datasets\": \"Lidar Point Cloud (LPC)\",\n",
- " \"polygon\": [\n",
- " (-104.94262695312236, 41.52867510196275),\n",
- " (-102.83325195312291, 40.45065268246805),\n",
- " (-104.94262695312236, 40.45065268246805),\n",
- " (-104.94262695312236, 41.52867510196275),\n",
- " ],\n",
- "}\n",
- "\n",
- "TNM.find_details(**params)[\"total\"]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "Available parameters"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "help(TNM.find_details)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "### Max items\n",
- "\n",
- "Defaults to about 50. You only retrieve about 1000 items in one call."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "len(TNM.find_details()[\"items\"])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "len(TNM.find_details(max=1000000)[\"items\"])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "Use offset to retrieve more batches."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "params = {\n",
- " \"q\": \"National Elevation Dataset (NED) 1/3 arc-second\",\n",
- " \"polyCode\": \"01010002\",\n",
- " \"polyType\": \"huc8\",\n",
- " \"max\": 2,\n",
- "}\n",
- "\n",
- "TNM.find_details(**params, offset=0)[\"items\"][0] == TNM.find_details(\n",
- " **params, offset=1\n",
- ")[\"items\"][0]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "### Select a region from leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "region = m.user_roi_bounds()\n",
- "if region is None:\n",
- " region = [-115.9689, 35.9758, -115.3619, 36.4721]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "TNM.find_details(q=\"LAZ\", bbox=region)[\"total\"]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27",
- "metadata": {},
- "source": [
- "### Error handling"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "bool(TNM.find_details(start=\"01-01-2010\", q=\"NED\", bbox=region))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "29",
- "metadata": {},
- "outputs": [],
- "source": [
- "bool(TNM.find_details(start=\"2021-12-01\", end=\"2020-01-01\", q=\"NED\", bbox=region))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "30",
- "metadata": {},
- "outputs": [],
- "source": [
- "bool(TNM.find_details(start=\"2021-12-01\", end=\"2022-01-01\", q=\"NED\", bbox=region))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "31",
- "metadata": {},
- "outputs": [],
- "source": [
- "bool(\n",
- " TNM.find_details(\n",
- " start=\"2020-12-01\",\n",
- " end=\"2022-01-01\",\n",
- " q=\"NED\",\n",
- " dateType=\"dateCreated\",\n",
- " bbox=region,\n",
- " )\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "32",
- "metadata": {},
- "source": [
- "### Downloading files"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "33",
- "metadata": {},
- "outputs": [],
- "source": [
- "help(TNM.download_tiles)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "34",
- "metadata": {},
- "outputs": [],
- "source": [
- "params = {\n",
- " \"q\": \"National Elevation Dataset (NED) 1/3 arc-second\",\n",
- " \"polyCode\": \"01010002\",\n",
- " \"polyType\": \"huc8\",\n",
- " \"max\": 0,\n",
- "}\n",
- "\n",
- "TNM.download_tiles(API=params)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "35",
- "metadata": {},
- "source": [
- "It can also be accessed without invoking the class."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "36",
- "metadata": {},
- "outputs": [],
- "source": [
- "params = {\n",
- " \"q\": \"National Elevation Dataset (NED) 1/3 arc-second\",\n",
- " \"polyCode\": \"01010002\",\n",
- " \"polyType\": \"huc8\",\n",
- " \"max\": 0,\n",
- "}\n",
- "\n",
- "leafmap.download_tnm(API=params)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "37",
- "metadata": {},
- "outputs": [],
- "source": [
- "region = [-115.9689, 35.9758, -115.3619, 36.4721]\n",
- "\n",
- "leafmap.download_ned(region=region, return_url=True) == leafmap.download_tnm(\n",
- " region=region, return_url=True, API={\"q\": \"NED\"}\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "38",
- "metadata": {},
- "source": [
- "### List of files"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "39",
- "metadata": {},
- "outputs": [],
- "source": [
- "TNM.find_tiles(API=params)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "40",
- "metadata": {},
- "source": [
- "### Dataset metadata"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "41",
- "metadata": {},
- "outputs": [],
- "source": [
- "TNM.datasets_full[0]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "42",
- "metadata": {},
- "source": [
- "### Read the docs"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "43",
- "metadata": {},
- "outputs": [],
- "source": [
- "help(TNM)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/58_bokeh.ipynb b/examples/notebooks/58_bokeh.ipynb
deleted file mode 100644
index ab8717f345..0000000000
--- a/examples/notebooks/58_bokeh.ipynb
+++ /dev/null
@@ -1,260 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/58_bokeh.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/58_bokeh.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install bokeh jupyter_bokeh"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.bokehmap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Create an interactive map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Specify center and zoom level"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4, height=400)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Add basemaps"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "# print(leafmap.basemaps.keys())"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Add COG"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-09-13.tif\"\n",
- "m.add_cog_layer(url)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Add STAC"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\"\n",
- "m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"False color\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Add local raster datasets"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/raster/srtm90.tif\"\n",
- "leafmap.download_file(url, \"dem.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(\"dem.tif\", colormap=\"terrain\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "Add points"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/leafmap/blob/master/examples/data/us_cities.geojson\"\n",
- "m.add_geojson(url, size=10, color=\"blue\", alpha=0.7)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "20",
- "metadata": {},
- "source": [
- "Add lines"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"CartoDB.DarkMatter\")\n",
- "url = \"https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson\"\n",
- "m.add_vector(url, line_color=\"color\", line_width=2)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "22",
- "metadata": {},
- "source": [
- "Add polygons"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "23",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/leafmap/blob/master/examples/data/countries.geojson\"\n",
- "m.add_vector(url, fill_alpha=0.5, fill_color=\"lightblue\")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/59_create_legend.ipynb b/examples/notebooks/59_create_legend.ipynb
deleted file mode 100644
index 20b8d9bbc7..0000000000
--- a/examples/notebooks/59_create_legend.ipynb
+++ /dev/null
@@ -1,256 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/59_create_legend.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/59_create_legend.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create a built-in draggable legend. Specify the `output` parameter to save the legend as an HTML file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.create_legend(\n",
- " title=\"NLCD Land Cover Type\",\n",
- " builtin_legend=\"NLCD\",\n",
- " draggable=True,\n",
- " output=\"NLCD_legend.html\",\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Create a built-in non-draggable legend. If the `output` parameter is not specified, the legend will be returned as an HTML string."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "html = leafmap.create_legend(\n",
- " title=\"NLCD Land Cover Type\",\n",
- " builtin_legend=\"NLCD\",\n",
- " draggable=False,\n",
- " position=\"bottomright\",\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "widget = leafmap.show_html(html)\n",
- "widget"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " widget.close()\n",
- "except:\n",
- " pass"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Create a custom legend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "legend_dict = {\n",
- " \"10 Trees\": \"006400\",\n",
- " \"20 Shrubland\": \"ffbb22\",\n",
- " \"30 Grassland\": \"ffff4c\",\n",
- " \"40 Cropland\": \"f096ff\",\n",
- " \"50 Built-up\": \"fa0000\",\n",
- " \"60 Barren / sparse vegetation\": \"b4b4b4\",\n",
- " \"70 Snow and ice\": \"f0f0f0\",\n",
- " \"80 Open water\": \"0064c8\",\n",
- " \"90 Herbaceous wetland\": \"0096a0\",\n",
- " \"95 Mangroves\": \"00cf75\",\n",
- " \"100 Moss and lichen\": \"fae6a0\",\n",
- "}"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.create_legend(\n",
- " title=\"ESA Land Cover Type\",\n",
- " legend_dict=legend_dict,\n",
- " draggable=False,\n",
- " output=\"ESA_legend.html\",\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Customize the legend by specifying the `style` parameter."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"ESA WorldCover 2021\")\n",
- "\n",
- "style = {\n",
- " \"position\": \"fixed\",\n",
- " \"z-index\": \"9999\",\n",
- " \"border\": \"2px solid grey\",\n",
- " \"background-color\": \"rgba(255, 255, 255, 0.8)\",\n",
- " \"border-radius\": \"10px\",\n",
- " \"padding\": \"5px\",\n",
- " \"font-size\": \"14px\",\n",
- " \"bottom\": \"20px\",\n",
- " \"right\": \"5px\",\n",
- "}\n",
- "\n",
- "m.add_legend(\n",
- " title=\"ESA Land Cover Type\", legend_dict=legend_dict, draggable=False, style=style\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Add a legend to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"ESA WorldCover 2021\")\n",
- "m.add_legend(title=\"ESA Land Cover Type\", builtin_legend=\"ESA_WorldCover\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "Add legends to a split-view map. Make sure the `draggable` parameter is set to `False`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " center=[40, -100],\n",
- " zoom=4,\n",
- " draw_control=False,\n",
- " measure_control=False,\n",
- " scale_control=False,\n",
- ")\n",
- "m.split_map(left_layer=\"ESA WorldCover 2021\", right_layer=\"NLCD 2019 CONUS Land Cover\")\n",
- "m.add_legend(\n",
- " title=\"ESA Land Cover Type\",\n",
- " builtin_legend=\"ESA_WorldCover\",\n",
- " draggable=False,\n",
- " position=\"bottomleft\",\n",
- " style={\"bottom\": \"5px\"},\n",
- ")\n",
- "m.add_legend(\n",
- " title=\"NLCD Land Cover Type\",\n",
- " builtin_legend=\"NLCD\",\n",
- " draggable=False,\n",
- " position=\"bottomright\",\n",
- ")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/60_add_widget.ipynb b/examples/notebooks/60_add_widget.ipynb
deleted file mode 100644
index 2574e51a25..0000000000
--- a/examples/notebooks/60_add_widget.ipynb
+++ /dev/null
@@ -1,211 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/60_add_widget.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/60_add_widget.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Add text."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "text = \"Hello World\"\n",
- "m.add_text(text, position=\"bottomright\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Customize text style."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "text = \"Hello World\"\n",
- "\n",
- "params = {\n",
- " \"fontsize\": 30,\n",
- " \"fontcolor\": \"blue\",\n",
- " \"bold\": True,\n",
- " \"padding\": \"10px\",\n",
- " \"background\": True,\n",
- " \"bg_color\": \"white\",\n",
- " \"border_radius\": \"5px\",\n",
- " \"position\": \"bottomright\",\n",
- "}\n",
- "\n",
- "m.add_text(text, **params)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(measure_control=False, scale_control=False)\n",
- "left = \"ESA WorldCover 2021 S2 FCC\"\n",
- "right = \"ESA WorldCover 2021 S2 TCC\"\n",
- "m.split_map(left_layer=left, right_layer=right)\n",
- "m.add_text(left, position=\"bottomleft\")\n",
- "m.add_text(right, position=\"bottomright\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Add image."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "image = \"https://i.imgur.com/LmTETPX.png\"\n",
- "m.add_image(image, position=\"bottomright\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Add HTML."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "html = \"\"\"\n",
- "Jupyter Logo
\n",
- "\n",
- "\"\"\"\n",
- "m.add_html(html, position=\"bottomright\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Add widget."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "import numpy as np\n",
- "import matplotlib.pyplot as plt"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Data for plotting\n",
- "t = np.arange(0.0, 2.0, 0.01)\n",
- "s = 1 + np.sin(2 * np.pi * t)\n",
- "\n",
- "fig, ax = plt.subplots(figsize=(4, 3))\n",
- "ax.plot(t, s)\n",
- "\n",
- "ax.set(\n",
- " xlabel=\"time (s)\", ylabel=\"voltage (mV)\", title=\"About as simple as it gets, folks\"\n",
- ")\n",
- "ax.grid()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_widget(fig, position=\"bottomright\")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/61_vector_to_gif.ipynb b/examples/notebooks/61_vector_to_gif.ipynb
deleted file mode 100644
index 5eed9ddb34..0000000000
--- a/examples/notebooks/61_vector_to_gif.ipynb
+++ /dev/null
@@ -1,125 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/61_vector_to_gif.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/61_vector_to_gif.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Creating animated GIF from vector data**\n",
- "\n",
- "Inspired by Johannes Uhl's [shapefile2gif](https://github.com/johannesuhl/shapefile2gif), I created a `vector_to_gif()` function in leafmap that makes it much easier to create animated GIF from vector data with only one line of code. The sample dataset used in this notebook is a subset of the dataset retrieved from the [shapefile2gif](https://github.com/johannesuhl/shapefile2gif) repo. Credits to Johannes Uhl. For more information about the datasets, check out the references below: \n",
- "\n",
- "- Uhl, Johannes H; Leyk, Stefan (2022), \"MTBF-33: A multi-temporal building footprint dataset for\n",
- "33 counties in the United States (1900–2015)\", *Data in Brief*, 43, 108369. DOI: [10.1016/j.dib.2022.108369](https://doi.org/10.1016/j.dib.2022.108369)\n",
- "- Uhl, Johannes H; Leyk, Stefan (2022), “MTBF-33: A multi-temporal building footprint dataset for 33 U.S. counties\n",
- "at annual resolution (1900-2015)”, *Mendeley Data*, V2. DOI: [10.17632/w33vbvjtdy.2](https://doi.org/10.17632/w33vbvjtdy.2)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "# A subset of the dataset retrieved from https://github.com/johannesuhl/shapefile2gif\n",
- "data = \"https://open.gishub.org/data/us/boulder_buildings.zip\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[39.9898, -105.2532], zoom=14)\n",
- "m.add_vector(data, layer_name=\"Buildings\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_gif = \"buildings.gif\"\n",
- "colname = \"year_built\"\n",
- "title = \"Building Evolution in Boulder, Colorado, USA (1950-2015)\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.vector_to_gif(\n",
- " data,\n",
- " out_gif,\n",
- " colname,\n",
- " vmin=1950,\n",
- " vmax=2015,\n",
- " step=10,\n",
- " facecolor=\"black\",\n",
- " figsize=(10, 8),\n",
- " title=title,\n",
- " xy=(\"1%\", \"1%\"),\n",
- " fontsize=20,\n",
- " progress_bar_color=\"blue\",\n",
- " progress_bar_height=10,\n",
- " dpi=300,\n",
- " fps=10,\n",
- " mp4=False,\n",
- " verbose=True,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/gf3JJ1N.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/62_folium_colorbar.ipynb b/examples/notebooks/62_folium_colorbar.ipynb
deleted file mode 100644
index bc0c985673..0000000000
--- a/examples/notebooks/62_folium_colorbar.ipynb
+++ /dev/null
@@ -1,220 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/62_folium_colorbar.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/62_folium_colorbar.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Adding colorbars to a folium map**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "Unlike the ipyleaflet plotting backend, folium does not support adding matplotlib colormap directly. One workaround is to save the maplotlib colormap as an image, then add the image to the map. Let's first create a colormap."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create a colormap using specified parameters."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "params = {\n",
- " \"width\": 4.0,\n",
- " \"height\": 0.3,\n",
- " \"vmin\": 0,\n",
- " \"vmax\": 6000,\n",
- " \"cmap\": \"terrain\",\n",
- " \"label\": \"Elevation (m)\",\n",
- " \"orientation\": \"horizontal\",\n",
- " \"transparent\": False,\n",
- "}"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Save the colormap as an image."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.save_colorbar(\"colorbar.png\", **params)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "You can also create use the `m.add_colormap()` method to add a colormap. Under the hood, it generate a colormap as an image, then add it to the map. You need to specified the position of the colormap using a tuple (x, y), which represents the percentage [0-100] from the lower-left corner. If the map size changes, you might need to change the colormap position as well."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Add a horizontal colormap to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_colormap(position=(55, 5), **params)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Make the colormap background transparent."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "params[\"transparent\"] = True"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_colormap(position=(55, 5), **params)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Change the orientation to vertical."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "params = {\n",
- " \"width\": 0.3,\n",
- " \"height\": 4,\n",
- " \"vmin\": 0,\n",
- " \"vmax\": 6000,\n",
- " \"cmap\": \"terrain\",\n",
- " \"label\": \"Elevation (m)\",\n",
- " \"orientation\": \"vertical\",\n",
- " \"transparent\": False,\n",
- "}"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_colormap(position=(85, 5), **params)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "To make the colormap position fixed at four corners (i.e., `bottomright`, `bottomleft`, `topright`, `topleft`), you need to make the image available through an HTTP URL (e.g., [imgur](https://imgur.com)). Local file paths are not supported. Use `m.add_image()` to add the colormap image to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "image = \"https://i.imgur.com/SpmE7Cs.png\"\n",
- "m.add_image(image, position=\"bottomright\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/hpHZiqT.png)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/63_arcgis.ipynb b/examples/notebooks/63_arcgis.ipynb
deleted file mode 100644
index a0564f4322..0000000000
--- a/examples/notebooks/63_arcgis.ipynb
+++ /dev/null
@@ -1,129 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/63_arcgis.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/63_arcgis.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Add basemap."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"TERRAIN\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Add COG layer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_cog_layer(url, name=\"COG\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Add STAC layer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"STAC\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/GbVx3vV.png)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/64_stac_search.ipynb b/examples/notebooks/64_stac_search.ipynb
deleted file mode 100644
index a291780efa..0000000000
--- a/examples/notebooks/64_stac_search.ipynb
+++ /dev/null
@@ -1,234 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/zz_notebook_template.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/64_stac_search.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://earth-search.aws.element84.com/v1/\"\n",
- "collection = \"sentinel-2-l2a\"\n",
- "time_range = \"2020-12-01/2020-12-31\"\n",
- "bbox = [-122.2751, 47.5469, -121.9613, 47.7458]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=10,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " query={\"eo:cloud_cover\": {\"lt\": 10}},\n",
- " sortby=[{\"field\": \"properties.eo:cloud_cover\", \"direction\": \"asc\"}],\n",
- ")\n",
- "search"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=10,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " get_collection=True,\n",
- ")\n",
- "# search"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=10,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " get_gdf=True,\n",
- ")\n",
- "search.head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=10,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " get_assets=True,\n",
- ")\n",
- "# search"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=10,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " get_info=True,\n",
- ")\n",
- "# search"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=10,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " get_links=True,\n",
- ")\n",
- "search"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Search and visualize open geospatial dataset interactively"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.show_youtube_video(\"https://youtu.be/7OEraGYOWiU\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[37.7517, -122.4433], zoom=8)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "The search results can be accessed using one of the following methods:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.stac_gdf # The GeoDataFrame of the STAC search results"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.stac_dict # The STAC search results as a dictionary"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.stac_item # The selected STAC item of the search result"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/65_sagemaker.ipynb b/examples/notebooks/65_sagemaker.ipynb
deleted file mode 100644
index 97d97d4ae1..0000000000
--- a/examples/notebooks/65_sagemaker.ipynb
+++ /dev/null
@@ -1,206 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/65_sagemaker.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/65_sagemaker.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "1",
- "metadata": {},
- "source": [
- "## Install packages\n",
- "Uncomment the following code blocks to install GDAL, leafmap, and localtileserver on SageMaker Studio Lab."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install --find-links=https://girder.github.io/large_image_wheels --no-cache GDAL"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "# pip install leafmap localtileserver matplotlib==3.6.3 folium==0.13.0"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "Restart the kernel after installing the packages."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "## Import libraries\n",
- "\n",
- "ipyleaflet currently does not work on SageMAker Studio Lab. See this [issue](https://github.com/jupyter-widgets/ipyleaflet/issues/1034). We can use the folium plotting backend instead."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "## Visualize local raster data"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Download a sample raster dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/raster/srtm90.tif\"\n",
- "leafmap.download_file(url, \"dem.tif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(\"dem.tif\", palette=\"terrain\", layer_name=\"Local Raster\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Create a split-view map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.split_map(\n",
- " left_layer=\"dem.tif\", right_layer=\"dem.tif\", right_args={\"palette\": \"terrain\"}\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "## Visualize Cloud Optimized GeoTIFF (COG)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- "m.add_cog_layer(url, name=\"COG\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- "url2 = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-09-13.tif\"\n",
- "m.split_map(left_layer=url, right_layer=url2)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "## Visualize SpatioTemporal Asset Catalog (STAC) Items"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\"\n",
- "m.add_stac_layer(url, bands=[\"pan\"], name=\"Panchromatic\")\n",
- "m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"False color\")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/66_gradio.ipynb b/examples/notebooks/66_gradio.ipynb
deleted file mode 100644
index d811807ade..0000000000
--- a/examples/notebooks/66_gradio.ipynb
+++ /dev/null
@@ -1,126 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/66_gradio.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/66_gradio.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Developing interactive web apps with gradio and leafmap**\n",
- "\n",
- "Gradio: https://gradio.app"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install -U leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "## Folium backend"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import gradio as gr\n",
- "import leafmap.foliumap as leafmap\n",
- "\n",
- "\n",
- "def split(left, right):\n",
- " m = leafmap.Map()\n",
- " m.split_map(left_layer=left, right_layer=right)\n",
- " return m.to_gradio()\n",
- "\n",
- "\n",
- "left_url = (\n",
- " \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- ")\n",
- "right_url = (\n",
- " \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-09-13.tif\"\n",
- ")\n",
- "left_input = gr.Textbox(value=left_url, label=\"Left Layer URL\")\n",
- "right_input = gr.Textbox(value=right_url, label=\"Right Layer URL\")\n",
- "\n",
- "demo = gr.Interface(split, [left_input, right_input], \"html\")\n",
- "# demo.launch()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/srsosv6.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "## Plotly backend"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "import gradio as gr\n",
- "import leafmap.plotlymap as leafmap\n",
- "\n",
- "\n",
- "def viz_cog(url):\n",
- " m = leafmap.Map()\n",
- " m.add_cog_layer(url)\n",
- " return m\n",
- "\n",
- "\n",
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- "\n",
- "demo = gr.Interface(\n",
- " fn=viz_cog,\n",
- " inputs=gr.Text(value=url, label=\"Enter a COG URL\"),\n",
- " outputs=gr.Plot(),\n",
- ")\n",
- "# demo.launch()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/ktzZlON.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/67_maxar_open_data.ipynb b/examples/notebooks/67_maxar_open_data.ipynb
deleted file mode 100644
index a1dad323ab..0000000000
--- a/examples/notebooks/67_maxar_open_data.ipynb
+++ /dev/null
@@ -1,250 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/67_maxar_open_data.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/67_maxar_open_data.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Visualizing Maxar Open Data with Leafmap**\n",
- "\n",
- "\n",
- "The [Maxar Open Data Program](https://www.maxar.com/open-data) provides pre- and post-event high-resolution satellite imagery in support of emergency planning, risk assessment, monitoring of staging areas and emergency response, damage assessment, and recovery. Check out the links below for more information.\n",
- "- [Maxar Open Data Program](https://www.maxar.com/open-data)\n",
- "- [Maxar Open Data on AWS](https://registry.opendata.aws/maxar-open-data/)\n",
- "- [Maxar Open Data on STAC Index](https://stacindex.org/catalogs/maxar-open-data-catalog-ard-format#/)\n",
- "- [Maxar Open Data on STAC Browser](https://radiantearth.github.io/stac-browser/#/external/maxar-opendata.s3.amazonaws.com/events/catalog.json?.language=en)\n",
- "\n",
- "The Maxar Open Data STAC catalog URL is: https://maxar-opendata.s3.amazonaws.com/events/catalog.json"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Retrieve all collections from the Maxar Open Data STAC catalog. Each collection represents a single event."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.maxar_collections()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Retrieve all collections for a specific event:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "collections = leafmap.maxar_child_collections(\"Kahramanmaras-turkey-earthquake-23\")\n",
- "print(f\"The number of collections: {len(collections)}\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "collections[:5]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Retrieve all items (tiles) for a specific collection and generate the footprints:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = leafmap.maxar_items(\n",
- " collection_id=\"Kahramanmaras-turkey-earthquake-23\",\n",
- " child_id=\"1050050044DE7E00\",\n",
- " return_gdf=True,\n",
- " assets=[\"visual\"],\n",
- ")\n",
- "gdf.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Add the footprints to the map:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_gdf(gdf, layer_name=\"Footprints\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Retrieve the COG URLs for all tiles in a collection:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "images = gdf[\"visual\"].tolist()\n",
- "images[:5]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Create a mosaic json file for the collection. You need to install `cogeo-mosaic` first using `pip install cogeo-mosaic`. Creating a mosaic json file might take a few minutes. Please be patient."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.create_mosaicjson(images, output='1050050044DE7E00.json')"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "Make the mosaic json file available on the web, then you can add the mosaic to the map:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://geospatial.glitch.me/1050050044DE7E00.json\"\n",
- "m.add_stac_layer(url, name=\"Mosaic\")\n",
- "m.add_gdf(gdf, layer_name=\"Footprints\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "Retrieve the footprint of all tiles for a specific event. This might take 15+ minutes. Please be patient."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "# gdf = leafmap.maxar_all_items(\n",
- "# collection_id='Kahramanmaras-turkey-earthquake-23',\n",
- "# return_gdf=True,\n",
- "# verbose=True\n",
- "# )\n",
- "# gdf.to_file('maxar_footprints.geojson', driver='GeoJSON')\n",
- "# gdf"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "20",
- "metadata": {},
- "source": [
- "Add the footprints to the map:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[36.844461, 37.386475], zoom=8)\n",
- "# m.add_gdf(gdf, layer_name=\"Footprints\")\n",
- "url = \"https://cdn.glitch.global/cc5b7737-d8d0-4b07-bf2f-867b9009e986/maxar_footprints.geojson?v=1676583955698\"\n",
- "m.add_geojson(url, layer_name=\"Footprints\")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/68_openaerialmap.ipynb b/examples/notebooks/68_openaerialmap.ipynb
deleted file mode 100644
index 19679cdc6d..0000000000
--- a/examples/notebooks/68_openaerialmap.ipynb
+++ /dev/null
@@ -1,201 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/68_openaerialmap.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/68_openaerialmap.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Searching and visualizing OpenAerialMap imagery interactively**\n",
- "\n",
- "[OpenAerialMap](https://openaerialmap.org/) (OAM) provides openly licensed satellite and unmanned aerial vehicle (UAV) imagery. Currently, it has over 12,400+ images around the globe. This notebook demonstrates how to search and visualize OAM imagery interactively. You can download images automatically with one line of code.\n",
- "\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "Search OAM images by a bounding box and a date range. The results can be returned as a GeoDataFrame or a list of image metadata."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "bbox = [-79.6344, -0.9063, -77.3383, 1.0436]\n",
- "start_date = \"2016-04-01\"\n",
- "end_date = \"2016-04-30\"\n",
- "gdf = leafmap.oam_search(\n",
- " bbox=bbox, start_date=start_date, end_date=end_date, return_gdf=True\n",
- ")\n",
- "print(f\"Found {len(gdf)} images\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "The tile URLs are stored in the `tms` column of the GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "tiles = gdf[\"tms\"].tolist()\n",
- "tiles[:5]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "The image sources (downloadable URLs) are stored in the `uuid` column of the GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "images = gdf[\"uuid\"].tolist()\n",
- "images[:5]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Download all images using the `download_files()` function."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.download_files(images[:2])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Add the image footprints to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_gdf(gdf, layer_name=\"Footprints\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Search OAM imagery within the current map extent or user drawn ROI."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[4.7955, -75.6899], zoom=15)\n",
- "m.add_basemap(\"SATELLITE\", show=False)\n",
- "\n",
- "bbox = [-75.7138, 4.7826, -75.6659, 4.808332]\n",
- "m.oam_search(bbox=bbox)\n",
- "\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Search OAM imagery interactively using the interactive GUI."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[4.7955, -75.6899], zoom=15)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/YLnNOVF.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/69_turkey_earthquake.ipynb b/examples/notebooks/69_turkey_earthquake.ipynb
deleted file mode 100644
index 052cbef77d..0000000000
--- a/examples/notebooks/69_turkey_earthquake.ipynb
+++ /dev/null
@@ -1,414 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/69_turkey_earthquake.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/69_turkey_earthquake.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Visualizing Maxar Open Data for the 2023 Turkey-Syria Earthquake**\n",
- "\n",
- "The [Maxar Open Data Program](https://www.maxar.com/open-data) provides pre- and post-event high-resolution satellite imagery in support of emergency planning, risk assessment, monitoring of staging areas and emergency response, damage assessment, and recovery. Check out the links below for more information.\n",
- "- [Maxar Open Data Program](https://www.maxar.com/open-data)\n",
- "- [Maxar Open Data on AWS](https://registry.opendata.aws/maxar-open-data/)\n",
- "- [Maxar Open Data on STAC Index](https://stacindex.org/catalogs/maxar-open-data-catalog-ard-format#/)\n",
- "- [Maxar Open Data on STAC Browser](https://radiantearth.github.io/stac-browser/#/external/maxar-opendata.s3.amazonaws.com/events/catalog.json?.language=en)\n",
- "- [Maxar Open Data in CSV, GeoJSON, and MosaicJSON formats](https://github.com/giswqs/maxar-open-data)\n",
- "\n",
- "This notebook shows how to visualize and download the Maxar Open Data for the 2023 Turkey Earthquake using leafmap.\n",
- "\n",
- "First, install libraries and import modules."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install -U leafmap geopandas"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "import geopandas as gpd"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Retrieve all collections from the Maxar Open Data STAC catalog. Each collection represents a single event."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.maxar_collections()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "The collection ID for the 2023 Turkey Earthquake is `Kahramanmaras-turkey-earthquake-23`. We can get the footprints ([geojson](https://github.com/giswqs/maxar-open-data/blob/master/datasets/Kahramanmaras-turkey-earthquake-23.geojson), [tsv](https://github.com/giswqs/maxar-open-data/blob/master/datasets/Kahramanmaras-turkey-earthquake-23.tsv)) of the event from the [Maxar Open Data GitHub repo](https://github.com/giswqs/maxar-open-data):"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "collection = \"Kahramanmaras-turkey-earthquake-23\"\n",
- "url = leafmap.maxar_collection_url(collection, dtype=\"geojson\")\n",
- "url"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Let's find out how many images are available for the event:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = gpd.read_file(url)\n",
- "print(f\"Total number of images: {len(gdf)}\")\n",
- "gdf.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Visualize the footprints of the images on the map:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_gdf(gdf, layer_name=\"Footprints\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "The earthquake started on February 6, 2023. We can use the `start_date` and `end_date` parameters to filter the images by date. Set `end_date` to `2023-02-06` to get all images captured before the earthquake:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "pre_gdf = leafmap.maxar_search(collection, end_date=\"2023-02-06\")\n",
- "print(f\"Total number of pre-event images: {len(pre_gdf)}\")\n",
- "pre_gdf.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Set the `start_date` to `2023-02-06` to get all images captured after the earthquake:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "post_gdf = leafmap.maxar_search(collection, start_date=\"2023-02-06\")\n",
- "print(f\"Total number of post-event images: {len(post_gdf)}\")\n",
- "post_gdf.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Visualize the pre-event and post-event image footprints on the map. The red footprints represent the pre-event images and the blue footprints represent the post-event images:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "pre_style = {\"color\": \"red\", \"fillColor\": \"red\", \"opacity\": 1, \"fillOpacity\": 0.5}\n",
- "m.add_gdf(pre_gdf, layer_name=\"Pre-event\", style=pre_style, info_mode=\"on_click\")\n",
- "m.add_gdf(post_gdf, layer_name=\"Post-event\", info_mode=\"on_click\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "Use the draw tools to select a region of interest (ROI) and get the bounding box coordinates:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "bbox = m.user_roi_bounds()\n",
- "if bbox is None:\n",
- " bbox = [36.8715, 37.5497, 36.9814, 37.6019]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "Search the Maxar Open Data catalog for images within the ROI before the earthquake:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "pre_event = leafmap.maxar_search(collection, bbox=bbox, end_date=\"2023-02-06\")\n",
- "pre_event.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "Search the Maxar Open Data catalog for images within the ROI after the earthquake:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "post_event = leafmap.maxar_search(collection, bbox=bbox, start_date=\"2023-02-06\")\n",
- "post_event.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "Get the catalog id of the pre-event tile, which contain several images. Each of the image has a unique `quadkey`:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "pre_tile = pre_event[\"catalog_id\"].values[0]\n",
- "pre_tile"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "25",
- "metadata": {},
- "source": [
- "Get the catalog id of the post-event tile, which contain several images. Each of the image has a unique `quadkey`:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "post_tile = post_event[\"catalog_id\"].values[0]\n",
- "post_tile"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27",
- "metadata": {},
- "source": [
- "Get the MosaicJSON for the pre-event tile:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "pre_stac = leafmap.maxar_tile_url(collection, pre_tile, dtype=\"json\")\n",
- "pre_stac"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "29",
- "metadata": {},
- "source": [
- "Get the MosaicJSON for the post-event tile:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "30",
- "metadata": {},
- "outputs": [],
- "source": [
- "post_stac = leafmap.maxar_tile_url(collection, post_tile, dtype=\"json\")\n",
- "post_stac"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "31",
- "metadata": {},
- "source": [
- "Create a split map to compare the pre-event and post-event images. Note the the ipyleaflet split map has some bugs ([source](https://github.com/jupyter-widgets/ipyleaflet/issues/1066)), so we will use the folium plotting backend instead."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "32",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "33",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.split_map(\n",
- " left_layer=pre_stac,\n",
- " right_layer=post_stac,\n",
- " left_label=\"Pre-event\",\n",
- " right_label=\"Post-event\",\n",
- ")\n",
- "m.set_center(36.9265, 37.5762, 16)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "34",
- "metadata": {},
- "source": [
- "Get download links for the pre-event and post-event images:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "35",
- "metadata": {},
- "outputs": [],
- "source": [
- "pre_images = pre_event[\"visual\"].tolist()\n",
- "post_images = post_event[\"visual\"].tolist()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "36",
- "metadata": {},
- "source": [
- "Download the pre-event and post-event images:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "37",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.maxar_download(pre_images)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "38",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.maxar_download(post_images)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/70_zonal_stats.ipynb b/examples/notebooks/70_zonal_stats.ipynb
deleted file mode 100644
index 776cb9e557..0000000000
--- a/examples/notebooks/70_zonal_stats.ipynb
+++ /dev/null
@@ -1,206 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/70_zonal_stats.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/70_zonal_stats.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Calculating zonal statistics - summarizing geospatial raster datasets based on vector geometries**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U rasterstats geopandas"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "import geopandas as gpd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "dsm = \"https://open.gishub.org/data/elevation/dsm.tif\"\n",
- "hag = \"https://open.gishub.org/data/elevation/hag.tif\"\n",
- "buildings = \"https://open.gishub.org/data/elevation/buildings.geojson\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_cog_layer(dsm, name=\"DSM\", palette=\"terrain\")\n",
- "m.add_cog_layer(hag, name=\"Height Above Ground\", palette=\"magma\")\n",
- "m.add_geojson(buildings, layer_name=\"Buildings\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = gpd.read_file(buildings)\n",
- "len(gdf)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "The `leafmap.zonal_stats()` function wraps the [`rasterstats.zonal_stats()`](https://pythonhosted.org/rasterstats/index.html) function and performs reprojection if necessary. \n",
- "\n",
- "By default, the zonal_stats function will return the following [statistics](https://pythonhosted.org/rasterstats/manual.html#statistics):\n",
- "\n",
- "* min\n",
- "* max\n",
- "* mean\n",
- "* count\n",
- "* \n",
- "Optionally, these statistics are also available.\n",
- "\n",
- "* sum\n",
- "* std\n",
- "* median\n",
- "* majority\n",
- "* minority\n",
- "* unique\n",
- "* range\n",
- "* nodata"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "stats = leafmap.zonal_stats(gdf, hag, stats=[\"min\", \"max\", \"mean\", \"count\"])\n",
- "len(stats)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "stats[:5]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "stats_geojson = leafmap.zonal_stats(gdf, hag, stats=[\"mean\", \"count\"], geojson_out=True)\n",
- "len(stats_geojson)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "stats_geojson[0]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "stats_gdf = leafmap.zonal_stats(gdf, hag, stats=[\"mean\", \"count\"], gdf_out=True)\n",
- "len(stats_gdf)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "stats_gdf.head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_gdf(stats_gdf, layer_name=\"Zonal Stats\")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/71_aws_s3.ipynb b/examples/notebooks/71_aws_s3.ipynb
deleted file mode 100644
index 0ded5269a7..0000000000
--- a/examples/notebooks/71_aws_s3.ipynb
+++ /dev/null
@@ -1,171 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/71_aws_s3.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/71_aws_s3.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Loading geospatial datasets from an AWS S3 bucket**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U boto3"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "To Be able to run this notebook you'll need to have AWS credential available as environment variables. Uncomment the following lines to set the environment variables."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "# import os\n",
- "# os.environ[\"AWS_ACCESS_KEY_ID\"] = \"YOUR AWS ACCESS ID HERE\"\n",
- "# os.environ[\"AWS_SECRET_ACCESS_KEY\"] = \"YOUR AWS ACCESS KEY HERE\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "In this example, we will use datasets from the [Maxar Open Data Program on AWS](https://registry.opendata.aws/maxar-open-data/)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "BUCKET = \"maxar-opendata\"\n",
- "FOLDER = \"events/Kahramanmaras-turkey-earthquake-23/\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "List all the datasets in the bucket. Specify a file extension to filter the results if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "items = leafmap.s3_list_objects(BUCKET, FOLDER, ext=\".tif\")\n",
- "items[:10]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Visualize raster datasets from the bucket."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_cog_layer(items[2], name=\"Maxar\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Download a raster dataset from the bucket."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.s3_download_file(items[0], outfile=\"maxar.tif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Download a list of raster datasets from the bucket."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.s3_download_files(items[:2], outdir=\"maxar\")"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/72_timelapse.ipynb b/examples/notebooks/72_timelapse.ipynb
deleted file mode 100644
index b4c638954f..0000000000
--- a/examples/notebooks/72_timelapse.ipynb
+++ /dev/null
@@ -1,426 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/72_timelapse.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/72_timelapse.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Creating timelapse animations from satellite imagery timeseries**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install rasterio"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "## Landsat Timelapse\n",
- "\n",
- "Download Landsat imagery covering [Pucallpa, Peru](https://goo.gl/maps/nYGnFAC3zqrFkFWWA) from 1984 to 2022."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/landsat/peru.zip\"\n",
- "leafmap.download_file(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "The downloaded zip file contains 38 Landsat images covering the area. They have been unzipped and saved to the `peru` folder. All GeoTIFF files under the `peru` folder will be used to create the timelapse animation."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "images = \"peru/*.tif\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Each imagery contains four bands, including SWIR1, NIR, Red, and Green. First, let's create a Landsat timelapse using the `SWIR1/NIR/Red` bands."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.create_timelapse(\n",
- " images,\n",
- " out_gif=\"landsat.gif\",\n",
- " bands=[0, 1, 2],\n",
- " fps=10,\n",
- " progress_bar_color=\"blue\",\n",
- " add_text=True,\n",
- " text_xy=(\"3%\", \"3%\"),\n",
- " text_sequence=1984,\n",
- " font_size=20,\n",
- " font_color=\"black\",\n",
- " mp4=False,\n",
- " reduce_size=False,\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.show_image(\"landsat.gif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/BRQAdsB.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Creating another Landsat timelapse using the `NIR/Red/Green` bands."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.create_timelapse(\n",
- " images,\n",
- " out_gif=\"landsat2.gif\",\n",
- " bands=[1, 2, 3],\n",
- " fps=10,\n",
- " progress_bar_color=\"blue\",\n",
- " add_text=True,\n",
- " text_xy=(\"3%\", \"3%\"),\n",
- " text_sequence=1984,\n",
- " font_size=20,\n",
- " font_color=\"black\",\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.show_image(\"landsat2.gif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/Yv2o5Kx.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "You can also create a timelapse using Cloud Optimized GeoTIFF (COG) files hosted on the web. The following example uses some COG files hosted on [GitHub](https://github.com/opengeos/data/tree/main/landsat)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "years = [str(year) for year in range(1985, 2021, 5)]\n",
- "years"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "images = [f\"https://open.gishub.org/data/landsat/{year}.tif\" for year in years]\n",
- "images"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "If the original image size (shape) is too large, you can use the `size` parameter (rows, cols) to resize the image. The following example resizes the image to (300, 550)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.create_timelapse(\n",
- " images,\n",
- " out_gif=\"landsat3.gif\",\n",
- " bands=[0, 1, 2],\n",
- " size=(300, 550),\n",
- " fps=3,\n",
- " progress_bar_color=\"blue\",\n",
- " add_text=True,\n",
- " text_xy=(\"3%\", \"3%\"),\n",
- " text_sequence=years,\n",
- " font_size=20,\n",
- " font_color=\"black\",\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.show_image(\"landsat3.gif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "22",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/4zwh2D5.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "## NAIP Timelapse\n",
- "\n",
- "Download [NAIP](https://naip-usdaonline.hub.arcgis.com/) imagery covering [Valley Spring, North Dakota](https://goo.gl/maps/tb6MbsRtjSqudUrA8) from 2009 to 2020."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/naip/naip.zip\"\n",
- "leafmap.download_file(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "25",
- "metadata": {},
- "source": [
- "The downloaded zip file contains 10 NAIP images covering the area. All GeoTIFF files under the `naip` folder will be used to create the timelapse animation."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "images = \"naip/*.tif\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27",
- "metadata": {},
- "source": [
- "The images cover the area from 2009 to 2020 annually except 2011 and 2013. Each image contains four bands, including Red, Green, Blue, and NIR."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "text_sequence = [str(year) for year in range(2009, 2021)]\n",
- "text_sequence.remove(\"2011\")\n",
- "text_sequence.remove(\"2013\")\n",
- "text_sequence"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "29",
- "metadata": {},
- "source": [
- "Creating a timelapse using the `Red/Green/Blue` bands."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "30",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.create_timelapse(\n",
- " images,\n",
- " out_gif=\"naip.gif\",\n",
- " bands=[0, 1, 2],\n",
- " fps=3,\n",
- " add_progress_bar=True,\n",
- " progress_bar_color=\"blue\",\n",
- " add_text=True,\n",
- " text_xy=(\"4%\", \"4%\"),\n",
- " text_sequence=text_sequence,\n",
- " font_size=30,\n",
- " font_color=\"white\",\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "31",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.show_image(\"naip.gif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "32",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/mFFCa63.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "33",
- "metadata": {},
- "source": [
- "Creating a timelapse using the `NIR/Red/Green` bands."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "34",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.create_timelapse(\n",
- " images,\n",
- " out_gif=\"naip2.gif\",\n",
- " bands=[3, 0, 1],\n",
- " fps=3,\n",
- " add_progress_bar=True,\n",
- " progress_bar_color=\"blue\",\n",
- " add_text=True,\n",
- " text_xy=(\"4%\", \"4%\"),\n",
- " text_sequence=text_sequence,\n",
- " font_size=30,\n",
- " font_color=\"white\",\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "35",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.show_image(\"naip2.gif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "36",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/KP5MQt2.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/73_custom_stac.ipynb b/examples/notebooks/73_custom_stac.ipynb
deleted file mode 100644
index 329f1647d4..0000000000
--- a/examples/notebooks/73_custom_stac.ipynb
+++ /dev/null
@@ -1,227 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/73_custom_stac.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/73_custom_stac.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Searching Geospatial Data Interactively with Custom STAC API Endpoints**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Provide custom STAC API endpoints as a dictionary in the format of `{\"name\": \"url\"}`. The name will show up in the dropdown menu, while the url is the STAC API endpoint that will be used to search for items."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "catalogs = {\n",
- " \"Element84 Earth Search\": \"https://earth-search.aws.element84.com/v1\",\n",
- " \"Microsoft Planetary Computer\": \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n",
- "}"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Create an interactive map and click on the catalog button as shown below to open the catalog panel. Be sure to specify the `catalog_source` parameter during the map creation."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/IrnRrcF.png)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4, catalog_source=catalogs)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Alternatively, you can also use the `Map.set_catalog_source` method to specify the custom API endpoints."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4)\n",
- "m.set_catalog_source(catalogs)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Another way to specify STAC API endpoints is to set the environment variable `STAC_CATALOGS` to a dictionary in the format of `{\"name\": \"url\"}`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "os.environ[\"STAC_CATALOGS\"] = str(catalogs)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Then, you can create an interactive map as usual and click on the catalog button to open the catalog panel."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "The STAC GUI can also be open directly by calling the `stac_gui()` function."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap.toolbar import stac_gui"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "stac_gui(m)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "Once the catalog panel is open, you can search for items from the custom STAC API endpoints. Simply draw a bounding box on the map or zoom to a location of interest. Click on the **Collections** button to retrieve the collections from the custom STAC API endpoints. Next, select a collection from the dropdown menu. Then, click on the **Items** button to retrieve the items from the selected collection. Finally, click on the **Display** button to add the selected item to the map."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/iv0f6aK.png)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.stac_gdf # The GeoDataFrame of the STAC search results"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.stac_dict # The STAC search results as a dictionary"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.stac_item # The selected STAC item of the search result"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/74_map_tiles_to_geotiff.ipynb b/examples/notebooks/74_map_tiles_to_geotiff.ipynb
deleted file mode 100644
index 4caafb9310..0000000000
--- a/examples/notebooks/74_map_tiles_to_geotiff.ipynb
+++ /dev/null
@@ -1,133 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/74_map_tiles_to_geotiff.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/74_map_tiles_to_geotiff.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Downloading maps tiles and converting them to a GeoTIFF file**\n",
- "\n",
- "Disclaimer: The `leafmap.map_tiles_to_geotiff()` function is adapted from the [tms2geotiff](https://github.com/gumblex/tms2geotiff) repo. Credit goes to the GitHub user @gumblex.\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Use the drawing tools to draw a rectangle on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "if m.user_roi is not None:\n",
- " bbox = m.user_roi_bounds()\n",
- "else:\n",
- " bbox = [-122.5216, 37.733, -122.3661, 37.8095]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Download map tiles and create a GeoTIFF file. First, let's try Esri world imagery basemap."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.map_tiles_to_geotiff(\"satellite.tif\", bbox, zoom=13, source=\"Esri.WorldImagery\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/ILYunA9.png)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.map_tiles_to_geotiff(\"topo.tif\", bbox, zoom=13, source=\"OpenTopoMap\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/4UkUZKw.png)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/75_segment_anything.ipynb b/examples/notebooks/75_segment_anything.ipynb
deleted file mode 100644
index 8ed0e450d5..0000000000
--- a/examples/notebooks/75_segment_anything.ipynb
+++ /dev/null
@@ -1,339 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "# Segment Anything Model for Geospatial Data \n",
- "\n",
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/75_segment_anything.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/75_segment_anything.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "This notebook shows how to use segment satellite imagery using the Segment Anything Model (SAM) with a few lines of code. \n",
- "\n",
- "Make sure you use GPU runtime for this notebook. For Google Colab, go to `Runtime` -> `Change runtime type` and select `GPU` as the hardware accelerator."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "1",
- "metadata": {},
- "source": [
- "## Install dependencies\n",
- "\n",
- "Uncomment and run the following cell to install the required dependencies."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install segment-geospatial localtileserver"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "## Import libraries"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap\n",
- "from samgeo import SamGeo, tms_to_geotiff, get_basemaps"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "## Create an interactive map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[29.676840, -95.369222], zoom=19)\n",
- "m.add_basemap(\"SATELLITE\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Pan and zoom the map to select the area of interest. Use the draw tools to draw a polygon or rectangle on the map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "if m.user_roi_bounds() is not None:\n",
- " bbox = m.user_roi_bounds()\n",
- "else:\n",
- " bbox = [-95.3704, 29.6762, -95.368, 29.6775]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "## Download map tiles\n",
- "\n",
- "Download maps tiles and mosaic them into a single GeoTIFF file"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "image = \"satellite.tif\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Besides the `satellite` basemap, you can use any of the following basemaps returned by the `get_basemaps()` function:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "# get_basemaps().keys()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Specify the basemap as the source."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "tms_to_geotiff(output=image, bbox=bbox, zoom=20, source=\"Satellite\", overwrite=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "You can also use your own image. Uncomment and run the following cell to use your own image."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "# image = '/path/to/your/own/image.tif'"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "Display the downloaded image on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.layers[-1].visible = False # turn off the basemap\n",
- "m.add_raster(image, layer_name=\"Image\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "20",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/KAm84IY.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "## Initialize SAM class"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "sam = SamGeo(\n",
- " model_type=\"vit_h\",\n",
- " checkpoint=\"sam_vit_h_4b8939.pth\",\n",
- " sam_kwargs=None,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "## Segment the image\n",
- "\n",
- "Set `batch=True` to segment the image in batches. This is useful for large images that cannot fit in memory."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "mask = \"segment.tif\"\n",
- "sam.generate(\n",
- " image, mask, batch=True, foreground=True, erosion_kernel=(3, 3), mask_multiplier=255\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "25",
- "metadata": {},
- "source": [
- "## Polygonize the raster data\n",
- "\n",
- "Save the segmentation results as a GeoPackage file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "vector = \"segment.gpkg\"\n",
- "sam.tiff_to_gpkg(mask, vector, simplify_tolerance=None)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27",
- "metadata": {},
- "source": [
- "You can also save the segmentation results as any vector data format supported by GeoPandas."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "shapefile = \"segment.shp\"\n",
- "sam.tiff_to_vector(mask, shapefile)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "29",
- "metadata": {},
- "source": [
- "## Visualize the results"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "30",
- "metadata": {},
- "outputs": [],
- "source": [
- "style = {\n",
- " \"color\": \"#3388ff\",\n",
- " \"weight\": 2,\n",
- " \"fillColor\": \"#7c4185\",\n",
- " \"fillOpacity\": 0.5,\n",
- "}\n",
- "m.add_vector(vector, layer_name=\"Vector\", style=style)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "31",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/Ysq3u7E.png)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/76_image_comparison.ipynb b/examples/notebooks/76_image_comparison.ipynb
deleted file mode 100644
index c04043b552..0000000000
--- a/examples/notebooks/76_image_comparison.ipynb
+++ /dev/null
@@ -1,93 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/76_image_comparison.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/76_image_comparison.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Comparing images with an interactive slider**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed.\n",
- "\n",
- "Note that the `image_comparison` will only work with Jupyter Notebook or JupyterLab. It seems not working with Visual Studio Code."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "img1 = \"https://open.gishub.org/data/images/berkeley.jpg\"\n",
- "img2 = \"https://open.gishub.org/data/images/berkeley_sam.jpg\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "The labels might not show up the first time. Try running the code block again to show the labels."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.image_comparison(\n",
- " img1,\n",
- " img2,\n",
- " label1=\"Satellite Image\",\n",
- " label2=\"Image Segmentation\",\n",
- " starting_position=50,\n",
- " out_html=\"image_comparison.html\",\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/Ega3y5d.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/77_split_raster.ipynb b/examples/notebooks/77_split_raster.ipynb
deleted file mode 100644
index 1a8b38203d..0000000000
--- a/examples/notebooks/77_split_raster.ipynb
+++ /dev/null
@@ -1,120 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/77_split_raster.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/77_split_raster.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create an interactive map and add a raster layer to it."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://open.gishub.org/data/raster/cog.tif\"\n",
- "m.add_cog_layer(url, name=\"COG\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Split the raster layer into multiple tiles."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_raster(url, out_dir=\"tiles\", tile_size=(100, 100), overlap=0)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Show the tiles."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.find_files(\"tiles\", ext=\".tif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Merge the tiles into a single raster dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.merge_rasters(\"tiles\", output=\"merged.tif\", input_pattern=\"*.tif\")"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/78_read_raster.ipynb b/examples/notebooks/78_read_raster.ipynb
deleted file mode 100644
index 830b4042b5..0000000000
--- a/examples/notebooks/78_read_raster.ipynb
+++ /dev/null
@@ -1,456 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/78_read_raster.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/78_read_raster.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Interactive Extraction and Visualization of AWS Open Geospatial Data**\n",
- "\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Set custom STAC endpoints."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "catalogs = {\n",
- " \"Element84 Earth Search\": \"https://earth-search.aws.element84.com/v1\",\n",
- " \"Microsoft Planetary Computer\": \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n",
- "}"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Display the STAC search GUI. Pan and zoom to the area of interest and use the drawing tools to draw a bounding box or polygon. Select a STAC catalog and click the **Collections** button to retrieve the collections, then click on the **Items** button to retrieve the items within the bounding box or polygon. Select an item from the dropdown list and click the **Display** button to display the item on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[37.7452, -122.4108], zoom=12, catalog_source=catalogs)\n",
- "m.add(\"stac\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Display the information of the selected item."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.stac_item"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Alternatively, you can search the STAC catalog programmatically by providing a bounding box, time range, and other filters. The example below use the [Earth Search](https://stacindex.org/catalogs/earth-search#/) STAC endpoint by Element 84 for searching for AWS Open Data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://earth-search.aws.element84.com/v1/\"\n",
- "collection = \"sentinel-2-l2a\"\n",
- "time_range = \"2023-04-01/2023-07-31\"\n",
- "bbox = [-122.491, 37.7208, -122.411, 37.7786]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Search the STAC catalog and return the results as an ItemCollection."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=5,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " query={\"eo:cloud_cover\": {\"lt\": 10}},\n",
- " get_collection=True,\n",
- ")\n",
- "# search"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Search the STAC catalog and return the results as a dictionary of assets."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=5,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " query={\"eo:cloud_cover\": {\"lt\": 10}},\n",
- " get_assets=True,\n",
- ")\n",
- "# search"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Get the first item in the collection."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "name, item = next(iter(search.items()))\n",
- "name"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "Retrieve the item's assets, which are links to the actual data files."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "item"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "Retrieve the STAT item's URLs."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=5,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " query={\"eo:cloud_cover\": {\"lt\": 10}},\n",
- " get_links=True,\n",
- ")\n",
- "search"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "Check the band names of the selected item."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = search[0]\n",
- "bands = leafmap.stac_bands(url)\n",
- "bands[:10]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "Display the selected item on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_stac_layer(url, bands=[\"nir\", \"red\", \"green\"], name=\"Sentinel-2\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "25",
- "metadata": {},
- "source": [
- "Use the drawing tools to draw a small bounding box on the image."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "if m.user_roi is not None:\n",
- " roi = m.user_roi_bounds()\n",
- "else:\n",
- " roi = [-122.5315, 37.6882, -122.3523, 37.8166]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27",
- "metadata": {},
- "source": [
- "Specify the bands to use."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "bands = [\"nir\", \"red\", \"green\"]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "29",
- "metadata": {},
- "source": [
- "Display the COG URL."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "30",
- "metadata": {},
- "outputs": [],
- "source": [
- "item[\"nir\"]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "31",
- "metadata": {},
- "source": [
- "Extract one single band within the bounding box as an a numpy array."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "32",
- "metadata": {},
- "outputs": [],
- "source": [
- "array = leafmap.read_raster(item[\"nir\"], window=roi, coord_crs=\"epsg:4326\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "33",
- "metadata": {},
- "source": [
- "Check the shape of the array."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "34",
- "metadata": {},
- "outputs": [],
- "source": [
- "array.shape"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "35",
- "metadata": {},
- "source": [
- "Extract multiple bands within the bounding box as an a numpy array."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "36",
- "metadata": {},
- "outputs": [],
- "source": [
- "sources = [item[\"nir\"], item[\"red\"], item[\"green\"]]\n",
- "array = leafmap.read_rasters(sources, window=roi, coord_crs=\"epsg:4326\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "37",
- "metadata": {},
- "source": [
- "Check the shape of the array."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "38",
- "metadata": {},
- "outputs": [],
- "source": [
- "array.shape"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "39",
- "metadata": {},
- "source": [
- "Convert the numpy array to a Cloud Optimized GeoTIFF (COG)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "40",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.numpy_to_cog(\n",
- " array, \"s2.tif\", bounds=roi, profile=item[\"nir\"], coord_crs=\"epsg:4326\"\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "41",
- "metadata": {},
- "source": [
- "Display the image on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "42",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(\"s2.tif\", band=[1, 2, 3], vmin=0, vmax=4000, layer_name=\"Subset\")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/79_timeseries.ipynb b/examples/notebooks/79_timeseries.ipynb
deleted file mode 100644
index 312e34cf39..0000000000
--- a/examples/notebooks/79_timeseries.ipynb
+++ /dev/null
@@ -1,101 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/79_timeseries.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/79_timeseries.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Visualizing time series images interactively with a time slider**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Download sample data [here](https://open.gishub.org/data/landsat/timeseries.zip)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/landsat/timeseries.zip\"\n",
- "leafmap.download_file(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Visualize time series images interactively with a time slider. You can pass a list of file paths or a string representing a directory to the `add_time_slider` function."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "images = \"landsat\"\n",
- "m.add_time_slider(\n",
- " images,\n",
- " time_interval=0.5,\n",
- " position=\"bottomright\",\n",
- " band=[1, 2, 3],\n",
- " zoom_to_layer=True,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/mufTpVD.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/80_solar.ipynb b/examples/notebooks/80_solar.ipynb
deleted file mode 100644
index 1174001b75..0000000000
--- a/examples/notebooks/80_solar.ipynb
+++ /dev/null
@@ -1,161 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/80_solar.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/80_solar.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Set Google API key. Get one from https://developers.google.com/maps/documentation/solar/get-api-key\n",
- "\n",
- "You also need to enable the Google Solar API at https://console.cloud.google.com/google/maps-apis/api-list"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "os.environ[\"GOOGLE_API_KEY\"] = \"YOUR-API-KEY\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Set download directory."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_dir = os.path.expanduser(\"~/Downloads\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Download Solar data from Google's [Solar API](https://developers.google.com/maps/documentation/solar)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "lat = 50.97579908646006\n",
- "lon = 11.023334842349778\n",
- "radiusMeters = 50\n",
- "view = \"FULL_LAYERS\"\n",
- "requiredQuality = \"HIGH\"\n",
- "pixelSizeMeters = 0.1"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "files = leafmap.get_solar_data(\n",
- " lat, lon, radiusMeters, view, requiredQuality, pixelSizeMeters, out_dir=out_dir\n",
- ")\n",
- "files"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Create an interactive map and add the Solar data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(files[\"rgb\"], layer_name=\"RGB\")\n",
- "m.add_raster(files[\"mask\"], layer_name=\"Mask\")\n",
- "m.add_raster(files[\"dsm\"], colormap=\"terrain\", layer_name=\"DSM\", visible=False)\n",
- "m.add_raster(files[\"annualFlux\"], colormap=\"plasma\", layer_name=\"annualFlux\")\n",
- "m.add_raster(\n",
- " files[\"monthlyFlux\"],\n",
- " colormap=\"plasma\",\n",
- " band=[7],\n",
- " layer_name=\"monthlyFlux\",\n",
- " visible=False,\n",
- ")\n",
- "\n",
- "m.add_colormap(cmap=\"terrain\", vmin=190, vmax=250, label=\"Elevation (m)\")\n",
- "m.add_colormap(cmap=\"plasma\", vmin=500, vmax=1000, label=\"Annual flux (kWh/kW/year)\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/XZ1i8O6.png)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/81_buildings.ipynb b/examples/notebooks/81_buildings.ipynb
deleted file mode 100644
index d6b0920622..0000000000
--- a/examples/notebooks/81_buildings.ipynb
+++ /dev/null
@@ -1,185 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/81_buildings.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/81_buildings.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Downloading Microsoft and Google Building Footprints**\n",
- "\n",
- "This notebook demonstrates how to download Microsoft and Google Building Footprints and merge them into a single vector file.\n",
- "\n",
- "- Microsoft Global Building Footprints: https://github.com/microsoft/GlobalMLBuildingFootprints\n",
- "- Google Open Buildings: https://sites.research.google/open-buildings\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap geopandas"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Specify the country name."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "country = \"Libya\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Specify the number of files to download. Set to `None` to download all files."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "head = 2"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Download the Microsoft building footprints."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.download_ms_buildings(\n",
- " country, out_dir=\"buildings\", merge_output=f\"{country}_ms.shp\", head=head\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Display the Microsoft building footprints."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"SATELLITE\")\n",
- "m.add_vector(f\"{country}_ms.shp\", layer_name=\"MS Buildings\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Download the Google building footprints."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.download_google_buildings(\n",
- " country,\n",
- " out_dir=\"buildings\",\n",
- " merge_output=f\"{country}_google.shp\",\n",
- " head=head,\n",
- " overwrite=True,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Display the Google building footprints."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://sites.research.google/open-buildings/tiles.geojson\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"SATELLITE\")\n",
- "m.add_geojson(url, layer_name=\"Google Building Coverage\")\n",
- "m.add_vector(f\"{country}_google.shp\", layer_name=\"Google Buildings\")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/82_pmtiles.ipynb b/examples/notebooks/82_pmtiles.ipynb
deleted file mode 100644
index 7d34610a4d..0000000000
--- a/examples/notebooks/82_pmtiles.ipynb
+++ /dev/null
@@ -1,406 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/82_pmtiles.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/82_pmtiles.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "\n",
- "**Visualizing PMTiles with leafmap**\n",
- "\n",
- "[PMTiles](https://github.com/protomaps/PMTiles) is a single-file archive format for tiled data. A PMTiles archive can be hosted on a commodity storage platform such as S3, and enables low-cost, zero-maintenance map applications that are \"serverless\" - free of a custom tile backend or third party provider.\n",
- "\n",
- "The PMTiles functionality for leafmap is based on the [folium-pmtiles](https://github.com/jtmiclat/folium-pmtiles) package. Credits to [Jt Miclat](https://github.com/jtmiclat)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap pmtiles"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "## Remote PMTiles\n",
- "\n",
- "### Protomaps sample data"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/pmtiles/protomaps_firenze.pmtiles\"\n",
- "metadata = leafmap.pmtiles_metadata(url)\n",
- "print(f\"layer names: {metadata['layer_names']}\")\n",
- "print(f\"bounds: {metadata['bounds']}\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "style = {\n",
- " \"version\": 8,\n",
- " \"sources\": {\n",
- " \"example_source\": {\n",
- " \"type\": \"vector\",\n",
- " \"url\": \"pmtiles://\" + url,\n",
- " \"attribution\": \"PMTiles\",\n",
- " }\n",
- " },\n",
- " \"layers\": [\n",
- " {\n",
- " \"id\": \"buildings\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"landuse\",\n",
- " \"type\": \"fill\",\n",
- " \"paint\": {\"fill-color\": \"steelblue\"},\n",
- " },\n",
- " {\n",
- " \"id\": \"roads\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"roads\",\n",
- " \"type\": \"line\",\n",
- " \"paint\": {\"line-color\": \"black\"},\n",
- " },\n",
- " ],\n",
- "}\n",
- "\n",
- "# style = leafmap.pmtiles_style(url) # Use default style\n",
- "\n",
- "m.add_pmtiles(\n",
- " url, name=\"PMTiles\", style=style, overlay=True, show=True, zoom_to_layer=True\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "### Overture data"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "You can also visualize Overture data. Inspired by [overture-maps](https://github.com/tebben/overture-maps)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://storage.googleapis.com/ahp-research/overture/pmtiles/overture.pmtiles\"\n",
- "metadata = leafmap.pmtiles_metadata(url)\n",
- "print(f\"layer names: {metadata['layer_names']}\")\n",
- "print(f\"bounds: {metadata['bounds']}\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(height=\"800px\")\n",
- "m.add_basemap(\"CartoDB.DarkMatter\")\n",
- "\n",
- "style = {\n",
- " \"version\": 8,\n",
- " \"sources\": {\n",
- " \"example_source\": {\n",
- " \"type\": \"vector\",\n",
- " \"url\": \"pmtiles://\" + url,\n",
- " \"attribution\": \"PMTiles\",\n",
- " }\n",
- " },\n",
- " \"layers\": [\n",
- " {\n",
- " \"id\": \"admins\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"admins\",\n",
- " \"type\": \"fill\",\n",
- " \"paint\": {\"fill-color\": \"#BDD3C7\", \"fill-opacity\": 0.1},\n",
- " },\n",
- " {\n",
- " \"id\": \"buildings\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"buildings\",\n",
- " \"type\": \"fill\",\n",
- " \"paint\": {\"fill-color\": \"#FFFFB3\", \"fill-opacity\": 0.5},\n",
- " },\n",
- " {\n",
- " \"id\": \"places\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"places\",\n",
- " \"type\": \"fill\",\n",
- " \"paint\": {\"fill-color\": \"#BEBADA\", \"fill-opacity\": 0.5},\n",
- " },\n",
- " {\n",
- " \"id\": \"roads\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"roads\",\n",
- " \"type\": \"line\",\n",
- " \"paint\": {\"line-color\": \"#FB8072\"},\n",
- " },\n",
- " ],\n",
- "}\n",
- "\n",
- "# style = leafmap.pmtiles_style(url) # Use default style\n",
- "\n",
- "m.add_pmtiles(\n",
- " url, name=\"PMTiles\", style=style, overlay=True, show=True, zoom_to_layer=True\n",
- ")\n",
- "\n",
- "legend_dict = {\n",
- " \"admins\": \"BDD3C7\",\n",
- " \"buildings\": \"FFFFB3\",\n",
- " \"places\": \"BEBADA\",\n",
- " \"roads\": \"FB8072\",\n",
- "}\n",
- "\n",
- "m.add_legend(legend_dict=legend_dict)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "### Source Cooperative\n",
- "\n",
- "[Google-Microsoft Open Buildings - combined by VIDA](https://beta.source.coop/repositories/vida/google-microsoft-open-buildings/description)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://data.source.coop/vida/google-microsoft-open-buildings/pmtiles/go_ms_building_footprints.pmtiles\"\n",
- "metadata = leafmap.pmtiles_metadata(url)\n",
- "print(f\"layer names: {metadata['layer_names']}\")\n",
- "print(f\"bounds: {metadata['bounds']}\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[20, 0], zoom=2, height=\"800px\")\n",
- "m.add_basemap(\"CartoDB.DarkMatter\")\n",
- "m.add_basemap(\"Esri.WorldImagery\", show=False)\n",
- "\n",
- "style = {\n",
- " \"version\": 8,\n",
- " \"sources\": {\n",
- " \"example_source\": {\n",
- " \"type\": \"vector\",\n",
- " \"url\": \"pmtiles://\" + url,\n",
- " \"attribution\": \"PMTiles\",\n",
- " }\n",
- " },\n",
- " \"layers\": [\n",
- " {\n",
- " \"id\": \"buildings\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"building_footprints\",\n",
- " \"type\": \"fill\",\n",
- " \"paint\": {\"fill-color\": \"#3388ff\", \"fill-opacity\": 0.5},\n",
- " },\n",
- " ],\n",
- "}\n",
- "\n",
- "# style = leafmap.pmtiles_style(url) # Use default style\n",
- "\n",
- "m.add_pmtiles(\n",
- " url, name=\"Buildings\", style=style, overlay=True, show=True, zoom_to_layer=False\n",
- ")\n",
- "\n",
- "html = \"Source: source.coop\"\n",
- "m.add_html(html, position=\"bottomright\")\n",
- "\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.save(\"buildings.html\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "## Local PMTiles\n",
- "\n",
- "tippecanoe is required to convert vector data to pmtiles. Install it with `conda install -c conda-forge tippecanoe`.\n",
- "\n",
- "Download [building footprints](https://github.com/opengeos/open-data/blob/main/datasets/libya/Derna_buildings.geojson) of Derna, Libya."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://raw.githubusercontent.com/opengeos/open-data/main/datasets/libya/Derna_buildings.geojson\"\n",
- "leafmap.download_file(url, \"buildings.geojson\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "Convert vector to PMTiles."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "pmtiles = \"buildings.pmtiles\"\n",
- "leafmap.geojson_to_pmtiles(\n",
- " \"buildings.geojson\", pmtiles, layer_name=\"buildings\", overwrite=True, quiet=True\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "Start a HTTP Sever"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.start_server(port=8000)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = f\"http://127.0.0.1:8000/{pmtiles}\"\n",
- "# leafmap.pmtiles_metadata(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "Display the PMTiles on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "style = {\n",
- " \"version\": 8,\n",
- " \"sources\": {\n",
- " \"example_source\": {\n",
- " \"type\": \"vector\",\n",
- " \"url\": \"pmtiles://\" + url,\n",
- " \"attribution\": \"PMTiles\",\n",
- " }\n",
- " },\n",
- " \"layers\": [\n",
- " {\n",
- " \"id\": \"buildings\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"buildings\",\n",
- " \"type\": \"fill\",\n",
- " \"paint\": {\"fill-color\": \"#3388ff\", \"fill-opacity\": 0.5},\n",
- " },\n",
- " ],\n",
- "}\n",
- "\n",
- "# style = leafmap.pmtiles_style(url) # Use default style\n",
- "\n",
- "m.add_pmtiles(url, name=\"Buildings\", show=True, zoom_to_layer=True, style=style)\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/83_vector_viz.ipynb b/examples/notebooks/83_vector_viz.ipynb
deleted file mode 100644
index 3b9029bba0..0000000000
--- a/examples/notebooks/83_vector_viz.ipynb
+++ /dev/null
@@ -1,196 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/83_vector_viz.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/83_vector_viz.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Visualizing large vector datasets with lonboard**\n",
- "\n",
- "This notebook demonstrates how to visualize large vector datasets with [lonboard](https://github.com/developmentseed/lonboard). Please note that lonboard does not support Visual Studio Code's interactive notebook yet. You will need to run this notebook in Jupyter Notebook or JupyterLab.\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap lonboard"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.deckgl as leafmap\n",
- "import geopandas as gpd\n",
- "import ipywidgets as widgets"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Download sample datasets."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/duckdb/nyc_data.zip\"\n",
- "leafmap.download_file(url, unzip=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[20, 0], zoom=1.2)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Add GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "streets = gpd.read_file(\"nyc_streets.shp\")\n",
- "m.add_gdf(streets, zoom_to_layer=True, pickable=True, get_width=5)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Add any vector format supported by GeoPandas."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_vector(\"nyc_subway_stations.shp\", get_radius=10, get_fill_color=[255, 0, 0, 180])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Change layer properties."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "layer = m.layers[-1]\n",
- "layer.get_fill_color = [0, 0, 255, 255]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Interactive widgets."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "color = widgets.ColorPicker(value=\"red\", description=\"Color\")\n",
- "width = widgets.IntSlider(min=1, max=100, value=10, description=\"Radius\")\n",
- "hbox = widgets.HBox([color, width])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "widgets.dlink((color, \"value\"), (layer, \"get_fill_color\"))\n",
- "widgets.dlink((width, \"value\"), (layer, \"get_radius\"))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "hbox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/84_read_parquet.ipynb b/examples/notebooks/84_read_parquet.ipynb
deleted file mode 100644
index 2260561f26..0000000000
--- a/examples/notebooks/84_read_parquet.ipynb
+++ /dev/null
@@ -1,250 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/84_read_parquet.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/84_read_parquet.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Reading GeoParquet files and visualizing vector data interactively**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap lonboard==0.3.0"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Visualizing point data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/duckdb/cities.parquet\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Read GeoParquet and return a GeoPandas GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = leafmap.read_parquet(url, return_type=\"gdf\", src_crs=\"EPSG:4326\")\n",
- "gdf.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "View the GeoDataFrame interactively using folium."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf.explore()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Visualize the GeoDataFrame using lonboard."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.view_vector(gdf, get_radius=20000, get_fill_color=\"blue\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Visualizing polygon data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://data.source.coop/giswqs/nwi/wetlands/DC_Wetlands.parquet\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = leafmap.read_parquet(\n",
- " url, return_type=\"gdf\", src_crs=\"EPSG:5070\", dst_crs=\"EPSG:4326\"\n",
- ")\n",
- "gdf.head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf.explore()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.view_vector(gdf, get_fill_color=[0, 0, 255, 128])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "![vector](https://i.imgur.com/HRtpiVd.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "Alternatively, you can specify a color map to visualize the data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "color_map = {\n",
- " \"Freshwater Forested/Shrub Wetland\": (0, 136, 55),\n",
- " \"Freshwater Emergent Wetland\": (127, 195, 28),\n",
- " \"Freshwater Pond\": (104, 140, 192),\n",
- " \"Estuarine and Marine Wetland\": (102, 194, 165),\n",
- " \"Riverine\": (1, 144, 191),\n",
- " \"Lake\": (19, 0, 124),\n",
- " \"Estuarine and Marine Deepwater\": (0, 124, 136),\n",
- " \"Other\": (178, 134, 86),\n",
- "}"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.view_vector(gdf, color_column=\"WETLAND_TYPE\", color_map=color_map, opacity=0.5)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "20",
- "metadata": {},
- "source": [
- "![vector-color](https://i.imgur.com/Ejh8hK6.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "Display a legend for the data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.Legend(title=\"Wetland Type\", legend_dict=color_map)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "![legend](https://i.imgur.com/fxzHHFN.png)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/85_gedi.ipynb b/examples/notebooks/85_gedi.ipynb
deleted file mode 100644
index 3da76079c4..0000000000
--- a/examples/notebooks/85_gedi.ipynb
+++ /dev/null
@@ -1,292 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/85_gedi.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/85_gedi.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**How to search and download GEDI L4A dataset interactively**\n",
- "\n",
- "This notebook shows how to search and download the [GEDI L4A dataset](https://daac.ornl.gov/cgi-bin/dsviewer.pl?ds_id=2056) using [leafmap](https://leafmap.org). The source code is adapted from the [gedi_tutorials](https://github.com/ornldaac/gedi_tutorials) repository but has been greatly simplified. Credit goes to ORNL DAAC and [Rupesh Shrestha](https://github.com/rupesh2).\n",
- "\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U \"leafmap[vector]\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(height=600)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Use the draw tool to draw a rectangle on the map. If no rectangle is drawn, the default bounding box will be used."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "if m.user_roi is not None:\n",
- " roi = m.user_roi_bounds()\n",
- "else:\n",
- " roi = [-73.9872, -33.7683, -34.7299, 5.2444]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Specify the start and end date."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "start_date = \"2020-07-01\"\n",
- "end_date = \"2020-07-31\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Search and download GEDI L4A dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = leafmap.gedi_search(roi, start_date, end_date, add_roi=False, sort_filesize=True)\n",
- "gdf.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Visualize the GEDI L4A dataset footprints."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_gdf(gdf, layer_name=\"GEDI footprints\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Download the GEDI L4A dataset from NASA EarthData website. You need to register an account first if you don't have one. Create an account at https://urs.earthdata.nasa.gov. Then return to this notebook and uncomment the following code cell to set your username and password."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "# import os\n",
- "# os.environ[\"EARTHDATA_USERNAME\"] = \"your_username\"\n",
- "# os.environ[\"EARTHDATA_PASSWORD\"] = \"your_password\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.gedi_download_files(gdf.head(), outdir=\"data\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "Read the downloaded GEDI L4A dataset as a GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " gdf = leafmap.h5_to_gdf(\n",
- " \"data/*.h5\", dataset=\"BEAM0110\", columns=[\"agbd\"], nodata=-9999\n",
- " )\n",
- "except:\n",
- " # Download the sample data if the above code fails\n",
- " gdf = leafmap.geojson_to_gdf(\n",
- " \"https://github.com/opengeos/data/releases/download/v1.0.0/gedi_sample.geojson\"\n",
- " )\n",
- "gdf.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "We can subset the GeoDataFrame by a bounding box. First, create an interactive map and add the bounding box to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(height=620)\n",
- "roi = [-38.8641, -6.8664, -37.2107, -6.359]\n",
- "bbox = leafmap.bbox_to_gdf(roi)\n",
- "m.add_gdf(bbox, layer_name=\"ROI\", zoom_to_layer=True, info_mode=None)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "20",
- "metadata": {},
- "source": [
- "Use the bounding box to subset the GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "subset = leafmap.filter_bounds(gdf, roi, within=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "22",
- "metadata": {},
- "source": [
- "Add the subsetted GeoDataFrame to the map. Note that this is only for visualizing a small subset of the data. If you want to work with the entire dataset, you can skip this step."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "23",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_data(subset, column=\"agbd\", cmap=\"Greens\", marker_radius=5)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "24",
- "metadata": {},
- "source": [
- "Visualize the GEDI L4A Aboveground Biomass Density (AGBD) data with lonboard."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.view_vector(\n",
- " gdf, color_column=\"agbd\", color_map=\"Greens\", color_k=10, get_radius=25\n",
- ")"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/86_add_markers.ipynb b/examples/notebooks/86_add_markers.ipynb
deleted file mode 100644
index e545be9e80..0000000000
--- a/examples/notebooks/86_add_markers.ipynb
+++ /dev/null
@@ -1,183 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/86_add_markers.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/86_add_markers.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Adding markers to the map**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U \"leafmap[vector]\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Add a simple marker to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_markers(markers=[40, -100], shape=\"marker\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Add circle markers to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_markers(markers=[[40, -100], [35, -110]], shape=\"circle\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Customize circle markers."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_markers(\n",
- " markers=[[40, -100], [35, -110]],\n",
- " shape=\"circle\",\n",
- " radius=20,\n",
- " color=\"red\",\n",
- " fill_color=\"#3388ff\",\n",
- " fill_opacity=0.5,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/pKfZrdd.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Add country polygons to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "countries = \"https://open.gishub.org/data/world/countries.geojson\"\n",
- "m.add_geojson(countries, layer_name=\"Countries\", info_mode=None)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Add circle markers with popups to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/world/world_cities.geojson\"\n",
- "m.add_data(url, column=\"population\", cmap=\"Blues\", marker_radius=5, layer_name=\"Cities\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/ZGwInmO.png)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/87_actinia.ipynb b/examples/notebooks/87_actinia.ipynb
deleted file mode 100644
index 01af645bfe..0000000000
--- a/examples/notebooks/87_actinia.ipynb
+++ /dev/null
@@ -1,520 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/87_actinia.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/87_actinia.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Cloud-based geoprocessing with Actinia**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "The cloud based geoprocessing platform [actinia](https://github.com/actinia-org) is able to ingest and analyse large volumes of geodata in the cloud.\n",
- "\n",
- "For the following actinia example we use the [actinia-python-client](https://actinia-org.github.io/actinia-python-client/) ([source code](https://github.com/actinia-org/actinia-python-client)) to establish the connection to an actinia instance. \n",
- "First install the actinia-python-client (for latest version, see [actinia-python-client releases](https://github.com/actinia-org/actinia-python-client/releases))."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "%pip install actinia_python_client"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "The results of [actinia](https://actinia.mundialis.de/) ephemeral processing are available via object storage as GeoTIFF/COG or GeoPackage files."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "Add a helper function for \"pretty printing\" of actinia results:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "from json import dumps as json_dumps\n",
- "\n",
- "\n",
- "def print_dict(input_dict, text=None):\n",
- " if text:\n",
- " print(text)\n",
- " if \"region\" in input_dict:\n",
- " input_dict[\"region\"] = input_dict[\"region\"].__dict__\n",
- " print(json_dumps(input_dict, sort_keys=True, indent=4))\n",
- "\n",
- "\n",
- "def print_dict_keys(input_dict, text=None):\n",
- " if text:\n",
- " print(text)\n",
- " print(\", \".join(input_dict.keys()))"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Connect to the default actinia server which is defined in the actinia-python-client, currently https://actinia.mundialis.de."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "# connect to the actinia server\n",
- "from actinia import Actinia\n",
- "\n",
- "# connect to default actinia server (https://actinia.mundialis.de)\n",
- "actinia_mundialis = Actinia()\n",
- "\n",
- "# retrieve metadata about actinia server and related software versions\n",
- "version = actinia_mundialis.get_version()\n",
- "print_dict(version, \"Version is:\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "Set the authentication settings of the actinia demo user to gain access to the actinia server functionality."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "actinia_user = \"demouser\"\n",
- "actinia_password = \"gu3st!pa55w0rd\"\n",
- "\n",
- "# we use the default actinia server\n",
- "actinia_mundialis.set_authentication(actinia_user, actinia_password)\n",
- "print(\"Connected to actinia server.\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "Obtain the list of locations and retrieve the metadata of a selected location."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "# obtain the list of projects (called \"locations\") which are accessible to current user\n",
- "locations = actinia_mundialis.get_locations()\n",
- "print_dict_keys(locations, \"Locations: \")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "Retrieve the metadata of a selected location (this shows the respective projection information, spatial extent, resolution, etc.) to get an idea how the output looks like."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "print_dict(actinia_mundialis.locations[\"nc_spm_08\"].get_info(), \"Location info:\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "At this point the connection to the selected actinia server is properly established."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "**Reading the online data resource into the actinia server**"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "Next we demonstrate the data processing of a raster map available online in actinia, here a sample DEM GeoTIFF file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "# define raster elevation map name\n",
- "raster_layer_name = \"srtm90\"\n",
- "\n",
- "# cache file locally\n",
- "out_dir = os.getcwd()\n",
- "dem_file = os.path.join(out_dir, f\"{raster_layer_name}.tif\")\n",
- "\n",
- "# dem_url = (\n",
- "# \"https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing\"\n",
- "# )\n",
- "dem_url = f\"https://github.com/giswqs/data/raw/main/raster/{raster_layer_name}.tif\"\n",
- "\n",
- "# leafmap.download_file(dem_url, dem_file, unzip=False, overwrite=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "20",
- "metadata": {},
- "source": [
- "Prepare actinia location and mapset, i.e. generate a subproject for data processing."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "# request list of all locations\n",
- "locations = actinia_mundialis.get_locations()\n",
- "print([loc for loc in locations])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "# remove leftover location from previous run\n",
- "# actinia_mundialis.locations[\"latlong_wgs84\"].delete()\n",
- "#\n",
- "# remove leftover mapset from previous run\n",
- "locations[\"latlong_wgs84\"].delete_mapset(\"elevation\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "23",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Create a new location for the data processing in actinia\n",
- "new_location = actinia_mundialis.create_location(\"latlong_wgs84\", 4326)\n",
- "print(new_location.name)\n",
- "print(new_location.region)\n",
- "print([loc for loc in actinia_mundialis.locations])\n",
- "\n",
- "# request list of mapsets in selected location\n",
- "mapsets = actinia_mundialis.locations[\"latlong_wgs84\"].get_mapsets()\n",
- "print_dict_keys(mapsets, \"Mapsets in latlong_wgs84:\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Create a new mapset for the data processing in actinia\n",
- "mapset_name = \"elevation\"\n",
- "locations[\"latlong_wgs84\"].create_mapset(mapset_name)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "## Optional: Upload the sample DEM data set to actinia (indeed not needed since we use `vsicurl/` below\n",
- "## to directly retrieve the online dataset).\n",
- "# locations[\"latlong_wgs84\"].mapsets[mapset_name].upload_raster(raster_layer_name, dem_file)\n",
- "# print_dict_keys(locations[\"latlong_wgs84\"].mapsets[mapset_name].raster_layers, \"Raster maps in new mapset:\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "26",
- "metadata": {},
- "source": [
- "#### Ephemeral Processing with actinia\n",
- "\n",
- "**Ephemeral processing** is used to keep computed results, including user-generated data and temporary data, only for a limited period of time (e.g. 24 hours by default in the actinia demo server). This reduces cloud storage costs.\n",
- "\n",
- "In contrast, **persistent processing** refers to the persistent retention of data without a scheduled deletion time, even in the event of a power outage, resulting in corresponding storage costs. In the geo/EO context, persistent storage is used to provide, for example, basic cartography, i.e. elevation models, road networks, building footprints, etc."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27",
- "metadata": {},
- "source": [
- "**Hillshading example**\n",
- "\n",
- "Here an example for an ephemeral processing job: We download and import the remotely available GeoTIFF file. Then we use [r.relief](https://grass.osgeo.org/grass-stable/manuals/r.relief.html) to generate a hillshading map and pre-define the resolution to 10 m. The computational region is set to the input elevation map. The resulting `hillshade.tif` raster map is then provided as a resource for download and visualization."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "pc = {\n",
- " \"list\": [\n",
- " {\n",
- " \"id\": \"importer_0\",\n",
- " \"comment\": \"Import of remote data source (here: COG)\",\n",
- " \"module\": \"r.import\",\n",
- " \"inputs\": [\n",
- " {\"param\": \"input\", \"value\": f\"/vsicurl/{dem_url}\"},\n",
- " {\"param\": \"memory\", \"value\": \"2000\"},\n",
- " {\"param\": \"extent\", \"value\": \"input\"},\n",
- " ],\n",
- " \"outputs\": [{\"param\": \"output\", \"value\": f\"{raster_layer_name}\"}],\n",
- " },\n",
- " {\n",
- " \"id\": \"r.info_1\",\n",
- " \"comment\": \"Print metadata of imported raster map\",\n",
- " \"module\": \"r.info\",\n",
- " \"inputs\": [{\"param\": \"map\", \"value\": f\"{raster_layer_name}\"}],\n",
- " },\n",
- " {\n",
- " \"id\": \"computational_region_2\",\n",
- " \"comment\": \"Set computational region to imported map, and print settings\",\n",
- " \"module\": \"g.region\",\n",
- " \"inputs\": [{\"param\": \"raster\", \"value\": f\"{raster_layer_name}\"}],\n",
- " \"stdout\": {\"id\": \"region\", \"format\": \"kv\", \"delimiter\": \"=\"},\n",
- " \"flags\": \"g\",\n",
- " },\n",
- " {\n",
- " \"id\": \"create_hillshading_3\",\n",
- " \"comment\": \"Compute hillshading map\",\n",
- " \"module\": \"r.relief\",\n",
- " \"inputs\": [{\"param\": \"input\", \"value\": f\"{raster_layer_name}\"}],\n",
- " \"outputs\": [{\"param\": \"output\", \"value\": \"hillshade\"}],\n",
- " },\n",
- " {\n",
- " \"id\": \"exporter_4\",\n",
- " \"comment\": \"Export hillshading map to COG file\",\n",
- " \"module\": \"exporter\",\n",
- " \"outputs\": [\n",
- " {\n",
- " \"export\": {\"type\": \"raster\", \"format\": \"COG\"},\n",
- " \"param\": \"map\",\n",
- " \"value\": \"hillshade\",\n",
- " }\n",
- " ],\n",
- " },\n",
- " ],\n",
- " \"version\": \"1\",\n",
- "}\n",
- "\n",
- "\n",
- "print(pc)\n",
- "job = actinia_mundialis.locations[\"latlong_wgs84\"].create_processing_export_job(\n",
- " pc, \"hillshading\"\n",
- ")\n",
- "job.poll_until_finished()\n",
- "\n",
- "print(job.status)\n",
- "print(job.message)\n",
- "exported_raster = job.urls[\"resources\"][0]\n",
- "print(exported_raster)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "29",
- "metadata": {},
- "source": [
- "It will take a moment, then the communication by actinia is shown: \"Status of hillshading job is accepted: Resource accepted\" continued by further communication messages."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "30",
- "metadata": {},
- "source": [
- "In case an error occurs, check the process log (use [x] with x being the step number in the process chain). Examples:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "31",
- "metadata": {},
- "outputs": [],
- "source": [
- "# check step 0 (r.import)\n",
- "print_dict(job.process_log[0])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "32",
- "metadata": {},
- "outputs": [],
- "source": [
- "# check step 2 (g.region)\n",
- "print_dict(job.process_log[2])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "33",
- "metadata": {},
- "outputs": [],
- "source": [
- "# check step 3 (r.relief)\n",
- "print_dict(job.process_log[3])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "34",
- "metadata": {},
- "source": [
- "Inject `user:password@server` into `exported_raster` URL (i.e., the actinia resource)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "35",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = exported_raster.replace(\"//\", f\"//{actinia_user}:{actinia_password}@\")\n",
- "print(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "36",
- "metadata": {},
- "source": [
- "Visualize the `hillshade` map in leafmap (colorbar inspired by [this notebook](https://leafmap.org/notebooks/07_colorbar/)):"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "37",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_colormap(\n",
- " cmap=\"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=3,\n",
- " height=0.3,\n",
- " orientation=\"horizontal\",\n",
- " vmin=0,\n",
- " vmax=4000,\n",
- ")\n",
- "m.add_cog_layer(\n",
- " url,\n",
- " name=\"SRTM90 hillshaded map\",\n",
- " attribution='https://e4ftl01.cr.usgs.gov/MEASURES/',\n",
- ")\n",
- "# show map\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "38",
- "metadata": {},
- "source": [
- "Find further leafmap (styling) tools in the upper-right toolbox of leafmap."
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/88_nasa_earth_data.ipynb b/examples/notebooks/88_nasa_earth_data.ipynb
deleted file mode 100644
index b3bab018a1..0000000000
--- a/examples/notebooks/88_nasa_earth_data.ipynb
+++ /dev/null
@@ -1,221 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/88_nasa_earth_data.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/88_nasa_earth_data.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Searching and downloading NASA Earth science data products**\n",
- "\n",
- "Leafmap builds upon the [earthaccess](https://earthaccess.readthedocs.io) Python package to search and download NASA Earth science data products, making it easier visualize the footprints of the data products and download them interactively."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install leafmap earthaccess mapclassify"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "import pandas as pd"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "To download and access the data, you will need to create an Earthdata login. You can register for an account at [urs.earthdata.nasa.gov](https://urs.earthdata.nasa.gov)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.nasa_data_login()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "You can search data by short name, doi, concept id, etc. You can find the list of NASA Earth science data products from the [NASA-Earth-Data](https://github.com/opengeos/NASA-Earth-Data) repo. The example below shows how to show the metadata of the 9,000+ NASA Earth science data products."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://github.com/opengeos/NASA-Earth-Data/raw/main/nasa_earth_data.tsv\"\n",
- "df = pd.read_csv(url, sep=\"\\t\")\n",
- "df"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "To search data, specify the short name, bounding box, date range, etc. To return the footprints of the data, set `return_gdf=True`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "results, gdf = leafmap.nasa_data_search(\n",
- " short_name=\"GEDI_L4A_AGB_Density_V2_1_2056\",\n",
- " cloud_hosted=True,\n",
- " bounding_box=(-73.9872, -33.7683, -34.7299, 5.2444),\n",
- " temporal=(\"2020-07-01\", \"2020-07-31\"),\n",
- " count=-1, # use -1 to return all datasets\n",
- " return_gdf=True,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Visualize the footprints of the data on an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf.explore()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Download the data to your local drive. Let's download the first 5 data products."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.nasa_data_download(results[:5], out_dir=\"data\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Use the interactive GUI to search and download data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add(\"nasa_earth_data\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/yGRCfsb.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "To access the search results as a GeoDataFrame:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m._NASA_DATA_GDF"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "To download the data:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.nasa_data_download(m._NASA_DATA_RESULTS, out_dir=\"data\")"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/89_image_array_viz.ipynb b/examples/notebooks/89_image_array_viz.ipynb
deleted file mode 100644
index 1307dbddb7..0000000000
--- a/examples/notebooks/89_image_array_viz.ipynb
+++ /dev/null
@@ -1,317 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/89_image_array_viz.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/89_image_array_viz.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Visualizing in-memory raster datasets and image arrays**"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install \"leafmap[raster]\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "import rasterio\n",
- "import rioxarray\n",
- "import xarray as xr"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "Download two sample raster datasets."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "url1 = \"https://open.gishub.org/data/raster/landsat.tif\"\n",
- "url2 = \"https://open.gishub.org/data/raster/srtm90.tif\"\n",
- "satellite = leafmap.download_file(url1, \"landsat.tif\", overwrite=True)\n",
- "dem = leafmap.download_file(url2, \"srtm90.tif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "The Landsat image contains 3 bands: nir, red, and green. Let's calculate NDVI using the nir and red bands."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "dataset = rasterio.open(satellite)\n",
- "nir = dataset.read(4).astype(float)\n",
- "red = dataset.read(1).astype(float)\n",
- "ndvi = (nir - red) / (nir + red)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "Create an in-memory raster dataset from the NDVI array and use the projection and extent of the Landsat image."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "ndvi_image = leafmap.array_to_image(ndvi, source=satellite)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Visualize the Landsat image and the NDVI image on the same map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(satellite, indexes=[4, 1, 2], vmin=0, vmax=120, layer_name=\"Landsat 7\")\n",
- "m.add_raster(ndvi_image, colormap=\"Greens\", layer_name=\"NDVI\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "You can also specify the image metadata (e.g., cellsize, crs, and transform) when creating the in-memory raster dataset.\n",
- "\n",
- "First, check the metadata of the origina image."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "dataset.profile"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Check the crs of the original image."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "dataset.crs"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Check the transform of the original image."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "dataset.transform"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "Create an in-memory raster dataset from the NDVI array and specify the cellsize, crs, and transform."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "transform = (30.0, 0.0, -13651650.0, 0.0, -30.0, 4576290.0)\n",
- "ndvi_image = leafmap.array_to_image(\n",
- " ndvi, cellsize=30, crs=\"EPSG:3857\", transform=transform\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "Add the NDVI image to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(satellite, indexes=[4, 1, 2], vmin=0, vmax=120, layer_name=\"Landsat 7\")\n",
- "m.add_raster(ndvi_image, colormap=\"Greens\", layer_name=\"NDVI\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "Use rioxarray to read raster datasets into xarray DataArrays."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "ds = rioxarray.open_rasterio(dem)\n",
- "ds"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "Classify the DEM into 2 elevation classes."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "array = ds.sel(band=1)\n",
- "masked_array = xr.where(array < 2000, 0, 1)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "25",
- "metadata": {},
- "source": [
- "Visualize the DEM and the elevation class image on the same map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(dem, colormap=\"terrain\", layer_name=\"DEM\")\n",
- "m.add_raster(masked_array, colormap=\"coolwarm\", layer_name=\"Classified DEM\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27",
- "metadata": {},
- "source": [
- "Add a split map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[37.6, -119], zoom=9)\n",
- "m.split_map(\n",
- " dem,\n",
- " masked_array,\n",
- " left_args={\n",
- " \"layer_name\": \"DEM\",\n",
- " \"colormap\": \"terrain\",\n",
- " },\n",
- " right_args={\n",
- " \"layer_name\": \"Classified DEM\",\n",
- " \"colormap\": \"coolwarm\",\n",
- " },\n",
- ")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/90_pixel_inspector.ipynb b/examples/notebooks/90_pixel_inspector.ipynb
deleted file mode 100644
index c8585fa235..0000000000
--- a/examples/notebooks/90_pixel_inspector.ipynb
+++ /dev/null
@@ -1,285 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/90_pixel_inspector.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/90_pixel_inspector.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "## Interactive pixel inspector \n",
- "\n",
- "The interactive pixel inspector can be used to explore the pixel values of an image. It supports Cloud Optimized GeoTIFF (COG), STAC, and other raster data formats, either stored locally or on the cloud. The COG and STAC functionalities are powered by the [TiTiler](https://developmentseed.org/titiler/), while the local file support is powered by [localtileserver](https://github.com/banesullivan/localtileserver)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install \"leafmap[raster]\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "import rasterio\n",
- "import rioxarray\n",
- "import xarray as xr"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "### COG"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- "m.add_cog_layer(url, name=\"Libya\")\n",
- "m.add(\"inspector\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "### STAC"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\"\n",
- "m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"SPOT Image\")\n",
- "m.add(\"inspector\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "### Planetary Computer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "collection = \"landsat-8-c2-l2\"\n",
- "item = \"LC08_L2SP_047027_20201204_02_T1\"\n",
- "m.add_stac_layer(\n",
- " collection=collection,\n",
- " item=item,\n",
- " assets=\"SR_B7,SR_B5,SR_B4\",\n",
- " name=\"Landsat Band-754\",\n",
- ")\n",
- "m.add(\"inspector\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "### Local raster"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/raster/landsat.tif\"\n",
- "satellite = leafmap.download_file(url, \"landsat.tif\", overwrite=True)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(satellite, indexes=[4, 1, 2], vmin=0, vmax=120, layer_name=\"Landsat 7\")\n",
- "m.add(\"inspector\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "## In-memory raster\n",
- "\n",
- "### NumPy array"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "13",
- "metadata": {},
- "outputs": [],
- "source": [
- "dataset = rasterio.open(satellite)\n",
- "nir = dataset.read(4).astype(float)\n",
- "red = dataset.read(1).astype(float)\n",
- "ndvi = (nir - red) / (nir + red)\n",
- "ndvi_image = leafmap.array_to_image(ndvi, source=satellite)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(satellite, indexes=[4, 1, 2], vmin=0, vmax=120, layer_name=\"Landsat 7\")\n",
- "m.add_raster(ndvi_image, colormap=\"Greens\", layer_name=\"NDVI\")\n",
- "m.add(\"inspector\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "### Xarray DataArray"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/raster/srtm90.tif\"\n",
- "dem = leafmap.download_file(url, \"srtm90.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "ds = rioxarray.open_rasterio(dem)\n",
- "ds"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "array = ds.sel(band=1)\n",
- "masked_array = xr.where(array < 2000, 0, 1)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(dem, colormap=\"terrain\", layer_name=\"DEM\")\n",
- "m.add_raster(masked_array, colormap=\"coolwarm\", layer_name=\"Classified DEM\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "20",
- "metadata": {},
- "source": [
- "## Split map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[37.6, -119], zoom=9)\n",
- "m.split_map(\n",
- " dem,\n",
- " masked_array,\n",
- " left_args={\n",
- " \"layer_name\": \"DEM\",\n",
- " \"colormap\": \"terrain\",\n",
- " },\n",
- " right_args={\n",
- " \"layer_name\": \"Classified DEM\",\n",
- " \"colormap\": \"coolwarm\",\n",
- " },\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "22",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/2AduU8G.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/91_raster_viz_gui.ipynb b/examples/notebooks/91_raster_viz_gui.ipynb
deleted file mode 100644
index 16e6260d1a..0000000000
--- a/examples/notebooks/91_raster_viz_gui.ipynb
+++ /dev/null
@@ -1,142 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/91_raster_viz_gui.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/91_raster_viz_gui.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Visualizing raster data interactively**\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "## Visualizing local raster data"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "filename = \"landsat.tif\"\n",
- "landsat_url = (\n",
- " \"https://github.com/opengeos/datasets/releases/download/raster/landsat.tif\"\n",
- ")\n",
- "leafmap.download_file(landsat_url, filename, overwrite=True)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(filename, indexes=[3, 2, 1], vmin=0, vmax=100, layer_name=\"Landsat\")\n",
- "m.add(\"layer_manager\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/2QsLp32.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "## Visualizing Cloud Optimized GeoTIFF (COG)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- "m.add_cog_layer(url, bands=[\"b1\", \"b2\", \"b3\"], name=\"Libya\")\n",
- "m.add(\"layer_manager\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "## Visualizing SpatioTemporal Asset Catalog (STAC)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\"\n",
- "m.add_stac_layer(url, bands=[\"B4\", \"B3\", \"B2\"], name=\"SPOT\")\n",
- "m.add(\"layer_manager\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/wln009j.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/92_maplibre.ipynb b/examples/notebooks/92_maplibre.ipynb
deleted file mode 100644
index a0c35682dc..0000000000
--- a/examples/notebooks/92_maplibre.ipynb
+++ /dev/null
@@ -1,993 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/92_maplibre.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/92_maplibre.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "**Creating 3D maps with MapLibre**\n",
- "\n",
- "The notebook demonstrates how to create 3D maps using the [MapLibre](https://github.com/eodaGmbH/py-maplibregl) Python package. The examples shown in this notebook are based on the [MapLibre documentation](https://eodagmbh.github.io/py-maplibregl/examples/vancouver_blocks/). Credits to the original authors at [eoda GmbH](https://www.eoda.de/en/).\n",
- "\n",
- "## Installation\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install \"leafmap[maplibre]\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "## Import libraries"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.maplibregl as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4",
- "metadata": {},
- "source": [
- "## Create maps\n",
- "\n",
- "Create an interactive map by specifying map center [lon, lat], zoom level, pitch, and bearing."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[-100, 40], zoom=3, pitch=0, bearing=0)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/8ITaEZa.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "To customize the basemap, you can specify the `style` parameter. It can be an URL or a string, such as `dark-matter`, `positron`, `voyager`, `demotiles`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(style=\"positron\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/9fImW21.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "To create a map with a background color, use `style=\"background-\"`, such as `background-lightgray` and `background-green`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(style=\"background-lightgray\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "12",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/xFeDTkE.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Alternatively, you can provide a URL to a vector style."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "style = \"https://demotiles.maplibre.org/style.json\"\n",
- "m = leafmap.Map(style=style)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/yaZYrr1.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "## Add controls\n",
- "\n",
- "The control to add to the map. Can be one of the following: `scale`, `fullscreen`, `geolocate`, `navigation`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_control(\"geolocate\", position=\"top-left\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/7LS5WAk.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "## Add basemaps"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_basemap()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/MRRw1MW.png)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_basemap(\"Esri.WorldImagery\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "25",
- "metadata": {},
- "source": [
- "## XYZ tile layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://tile.openstreetmap.org/{z}/{x}/{y}.png\"\n",
- "m.add_tile_layer(\n",
- " url, name=\"OpenStreetMap\", attribution=\"OpenStreetMap\", opacity=1.0, visible=True\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/V9wmsjl.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "28",
- "metadata": {},
- "source": [
- "## WMS layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "29",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[-100, 40], zoom=3)\n",
- "m.add_basemap(\"Esri.WorldImagery\")\n",
- "url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2021_Land_Cover_L48/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&transparent=true&width=256&height=256&layers=NLCD_2021_Land_Cover_L48\"\n",
- "m.add_wms_layer(url, name=\"NLCD\", opacity=0.8)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "30",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/xcZ4VKv.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "31",
- "metadata": {},
- "source": [
- "## COG layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "32",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = (\n",
- " \"https://github.com/opengeos/datasets/releases/download/raster/Libya-2023-07-01.tif\"\n",
- ")\n",
- "m.add_cog_layer(url, name=\"COG\", attribution=\"Maxar\", fit_bounds=True)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "33",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/ApGhjDp.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "34",
- "metadata": {},
- "source": [
- "## STAC layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "35",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\"\n",
- "m.add_stac_layer(url, bands=[\"B4\", \"B3\", \"B2\"], name=\"SPOT\", vmin=0, vmax=150)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "36",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/RJAhsV5.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "37",
- "metadata": {},
- "source": [
- "## Local raster"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "38",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://github.com/opengeos/datasets/releases/download/raster/srtm90.tif\"\n",
- "filepath = \"srtm90.tif\"\n",
- "leafmap.download_file(url, filepath)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "39",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(filepath, colormap=\"terrain\", name=\"DEM\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "40",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/pMcuQAp.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "41",
- "metadata": {},
- "source": [
- "## Vancouver Property Value"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "42",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " center=[-123.13, 49.254], zoom=11, style=\"dark-matter\", pitch=45, bearing=0\n",
- ")\n",
- "url = \"https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/geojson/vancouver-blocks.json\"\n",
- "paint_line = {\n",
- " \"line-color\": \"white\",\n",
- " \"line-width\": 2,\n",
- "}\n",
- "paint_fill = {\n",
- " \"fill-extrusion-color\": {\n",
- " \"property\": \"valuePerSqm\",\n",
- " \"stops\": [\n",
- " [0, \"grey\"],\n",
- " [1000, \"yellow\"],\n",
- " [5000, \"orange\"],\n",
- " [10000, \"darkred\"],\n",
- " [50000, \"lightblue\"],\n",
- " ],\n",
- " },\n",
- " \"fill-extrusion-height\": [\"*\", 10, [\"sqrt\", [\"get\", \"valuePerSqm\"]]],\n",
- " \"fill-extrusion-opacity\": 0.9,\n",
- "}\n",
- "m.add_geojson(url, layer_type=\"line\", paint=paint_line, name=\"blocks-line\")\n",
- "m.add_geojson(url, layer_type=\"fill-extrusion\", paint=paint_fill, name=\"blocks-fill\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "43",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.layer_interact()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "44",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/IZXfgSz.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "45",
- "metadata": {},
- "source": [
- "## Earthquake Clusters"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "46",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(style=\"positron\")\n",
- "\n",
- "data = \"https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson\"\n",
- "source_args = {\n",
- " \"cluster\": True,\n",
- " \"cluster_radius\": 50,\n",
- " \"cluster_min_points\": 2,\n",
- " \"cluster_max_zoom\": 14,\n",
- " \"cluster_properties\": {\n",
- " \"maxMag\": [\"max\", [\"get\", \"mag\"]],\n",
- " \"minMag\": [\"min\", [\"get\", \"mag\"]],\n",
- " },\n",
- "}\n",
- "\n",
- "m.add_geojson(\n",
- " data,\n",
- " layer_type=\"circle\",\n",
- " name=\"earthquake-circles\",\n",
- " filter=[\"!\", [\"has\", \"point_count\"]],\n",
- " paint={\"circle-color\": \"darkblue\"},\n",
- " source_args=source_args,\n",
- ")\n",
- "\n",
- "m.add_geojson(\n",
- " data,\n",
- " layer_type=\"circle\",\n",
- " name=\"earthquake-clusters\",\n",
- " filter=[\"has\", \"point_count\"],\n",
- " paint={\n",
- " \"circle-color\": [\n",
- " \"step\",\n",
- " [\"get\", \"point_count\"],\n",
- " \"#51bbd6\",\n",
- " 100,\n",
- " \"#f1f075\",\n",
- " 750,\n",
- " \"#f28cb1\",\n",
- " ],\n",
- " \"circle-radius\": [\"step\", [\"get\", \"point_count\"], 20, 100, 30, 750, 40],\n",
- " },\n",
- " source_args=source_args,\n",
- ")\n",
- "\n",
- "m.add_geojson(\n",
- " data,\n",
- " layer_type=\"symbol\",\n",
- " name=\"earthquake-labels\",\n",
- " filter=[\"has\", \"point_count\"],\n",
- " layout={\n",
- " \"text-field\": [\"get\", \"point_count_abbreviated\"],\n",
- " \"text-size\": 12,\n",
- " },\n",
- " source_args=source_args,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "47",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/vge4jF4.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "48",
- "metadata": {},
- "source": [
- "## Airport Markers"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "49",
- "metadata": {},
- "outputs": [],
- "source": [
- "from maplibre.controls import Marker, MarkerOptions, Popup, PopupOptions\n",
- "import pandas as pd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "50",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(style=\"positron\")\n",
- "\n",
- "url = \"https://github.com/visgl/deck.gl-data/raw/master/examples/line/airports.json\"\n",
- "data = leafmap.pandas_to_geojson(\n",
- " url, \"coordinates\", properties=[\"type\", \"name\", \"abbrev\"]\n",
- ")\n",
- "\n",
- "m.add_geojson(\n",
- " data,\n",
- " name=\"Airports\",\n",
- " layer_type=\"circle\",\n",
- " paint={\n",
- " \"circle-color\": [\n",
- " \"match\",\n",
- " [\"get\", \"type\"],\n",
- " \"mid\",\n",
- " \"darkred\",\n",
- " \"major\",\n",
- " \"darkgreen\",\n",
- " \"darkblue\",\n",
- " ],\n",
- " \"circle_radius\": 10,\n",
- " \"circle-opacity\": 0.3,\n",
- " },\n",
- ")\n",
- "\n",
- "\n",
- "def get_color(airport_type: str) -> str:\n",
- " color = \"darkblue\"\n",
- " if airport_type == \"mid\":\n",
- " color = \"darkred\"\n",
- " elif airport_type == \"major\":\n",
- " color = \"darkgreen\"\n",
- "\n",
- " return color\n",
- "\n",
- "\n",
- "airports_data = pd.read_json(url)\n",
- "popup_options = PopupOptions(close_button=False)\n",
- "\n",
- "for _, r in airports_data.iterrows():\n",
- " m.add_marker(\n",
- " lng_lat=r[\"coordinates\"],\n",
- " options=MarkerOptions(color=get_color(r[\"type\"])),\n",
- " popup=Popup(\n",
- " text=r[\"name\"],\n",
- " options=popup_options,\n",
- " ),\n",
- " )\n",
- "\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "51",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/q7nN1PW.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "52",
- "metadata": {},
- "source": [
- "## 3D Indoor Mapping"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "53",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " center=(-87.61694, 41.86625), zoom=17, pitch=40, bearing=20, style=\"positron\"\n",
- ")\n",
- "m.add_basemap(\"OpenStreetMap.Mapnik\")\n",
- "data = \"https://maplibre.org/maplibre-gl-js/docs/assets/indoor-3d-map.geojson\"\n",
- "m.add_geojson(\n",
- " data,\n",
- " layer_type=\"fill-extrusion\",\n",
- " name=\"floorplan\",\n",
- " paint={\n",
- " \"fill-extrusion-color\": [\"get\", \"color\"],\n",
- " \"fill-extrusion-height\": [\"get\", \"height\"],\n",
- " \"fill-extrusion-base\": [\"get\", \"base_height\"],\n",
- " \"fill-extrusion-opacity\": 0.5,\n",
- " },\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "54",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/dteQlQC.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "55",
- "metadata": {},
- "source": [
- "## Custom Basemap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "56",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.maplibregl as leafmap\n",
- "from maplibre.basemaps import construct_basemap_style\n",
- "from maplibre import Layer, LayerType, Map, MapOptions\n",
- "from maplibre.sources import GeoJSONSource\n",
- "\n",
- "\n",
- "bg_layer = Layer(\n",
- " type=LayerType.BACKGROUND,\n",
- " id=\"background\",\n",
- " source=None,\n",
- " paint={\"background-color\": \"darkblue\", \"background-opacity\": 0.8},\n",
- ")\n",
- "\n",
- "countries_source = GeoJSONSource(\n",
- " data=\"https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_110m_admin_0_countries.geojson\"\n",
- ")\n",
- "\n",
- "lines_layer = Layer(\n",
- " type=LayerType.LINE,\n",
- " source=\"countries\",\n",
- " paint={\"line-color\": \"white\", \"line-width\": 1.5},\n",
- ")\n",
- "\n",
- "polygons_layer = Layer(\n",
- " type=LayerType.FILL,\n",
- " source=\"countries\",\n",
- " paint={\"fill-color\": \"darkred\", \"fill-opacity\": 0.8},\n",
- ")\n",
- "\n",
- "custom_basemap = construct_basemap_style(\n",
- " layers=[bg_layer, polygons_layer, lines_layer],\n",
- " sources={\"countries\": countries_source},\n",
- ")\n",
- "\n",
- "\n",
- "m = leafmap.Map(style=custom_basemap)\n",
- "data = \"https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson\"\n",
- "m.add_geojson(\n",
- " data,\n",
- " layer_type=\"circle\",\n",
- " name=\"earthquakes\",\n",
- " paint={\"circle-color\": \"yellow\", \"circle-radius\": 5},\n",
- ")\n",
- "m.add_popup(\"earthquakes\", \"mag\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "57",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/Bn9Kwje.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "58",
- "metadata": {},
- "source": [
- "## H3 Grid UK Road Safety"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "59",
- "metadata": {},
- "outputs": [],
- "source": [
- "import pandas as pd\n",
- "import h3"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "60",
- "metadata": {},
- "outputs": [],
- "source": [
- "RESOLUTION = 7\n",
- "COLORS = (\n",
- " \"lightblue\",\n",
- " \"turquoise\",\n",
- " \"lightgreen\",\n",
- " \"yellow\",\n",
- " \"orange\",\n",
- " \"darkred\",\n",
- ")\n",
- "\n",
- "road_safety = pd.read_csv(\n",
- " \"https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv\"\n",
- ").dropna()\n",
- "\n",
- "\n",
- "def create_h3_grid(res=RESOLUTION) -> dict:\n",
- " road_safety[\"h3\"] = road_safety.apply(\n",
- " lambda x: h3.geo_to_h3(x[\"lat\"], x[\"lng\"], resolution=res), axis=1\n",
- " )\n",
- " df = road_safety.groupby(\"h3\").h3.agg(\"count\").to_frame(\"count\").reset_index()\n",
- " df[\"hexagon\"] = df.apply(\n",
- " lambda x: [h3.h3_to_geo_boundary(x[\"h3\"], geo_json=True)], axis=1\n",
- " )\n",
- " df[\"color\"] = pd.cut(\n",
- " df[\"count\"],\n",
- " bins=len(COLORS),\n",
- " labels=COLORS,\n",
- " )\n",
- " return leafmap.pandas_to_geojson(\n",
- " df, \"hexagon\", geometry_type=\"Polygon\", properties=[\"count\", \"color\"]\n",
- " )\n",
- "\n",
- "\n",
- "m = leafmap.Map(\n",
- " center=(-1.415727, 52.232395),\n",
- " zoom=7,\n",
- " pitch=40,\n",
- " bearing=-27,\n",
- ")\n",
- "data = create_h3_grid()\n",
- "m.add_geojson(\n",
- " data,\n",
- " layer_type=\"fill-extrusion\",\n",
- " paint={\n",
- " \"fill-extrusion-color\": [\"get\", \"color\"],\n",
- " \"fill-extrusion-opacity\": 0.7,\n",
- " \"fill-extrusion-height\": [\"*\", 100, [\"get\", \"count\"]],\n",
- " },\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "61",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/DYWmj5y.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "62",
- "metadata": {},
- "source": [
- "## Deck.GL Layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "63",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " style=\"positron\",\n",
- " center=(-122.4, 37.74),\n",
- " zoom=12,\n",
- " pitch=40,\n",
- ")\n",
- "deck_grid_layer = {\n",
- " \"@@type\": \"GridLayer\",\n",
- " \"id\": \"GridLayer\",\n",
- " \"data\": \"https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-bike-parking.json\",\n",
- " \"extruded\": True,\n",
- " \"getPosition\": \"@@=COORDINATES\",\n",
- " \"getColorWeight\": \"@@=SPACES\",\n",
- " \"getElevationWeight\": \"@@=SPACES\",\n",
- " \"elevationScale\": 4,\n",
- " \"cellSize\": 200,\n",
- " \"pickable\": True,\n",
- "}\n",
- "\n",
- "m.add_deck_layers([deck_grid_layer], tooltip=\"Number of points: {{ count }}\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "64",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/xBVdT2u.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "65",
- "metadata": {},
- "source": [
- "## Multiple Deck.GL Layers"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "66",
- "metadata": {},
- "outputs": [],
- "source": [
- "import requests"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "67",
- "metadata": {},
- "outputs": [],
- "source": [
- "data = requests.get(\n",
- " \"https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_airports.geojson\"\n",
- ").json()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "68",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " style=\"positron\",\n",
- " center=(0.45, 51.47),\n",
- " zoom=4,\n",
- " pitch=30,\n",
- ")\n",
- "deck_geojson_layer = {\n",
- " \"@@type\": \"GeoJsonLayer\",\n",
- " \"id\": \"airports\",\n",
- " \"data\": data,\n",
- " \"filled\": True,\n",
- " \"pointRadiusMinPixels\": 2,\n",
- " \"pointRadiusScale\": 2000,\n",
- " \"getPointRadius\": \"@@=11 - properties.scalerank\",\n",
- " \"getFillColor\": [200, 0, 80, 180],\n",
- " \"autoHighlight\": True,\n",
- " \"pickable\": True,\n",
- "}\n",
- "\n",
- "deck_arc_layer = {\n",
- " \"@@type\": \"ArcLayer\",\n",
- " \"id\": \"arcs\",\n",
- " \"data\": [\n",
- " feature\n",
- " for feature in data[\"features\"]\n",
- " if feature[\"properties\"][\"scalerank\"] < 4\n",
- " ],\n",
- " \"getSourcePosition\": [-0.4531566, 51.4709959], # London\n",
- " \"getTargetPosition\": \"@@=geometry.coordinates\",\n",
- " \"getSourceColor\": [0, 128, 200],\n",
- " \"getTargetColor\": [200, 0, 80],\n",
- " \"getWidth\": 2,\n",
- " \"pickable\": True,\n",
- "}\n",
- "\n",
- "m.add_deck_layers(\n",
- " [deck_geojson_layer, deck_arc_layer],\n",
- " tooltip={\n",
- " \"airports\": \"{{ &properties.name }}\",\n",
- " \"arcs\": \"gps_code: {{ properties.gps_code }}\",\n",
- " },\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "69",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/eFc4IbZ.png)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3 (ipykernel)",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.11.8"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/93_maplibre_pmtiles.ipynb b/examples/notebooks/93_maplibre_pmtiles.ipynb
deleted file mode 100644
index 11616cbd18..0000000000
--- a/examples/notebooks/93_maplibre_pmtiles.ipynb
+++ /dev/null
@@ -1,482 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/93_maplibre_pmtiles.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/93_maplibre_pmtiles.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "\n",
- "**Visualizing PMTiles with Leafmap and MapLibre**\n",
- "\n",
- "[PMTiles](https://github.com/protomaps/PMTiles) is a single-file archive format for tiled data. A PMTiles archive can be hosted on a commodity storage platform such as S3, and enables low-cost, zero-maintenance map applications that are \"serverless\" - free of a custom tile backend or third party provider."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U \"leafmap[maplibre]\" pmtiles"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.maplibregl as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "## Remote PMTiles\n",
- "\n",
- "### Protomaps sample data"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/pmtiles/protomaps_firenze.pmtiles\"\n",
- "metadata = leafmap.pmtiles_metadata(url)\n",
- "print(f\"layer names: {metadata['layer_names']}\")\n",
- "print(f\"bounds: {metadata['bounds']}\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "style = {\n",
- " \"version\": 8,\n",
- " \"sources\": {\n",
- " \"example_source\": {\n",
- " \"type\": \"vector\",\n",
- " \"url\": \"pmtiles://\" + url,\n",
- " \"attribution\": \"PMTiles\",\n",
- " }\n",
- " },\n",
- " \"layers\": [\n",
- " {\n",
- " \"id\": \"buildings\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"landuse\",\n",
- " \"type\": \"fill\",\n",
- " \"paint\": {\"fill-color\": \"steelblue\"},\n",
- " },\n",
- " {\n",
- " \"id\": \"roads\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"roads\",\n",
- " \"type\": \"line\",\n",
- " \"paint\": {\"line-color\": \"black\"},\n",
- " },\n",
- " ],\n",
- "}\n",
- "\n",
- "# style = leafmap.pmtiles_style(url) # Use default style\n",
- "\n",
- "m.add_pmtiles(\n",
- " url,\n",
- " style=style,\n",
- " visible=True,\n",
- " opacity=1.0,\n",
- " tooltip=True,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.layer_interact()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/Ucpv3wQ.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "### Overture data"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "You can also visualize Overture data. Inspired by [overture-maps](https://github.com/tebben/overture-maps)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://storage.googleapis.com/ahp-research/overture/pmtiles/overture.pmtiles\"\n",
- "metadata = leafmap.pmtiles_metadata(url)\n",
- "print(f\"layer names: {metadata['layer_names']}\")\n",
- "print(f\"bounds: {metadata['bounds']}\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "11",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(height=\"800px\")\n",
- "m.add_basemap(\"Esri.WorldImagery\")\n",
- "\n",
- "style = {\n",
- " \"version\": 8,\n",
- " \"sources\": {\n",
- " \"example_source\": {\n",
- " \"type\": \"vector\",\n",
- " \"url\": \"pmtiles://\" + url,\n",
- " \"attribution\": \"PMTiles\",\n",
- " }\n",
- " },\n",
- " \"layers\": [\n",
- " # {\n",
- " # \"id\": \"admins\",\n",
- " # \"source\": \"example_source\",\n",
- " # \"source-layer\": \"admins\",\n",
- " # \"type\": \"fill\",\n",
- " # \"paint\": {\"fill-color\": \"#BDD3C7\", \"fill-opacity\": 0.1},\n",
- " # },\n",
- " {\n",
- " \"id\": \"buildings\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"buildings\",\n",
- " \"type\": \"fill\",\n",
- " \"paint\": {\"fill-color\": \"#FFFFB3\", \"fill-opacity\": 0.5},\n",
- " },\n",
- " {\n",
- " \"id\": \"places\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"places\",\n",
- " \"type\": \"fill\",\n",
- " \"paint\": {\"fill-color\": \"#BEBADA\", \"fill-opacity\": 0.5},\n",
- " },\n",
- " {\n",
- " \"id\": \"roads\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"roads\",\n",
- " \"type\": \"line\",\n",
- " \"paint\": {\"line-color\": \"#FB8072\"},\n",
- " },\n",
- " ],\n",
- "}\n",
- "\n",
- "# style = leafmap.pmtiles_style(url) # Use default style\n",
- "\n",
- "m.add_pmtiles(\n",
- " url,\n",
- " style=style,\n",
- " visible=True,\n",
- " opacity=1.0,\n",
- " tooltip=True,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.layer_interact()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/ZOEbFGh.jpeg)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "14",
- "metadata": {},
- "source": [
- "### Source Cooperative\n",
- "\n",
- "[Google-Microsoft Open Buildings - combined by VIDA](https://beta.source.coop/repositories/vida/google-microsoft-open-buildings/description)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://data.source.coop/vida/google-microsoft-open-buildings/pmtiles/go_ms_building_footprints.pmtiles\"\n",
- "metadata = leafmap.pmtiles_metadata(url)\n",
- "print(f\"layer names: {metadata['layer_names']}\")\n",
- "print(f\"bounds: {metadata['bounds']}\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 20], zoom=2, height=\"800px\")\n",
- "m.add_basemap(\"Google Hybrid\", visible=False)\n",
- "\n",
- "style = {\n",
- " \"version\": 8,\n",
- " \"sources\": {\n",
- " \"example_source\": {\n",
- " \"type\": \"vector\",\n",
- " \"url\": \"pmtiles://\" + url,\n",
- " \"attribution\": \"PMTiles\",\n",
- " }\n",
- " },\n",
- " \"layers\": [\n",
- " {\n",
- " \"id\": \"buildings\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"building_footprints\",\n",
- " \"type\": \"fill\",\n",
- " \"paint\": {\"fill-color\": \"#3388ff\", \"fill-opacity\": 0.5},\n",
- " },\n",
- " ],\n",
- "}\n",
- "\n",
- "# style = leafmap.pmtiles_style(url) # Use default style\n",
- "\n",
- "m.add_pmtiles(\n",
- " url,\n",
- " style=style,\n",
- " visible=True,\n",
- " opacity=1.0,\n",
- " tooltip=True,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.layer_interact()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "18",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/rH0iLgc.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "## Local PMTiles\n",
- "\n",
- "tippecanoe is required to convert vector data to pmtiles. Install it with `conda install -c conda-forge tippecanoe`.\n",
- "\n",
- "Download [building footprints](https://github.com/opengeos/open-data/blob/main/datasets/libya/Derna_buildings.geojson) of Derna, Libya."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://raw.githubusercontent.com/opengeos/open-data/main/datasets/libya/Derna_buildings.geojson\"\n",
- "leafmap.download_file(url, \"buildings.geojson\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "Convert vector to PMTiles."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "pmtiles = \"buildings.pmtiles\"\n",
- "leafmap.geojson_to_pmtiles(\n",
- " \"buildings.geojson\", pmtiles, layer_name=\"buildings\", overwrite=True, quiet=True\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "Start a HTTP Sever"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.start_server(port=8000)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = f\"http://127.0.0.1:8000/{pmtiles}\"\n",
- "# leafmap.pmtiles_metadata(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "26",
- "metadata": {},
- "source": [
- "Display the PMTiles on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "27",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"Google Hybrid\")\n",
- "style = {\n",
- " \"version\": 8,\n",
- " \"sources\": {\n",
- " \"example_source\": {\n",
- " \"type\": \"vector\",\n",
- " \"url\": \"pmtiles://\" + url,\n",
- " \"attribution\": \"PMTiles\",\n",
- " }\n",
- " },\n",
- " \"layers\": [\n",
- " {\n",
- " \"id\": \"buildings\",\n",
- " \"source\": \"example_source\",\n",
- " \"source-layer\": \"buildings\",\n",
- " \"type\": \"fill\",\n",
- " \"paint\": {\"fill-color\": \"#3388ff\", \"fill-opacity\": 0.5},\n",
- " },\n",
- " ],\n",
- "}\n",
- "\n",
- "# style = leafmap.pmtiles_style(url) # Use default style\n",
- "\n",
- "m.add_pmtiles(\n",
- " url,\n",
- " style=style,\n",
- " visible=True,\n",
- " opacity=0.8,\n",
- " tooltip=True,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.layer_interact()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "29",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/PnYhph1.jpeg)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3 (ipykernel)",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.11.8"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/notebooks/zz_notebook_template.ipynb b/examples/notebooks/zz_notebook_template.ipynb
deleted file mode 100644
index 5b4a4c601e..0000000000
--- a/examples/notebooks/zz_notebook_template.ipynb
+++ /dev/null
@@ -1,82 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/zz_notebook_template.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/notebooks/zz_notebook_template.ipynb)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
- "\n",
- "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install -U leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "If you are using a recently implemented leafmap feature that has not yet been released to PyPI or conda-forge, you can uncomment the following line to install the development version from GitHub."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.update_package()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "Create an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/workshops/EarthCube_2023.ipynb b/examples/workshops/EarthCube_2023.ipynb
deleted file mode 100644
index d39d50145a..0000000000
--- a/examples/workshops/EarthCube_2023.ipynb
+++ /dev/null
@@ -1,954 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/EarthCube_2023.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/workshops/EarthCube_2023.ipynb)\n",
- "\n",
- "**Interactive Geospatial Analysis and Data Visualization with Leafmap**\n",
- "\n",
- "This [notebook](https://leafmap.org/workshops/EarthCube_2023) provides an introduction to interactive geospatial analysis and data visualization with leafmap. It is designed for the notebook demo at the [EarthCube 2023](https://isi-usc-edu.github.io/building-upon-the-earthcube-community)."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "1",
- "metadata": {},
- "source": [
- "## Installation\n",
- "\n",
- "Uncomment and run the following cell to install necessary packages for this notebook. **Restart the kernel/runtime after installation**."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install leafmap[raster] geopandas rasterstats"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "## Import libraries"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap\n",
- "import geopandas as gpd"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "## Create interactive maps\n",
- "\n",
- "Specify the map center [lat, lon], zoom level, and height."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4, height=\"600px\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "## Add basemaps\n",
- "\n",
- "Add OpenTopoMap, USGS 3DEP Elevation, and USGS Hydrography basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_basemap(\"USGS 3DEP Elevation\")\n",
- "m.add_basemap(\"USGS Hydrography\")\n",
- "m.add_layer_manager()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Add NLCD land cover map and legend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4)\n",
- "m.add_basemap(\"HYBRID\")\n",
- "m.add_basemap(\"NLCD 2019 CONUS Land Cover\")\n",
- "m.add_legend(builtin_legend=\"NLCD\", title=\"NLCD Land Cover Type\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Add WMS layers."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4)\n",
- "m.add_basemap(\"Esri.WorldImagery\")\n",
- "url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?\"\n",
- "m.add_wms_layer(\n",
- " url,\n",
- " layers=\"NLCD_2019_Land_Cover_L48\",\n",
- " name=\"NLCD 2019 CONUS Land Cover\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "m.add_legend(builtin_legend=\"NLCD\", title=\"NLCD Land Cover Type\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "Change basemaps interactively."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap_gui()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "## Visualize raster datasets\n",
- "\n",
- "### Cloud Optimized GeoTIFF\n",
- "\n",
- "A Cloud Optimized GeoTIFF (COG) is a regular GeoTIFF file that is optimized for serving on an HTTP file server, with an internal organization that enables more efficient workflows on a cloud environment. This is achieved by allowing clients to issue HTTP GET requests to ask for only the parts of a file that they need. For more information about COG, please visit https://www.cogeo.org."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://open.gishub.org/data/raster/srtm90.tif\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.cog_stats(url)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_cog_layer(url, name=\"Remote COG\", colormap_name=\"terrain\")\n",
- "m.add_colormap(vmin=0, vmax=4000, cmap=\"terrain\", label=\"Elevation (m)\")\n",
- "m.add_inspector_gui()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "Download the COG file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.download_file(url, \"srtm90.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(\"srtm90.tif\", colormap=\"terrain\", layer_name=\"Local COG\")\n",
- "m.add_colormap(vmin=0, vmax=4000, cmap=\"terrain\", label=\"Elevation (m)\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "22",
- "metadata": {},
- "source": [
- "## SpatioTemporal Asset Catalog\n",
- "\n",
- "The SpatioTemporal Asset Catalog (STAC) specification provides a common language to describe a range of geospatial information so that it can more easily be indexed and discovered. A **SpatioTemporal Asset** is any file that represents information about the earth captured in a certain space and time. STAC aims to enable that next generation of geospatial search engines, while also supporting web best practices so geospatial information is more easily surfaced in traditional search engines. More information about STAC can be found at the [STAC website](https://stacspec.org/). The [STAC Index website](https://stacindex.org/) is a one-stop-shop for discovering STAC catalogs, collections, APIs, software and tools. In this example, we will use the [STAC SPOT Orthoimages of Canada](https://stacindex.org/catalogs/spot-orthoimages-canada-2005)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "23",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_bands(url)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_stac_layer(url, bands=[\"pan\"], name=\"Panchromatic\")\n",
- "m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"False color\")\n",
- "m.add_layer_manager()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "26",
- "metadata": {},
- "source": [
- "## Visualize vector datasets\n",
- "\n",
- "### GeoJSON"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "27",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://open.gishub.org/data/world/continents.geojson\"\n",
- "m.add_geojson(url, layer_name=\"Continents\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "28",
- "metadata": {},
- "source": [
- "### Shapefile"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "29",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://open.gishub.org/data/world/countries.zip\"\n",
- "m.add_shp(url, layer_name=\"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "30",
- "metadata": {},
- "source": [
- "### Other vector formats"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "31",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson\"\n",
- "m.add_vector(url, layer_name=\"Cable lines\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "32",
- "metadata": {},
- "source": [
- "### Vector styling"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "33",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "\n",
- "m = leafmap.Map()\n",
- "m.add_basemap(\"CartoDB.DarkMatter\")\n",
- "url = \"https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson\"\n",
- "callback = lambda feat: {\"color\": feat[\"properties\"][\"color\"]}\n",
- "m.add_vector(url, layer_name=\"Cable lines\", style_callback=callback)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "34",
- "metadata": {},
- "source": [
- "### XY coordinates"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "35",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://github.com/opengeos/leafmap/raw/master/examples/data/us_cities.csv\"\n",
- "leafmap.csv_to_df(url).head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "36",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4)\n",
- "m.add_points_from_xy(url, x=\"longitude\", y=\"latitude\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "37",
- "metadata": {},
- "source": [
- "## Split Map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "38",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[36.1, -114.9], zoom=10)\n",
- "m.add_basemap(\"HYBRID\")\n",
- "m.split_map(\n",
- " left_layer=\"NLCD 2001 CONUS Land Cover\",\n",
- " right_layer=\"NLCD 2019 CONUS Land Cover\",\n",
- " left_label=\"2001\",\n",
- " right_label=\"2019\",\n",
- ")\n",
- "m.add_layer_control()\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "39",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "before = (\n",
- " \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- ")\n",
- "after = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-09-13.tif\"\n",
- "m.split_map(before, after, left_label=\"Before\", right_label=\"After\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "40",
- "metadata": {},
- "source": [
- "## OpenAerialMap\n",
- "\n",
- "[OpenAerialMap](https://openaerialmap.org/) (OAM) provides openly licensed satellite and unmanned aerial vehicle (UAV) imagery. Currently, it has over 12,400+ images around the globe. You can search and visualize OAM imagery interactively. You can also download images automatically with one line of code."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "41",
- "metadata": {},
- "outputs": [],
- "source": [
- "bbox = [-79.6344, -0.9063, -77.3383, 1.0436]\n",
- "start_date = \"2016-04-01\"\n",
- "end_date = \"2016-04-30\"\n",
- "gdf = leafmap.oam_search(\n",
- " bbox=bbox, start_date=start_date, end_date=end_date, return_gdf=True\n",
- ")\n",
- "print(f\"Found {len(gdf)} images\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "42",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "43",
- "metadata": {},
- "source": [
- "The tile URLs are stored in the `tms` column of the GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "44",
- "metadata": {},
- "outputs": [],
- "source": [
- "tiles = gdf[\"tms\"].tolist()\n",
- "tiles[:5]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "45",
- "metadata": {},
- "source": [
- "The image sources (downloadable URLs) are stored in the uuid column of the GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "46",
- "metadata": {},
- "outputs": [],
- "source": [
- "images = gdf[\"uuid\"].tolist()\n",
- "images[:5]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "47",
- "metadata": {},
- "source": [
- "Download all images using the download_files() function."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "48",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.download_files(images[:2])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "49",
- "metadata": {},
- "source": [
- "Add the image footprints to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "50",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "\n",
- "m = leafmap.Map()\n",
- "m.add_gdf(gdf, layer_name=\"Footprints\")\n",
- "m.add_cog_layer(images[0], nodata=0, name=\"OpenAerialMap\")\n",
- "# m.add_tile_layer(tiles[0], attribution='OpenAerialMap', name='OpenAerialMap')\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "51",
- "metadata": {},
- "source": [
- "Search OAM imagery interactively using the interactive GUI."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "52",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[4.7955, -75.6899], zoom=15)\n",
- "m.add_oam_gui()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "53",
- "metadata": {},
- "source": [
- "## AWS Open Data\n",
- "\n",
- "The [AWS Open Data Program](https://registry.opendata.aws/) hosts a lots of open and public datasets on AWS, including Landsat 8, Sentinel-2, NAIP, and many more. Check out https://github.com/opengeos#data-catalogs for a list of open and public datasets on AWS."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "54",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://earth-search.aws.element84.com/v1/\"\n",
- "collection = \"sentinel-2-l2a\"\n",
- "time_range = \"2021-12-01/2021-12-31\"\n",
- "bbox = [-122.2751, 47.5469, -121.9613, 47.7458]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "55",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=10,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " query={\"eo:cloud_cover\": {\"lt\": 10}},\n",
- " sortby=[{\"field\": \"properties.eo:cloud_cover\", \"direction\": \"asc\"}],\n",
- ")\n",
- "search"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "56",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=10,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " get_collection=True,\n",
- ")\n",
- "search"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "57",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=10,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " get_gdf=True,\n",
- ")\n",
- "search.head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "58",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=10,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " get_assets=True,\n",
- ")\n",
- "search"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "59",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=10,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " get_info=True,\n",
- ")\n",
- "search"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "60",
- "metadata": {},
- "outputs": [],
- "source": [
- "search = leafmap.stac_search(\n",
- " url=url,\n",
- " max_items=10,\n",
- " collections=[collection],\n",
- " bbox=bbox,\n",
- " datetime=time_range,\n",
- " get_links=True,\n",
- ")\n",
- "search"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "61",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[37.7517, -122.4433], zoom=8)\n",
- "m.add_stac_gui()\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "62",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.stac_gdf"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "63",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.stac_dict"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "64",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.stac_item"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "65",
- "metadata": {},
- "source": [
- "## Split raster into tiles"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "66",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://open.gishub.org/data/raster/srtm90.tif\"\n",
- "m.add_cog_layer(url, name=\"Remote COG\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "67",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_raster(url, out_dir=\"tiles\", tile_size=(1000, 1000), overlap=0)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "68",
- "metadata": {},
- "outputs": [],
- "source": [
- "tiles = leafmap.find_files(\"tiles\", ext=\".tif\")\n",
- "tiles"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "69",
- "metadata": {},
- "outputs": [],
- "source": [
- "for tile in tiles[:6]:\n",
- " name = os.path.basename(tile).replace(\".tif\", \"\")\n",
- " m.add_raster(\n",
- " tile, cmap=\"terrain\", vmin=0, vmax=4000, layer_name=name, zoom_to_layer=False\n",
- " )"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "70",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_layer_manager()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "71",
- "metadata": {},
- "source": [
- "## Merge tiles into a single raster"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "72",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.merge_rasters(\"tiles\", output=\"merged.tif\", input_pattern=\"*.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "73",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(\"merged.tif\", colormap=\"terrain\", layer_name=\"Merged raster\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "74",
- "metadata": {},
- "source": [
- "## Zonal statistics"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "75",
- "metadata": {},
- "outputs": [],
- "source": [
- "dsm = \"https://open.gishub.org/data/elevation/dsm.tif\"\n",
- "hag = \"https://open.gishub.org/data/elevation/hag.tif\"\n",
- "buildings = \"https://open.gishub.org/data/elevation/buildings.geojson\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "76",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_cog_layer(dsm, name=\"DSM\", palette=\"terrain\")\n",
- "m.add_cog_layer(hag, name=\"Height Above Ground\", palette=\"magma\")\n",
- "m.add_geojson(buildings, layer_name=\"Buildings\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "77",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = gpd.read_file(buildings)\n",
- "len(gdf)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "78",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf.head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "79",
- "metadata": {},
- "outputs": [],
- "source": [
- "types = [\"min\", \"max\", \"mean\", \"std\", \"count\"]\n",
- "gdf = leafmap.zonal_stats(gdf, hag, stats=types, gdf_out=True)\n",
- "gdf"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "80",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_gdf(gdf, layer_name=\"Zonal Stats\")\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/workshops/FOSS4G_2021.ipynb b/examples/workshops/FOSS4G_2021.ipynb
deleted file mode 100644
index c89fc955fa..0000000000
--- a/examples/workshops/FOSS4G_2021.ipynb
+++ /dev/null
@@ -1,3509 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/FOSS4G_2021.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://gishub.org/foss4g-colab)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/foss4g-binder)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/foss4g-binder-nb)\n",
- "![](https://i.imgur.com/fag5KRb.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "1",
- "metadata": {},
- "source": [
- "**Using Leafmap for Geospatial Analysis and Data Visualization**\n",
- "\n",
- "\n",
- "This notebook was developed for the [leafmap workshop](https://callforpapers.2021.foss4g.org/foss4g-2021-workshop/talk/VAHX9A/) taking place on September 27, 2021 at the [FOSS4G 2021 Conference](https://2021.foss4g.org/).\n",
- "\n",
- "Author: [Qiusheng Wu](https://github.com/giswqs)\n",
- "\n",
- "Launch this notebook to execute code interactively using: \n",
- "- Google Colab: https://gishub.org/foss4g-colab\n",
- "- Pangeo Binder JupyterLab: https://gishub.org/foss4g-binder\n",
- "- Pangeo Binder Jupyter Notebook: https://gishub.org/foss4g-binder-nb\n",
- "\n",
- "\n",
- "## Introduction\n",
- "\n",
- "### Workshop description\n",
- "\n",
- "[Leafmap](https://leafmap.org) is a Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment. It is built upon a number of open-source packages, such as [folium](https://github.com/python-visualization/folium) and [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet) (for creating interactive maps), [WhiteboxTools](https://github.com/jblindsay/whitebox-tools) and [whiteboxgui](https://github.com/opengeos/whiteboxgui) (for analyzing geospatial data), and [ipywidgets](https://github.com/jupyter-widgets/ipywidgets) (for designing interactive graphical user interface). The WhiteboxTools library currently contains 480+ tools for advanced geospatial analysis. Leafmap provides many convenient functions for loading and visualizing geospatial data with only one line of code. Users can also use the interactive user interface to load geospatial data without coding. Anyone with a web browser and Internet connection can use leafmap to perform geospatial analysis and data visualization in the cloud with minimal coding. The topics that will be covered in this workshop include: \n",
- "\n",
- "1. Creating interactive maps\n",
- "2. Changing basemaps\n",
- "3. Loading and visualizing vector/raster data\n",
- "4. Using Cloud Optimized GeoTIFF (COG) and SpatialTemporal Asset Catalog (STAC)\n",
- "5. Downloading OpenStreetMap data\n",
- "6. Loading data from a PostGIS database\n",
- "7. Creating custom legends and colorbars\n",
- "8. Creating split-panel maps and linked maps\n",
- "9. Visualizing Planet global monthly/quarterly mosaic\n",
- "10. Designing and publishing interactive web apps\n",
- "11. Performing geospatial analysis (e.g., hydrological analysis and LiDAR data analysis) using whiteboxgui.\n",
- "\n",
- "This workshop is intended for scientific programmers, data scientists, geospatial analysts, and concerned citizens of Earth. The attendees are expected to have a basic understanding of Python and the Jupyter ecosystem. Familiarity with Earth science and geospatial datasets is useful but not required. More information about leafmap can be found at https://leafmap.org\n",
- "\n",
- "\n",
- "### Jupyter keyboard shortcuts\n",
- "\n",
- "- Shift+Enter: run cell, select below\n",
- "- Ctrl+Enter: : run selected cells\n",
- "- Alt+Enter: run cell and insert below\n",
- "- Tab: code completion or indent\n",
- "- Shift+Tab: tooltip\n",
- "- Ctrl+/: comment out code"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "## Set up environment\n",
- "\n",
- "### Required Python packages:\n",
- "* [leafmap](https://github.com/opengeos/leafmap) - A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment\n",
- "* [geopandas](https://geopandas.org) - An open source project to make working with geospatial data in python easier. \n",
- "* [keplergl](https://docs.kepler.gl/docs/keplergl-jupyter) - A high-performance web-based application for visual exploration of large-scale geolocation data sets\n",
- "* [datapane](https://datapane.com) - A Python library for building interactive reports in seconds\n",
- "* [xarray-leaflet](https://github.com/davidbrochart/xarray_leaflet) - An xarray extension for tiled map plotting\n",
- "\n",
- "### Required API keys\n",
- "- [HERE Map](https://developer.here.com) API key\n",
- "- [datapane](https://datapane.com) API key\n",
- "- [Planet](https://www.planet.com/nicfi) API key\n",
- "\n",
- "### Use Google Colab\n",
- "\n",
- "Click the button below to open this notebook in Google Colab and execute code interactively.\n",
- "\n",
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/FOSS4G_2021.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/workshops/foss4g_2021.ipynb)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import subprocess\n",
- "import sys"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "import warnings\n",
- "\n",
- "warnings.filterwarnings(\"ignore\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "A function for installing Python packages."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "def install(package):\n",
- " subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", package])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Install required Python packages in Google Colab."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "pkgs = [\n",
- " \"leafmap\",\n",
- " \"geopandas\",\n",
- " \"keplergl\",\n",
- " \"datapane\",\n",
- " \"xarray_leaflet\",\n",
- " \"osmnx\",\n",
- " \"pygeos\",\n",
- " \"imageio\",\n",
- " \"tifffile\",\n",
- "]\n",
- "if \"google.colab\" in sys.modules:\n",
- " for pkg in pkgs:\n",
- " install(pkg)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "### Use Pangeo Binder\n",
- "\n",
- "Click the buttons below to open this notebook in JupyterLab (first button) or Jupyter Notebook (second button) and execute code interactively.\n",
- "\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/foss4g-binder)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/foss4g-binder-nb)\n",
- "\n",
- "- JupyterLab: https://gishub.org/foss4g-binder\n",
- "- Jupyter Notebook: https://gishub.org/foss4g-binder-nb"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "### Use Miniconda/Anaconda\n",
- "\n",
- "If you have\n",
- "[Anaconda](https://www.anaconda.com/distribution/#download-section) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html) installed on your computer, you can install leafmap using the following commands. Leafmap has an optional dependency - [geopandas](https://geopandas.org), which can be challenging to install on some computers, especially Windows. It is highly recommended that you create a fresh conda environment to install geopandas and leafmap. Follow the commands below to set up a conda env and install geopandas, leafmap, datapane, keplergl, and xarray_leaflet. \n",
- "\n",
- "```\n",
- "conda create -n geo python=3.9\n",
- "conda activate geo\n",
- "conda install geopandas\n",
- "conda install mamba -c conda-forge\n",
- "mamba install leafmap datapane keplergl xarray_leaflet -c conda-forge\n",
- "mamba install osmnx pygeos imageio tifffile -c conda-forge\n",
- "jupyter lab\n",
- "```"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " import leafmap\n",
- "except ImportError:\n",
- " install(\"leafmap\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "## Create an interactive map\n",
- "\n",
- "`leafmap` has four plotting backends: [folium](https://github.com/python-visualization/folium), [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet), [here-map](https://github.com/heremaps/here-map-widget-for-jupyter), and [kepler.gl](https://docs.kepler.gl/docs/keplergl-jupyter). Note that the backends do not offer equal functionality. Some interactive functionality in `ipyleaflet` might not be available in other plotting backends. To use a specific plotting backend, use one of the following:\n",
- "\n",
- "- `import leafmap.leafmap as leafmap`\n",
- "- `import leafmap.foliumap as leafmap`\n",
- "- `import leafmap.heremap as leafmap`\n",
- "- `import leafmap.kepler as leafmap`\n",
- "\n",
- "\n",
- "### Use ipyleaflet"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "15",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "16",
- "metadata": {},
- "source": [
- "## Customize the default map\n",
- "\n",
- "### Specify map center and zoom level"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "17",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(40, -100), zoom=4) # center=[lat, lon]\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(51.5, -0.15), zoom=17)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "### Change map size"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(height=\"400px\", width=\"800px\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "### Set control visibility\n",
- "\n",
- "When creating a map, set the following controls to either `True` or `False` as appropriate.\n",
- "\n",
- "* attribution_control\n",
- "* draw_control\n",
- "* fullscreen_control\n",
- "* layers_control\n",
- "* measure_control\n",
- "* scale_control\n",
- "* toolbar_control"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " draw_control=False,\n",
- " measure_control=False,\n",
- " fullscreen_control=False,\n",
- " attribution_control=False,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "23",
- "metadata": {},
- "source": [
- "Remove all controls from the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "24",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.clear_controls()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "25",
- "metadata": {},
- "source": [
- "## Change basemaps\n",
- "\n",
- "Specify a Google basemap to use, can be one of [\"ROADMAP\", \"TERRAIN\", \"SATELLITE\", \"HYBRID\"]."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(google_map=\"TERRAIN\") # HYBRID, ROADMAP, SATELLITE, TERRAIN\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27",
- "metadata": {},
- "source": [
- "Add a basemap using the `add_basemap()` function."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "28",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "29",
- "metadata": {},
- "source": [
- "Print out the list of available basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "30",
- "metadata": {},
- "outputs": [],
- "source": [
- "for basemap in leafmap.basemaps:\n",
- " print(basemap[:5])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "31",
- "metadata": {},
- "source": [
- "## Add tile layers\n",
- "\n",
- "### Add XYZ tile layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "32",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_tile_layer(\n",
- " url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\",\n",
- " name=\"Google Satellite\",\n",
- " attribution=\"Google\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "33",
- "metadata": {},
- "source": [
- "### Add WMS tile layer\n",
- "\n",
- "More WMS basemaps can be found at the following websites:\n",
- "\n",
- "- USGS National Map: https://viewer.nationalmap.gov/services\n",
- "- MRLC NLCD Land Cover data: https://www.mrlc.gov/data-services-page\n",
- "- FWS NWI Wetlands data: https://www.fws.gov/wetlands/Data/Web-Map-Services.html"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "34",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "naip_url = \"https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url=naip_url, layers=\"0\", name=\"NAIP Imagery\", format=\"image/png\", shown=True\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "35",
- "metadata": {},
- "source": [
- "### Add xyzservices provider\n",
- "\n",
- "Add a layer from [xyzservices](https://github.com/geopandas/xyzservices) provider object."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "36",
- "metadata": {},
- "outputs": [],
- "source": [
- "import xyzservices.providers as xyz"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "37",
- "metadata": {},
- "outputs": [],
- "source": [
- "basemap = xyz.CartoDB.DarkMatter\n",
- "basemap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "38",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(basemap)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "39",
- "metadata": {},
- "source": [
- "## Add vector tile layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "40",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "41",
- "metadata": {},
- "source": [
- "The URL to the vector tile."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "42",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://tile.nextzen.org/tilezen/vector/v1/512/all/{z}/{x}/{y}.mvt?api_key=gCZXZglvRQa6sB2z7JzL1w\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "43",
- "metadata": {},
- "source": [
- "Attribution of the vector tile."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "44",
- "metadata": {},
- "outputs": [],
- "source": [
- "attribution = \"Nextzen\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "45",
- "metadata": {},
- "source": [
- "One can customize the vector tile layer style if needed. More info can be found at https://ipyleaflet.readthedocs.io/en/latest/api_reference/vector_tile.html"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "46",
- "metadata": {},
- "outputs": [],
- "source": [
- "vector_tile_layer_styles = {}"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "47",
- "metadata": {},
- "source": [
- "Add the vector tile layer to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "48",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_vector_tile_layer(url, attribution, vector_tile_layer_styles)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "49",
- "metadata": {},
- "source": [
- "## Add COG/STAC layers\n",
- "\n",
- "A Cloud Optimized GeoTIFF (COG) is a regular GeoTIFF file, aimed at being hosted on a HTTP file server, with an internal organization that enables more efficient workflows on the cloud. It does this by leveraging the ability of clients issuing HTTP GET range requests to ask for just the parts of a file they need. \n",
- "\n",
- "More information about COG can be found at \n",
- "\n",
- "Some publicly available Cloud Optimized GeoTIFFs:\n",
- "\n",
- "* https://stacindex.org/\n",
- "* https://cloud.google.com/storage/docs/public-datasets/landsat\n",
- "* https://www.digitalglobe.com/ecosystem/open-data\n",
- "* https://earthexplorer.usgs.gov/\n",
- "\n",
- "For this demo, we will use data from https://www.maxar.com/open-data/california-colorado-fires for mapping California and Colorado fires. A list of COGs can be found [here](https://github.com/opengeos/leafmap/blob/master/examples/data/cog_files.txt).\n",
- "\n",
- "### Add COG layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "50",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- "url2 = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-09-13.tif\"\n",
- "\n",
- "m.add_cog_layer(url, name=\"Fire (pre-event)\")\n",
- "m.add_cog_layer(url2, name=\"Fire (post-event)\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "51",
- "metadata": {},
- "source": [
- "Retrieve the bounding box coordinates of the COG file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "52",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.cog_bounds(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "53",
- "metadata": {},
- "source": [
- "Retrieve the centroid coordinates of the COG file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "54",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.cog_center(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "55",
- "metadata": {},
- "source": [
- "Retrieves the tile layer URL of the COG file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "56",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.cog_tile(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "57",
- "metadata": {},
- "source": [
- "### Add STAC layer\n",
- "\n",
- "The SpatioTemporal Asset Catalog (STAC) specification provides a common language to describe a range of geospatial information, so it can more easily be indexed and discovered. A 'spatiotemporal asset' is any file that represents information about the earth captured in a certain space and time. The initial focus is primarily remotely-sensed imagery (from satellites, but also planes, drones, balloons, etc), but the core is designed to be extensible to SAR, full motion video, point clouds, hyperspectral, LiDAR and derived data like NDVI, Digital Elevation Models, mosaics, etc. More information about STAC can be found at https://stacspec.org/\n",
- "\n",
- "Some publicly available SpatioTemporal Asset Catalog (STAC):\n",
- "\n",
- "* https://stacindex.org\n",
- "\n",
- "For this demo, we will use STAC assets from https://stacindex.org/catalogs/spot-orthoimages-canada-2005#/?t=catalogs"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "58",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\"\n",
- "m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"False color\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "59",
- "metadata": {},
- "source": [
- "Retrieve the bounding box coordinates of the STAC file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "60",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_bounds(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "61",
- "metadata": {},
- "source": [
- "Retrieve the centroid coordinates of the STAC file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "62",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_center(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "63",
- "metadata": {},
- "source": [
- "Retrieve the band names of the STAC file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "64",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_bands(url)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "65",
- "metadata": {},
- "source": [
- "Retrieve the tile layer URL of the STAC file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "66",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.stac_tile(url, bands=[\"B3\", \"B2\", \"B1\"])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "67",
- "metadata": {},
- "source": [
- "## Add local raster datasets\n",
- "\n",
- "The `add_raster` function relies on the `xarray_leaflet` package and is only available for the ipyleaflet plotting backend. Therefore, Google Colab is not supported. Note that `xarray_leaflet` does not work properly on Windows ([source](https://github.com/davidbrochart/xarray_leaflet/issues/30))."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "68",
- "metadata": {},
- "source": [
- "Download samples raster datasets\n",
- "\n",
- "More datasets can be downloaded from https://viewer.nationalmap.gov/basic/"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "69",
- "metadata": {},
- "outputs": [],
- "source": [
- "landsat = \"landsat.tif\"\n",
- "dem = \"dem.tif\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "70",
- "metadata": {},
- "source": [
- "Download a small Landsat imagery."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "71",
- "metadata": {},
- "outputs": [],
- "source": [
- "landsat_url = (\n",
- " \"https://drive.google.com/file/d/1EV38RjNxdwEozjc9m0FcO3LFgAoAX1Uw/view?usp=sharing\"\n",
- ")\n",
- "leafmap.download_file(landsat_url, \"landsat.tif\", unzip=False)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "72",
- "metadata": {},
- "source": [
- "Download a small DEM dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "73",
- "metadata": {},
- "outputs": [],
- "source": [
- "dem_url = (\n",
- " \"https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing\"\n",
- ")\n",
- "leafmap.download_file(dem_url, \"dem.tif\", unzip=False)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "74",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "75",
- "metadata": {},
- "source": [
- "Add local raster datasets to the map\n",
- "\n",
- "More colormap can be found at https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "76",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(dem, colormap=\"terrain\", layer_name=\"DEM\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "77",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(landsat, bands=[5, 4, 3], layer_name=\"Landsat\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "78",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "79",
- "metadata": {},
- "source": [
- "## Add legend\n",
- "\n",
- "### Add built-in legend"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "80",
- "metadata": {},
- "source": [
- "List all available built-in legends."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "81",
- "metadata": {},
- "outputs": [],
- "source": [
- "legends = leafmap.builtin_legends\n",
- "for legend in legends:\n",
- " print(legend)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "82",
- "metadata": {},
- "source": [
- "Add a WMS layer and built-in legend to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "83",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?\"\n",
- "m.add_wms_layer(\n",
- " url,\n",
- " layers=\"NLCD_2019_Land_Cover_L48\",\n",
- " name=\"NLCD 2019 CONUS Land Cover\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "m.add_legend(builtin_legend=\"NLCD\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "84",
- "metadata": {},
- "source": [
- "Add U.S. National Wetlands Inventory (NWI). More info at https://www.fws.gov/wetlands."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "85",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(google_map=\"HYBRID\")\n",
- "\n",
- "url1 = \"https://www.fws.gov/wetlands/arcgis/services/Wetlands/MapServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url1, layers=\"1\", format=\"image/png\", transparent=True, name=\"NWI Wetlands Vector\"\n",
- ")\n",
- "\n",
- "url2 = \"https://www.fws.gov/wetlands/arcgis/services/Wetlands_Raster/ImageServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url2, layers=\"0\", format=\"image/png\", transparent=True, name=\"NWI Wetlands Raster\"\n",
- ")\n",
- "\n",
- "m.add_legend(builtin_legend=\"NWI\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "86",
- "metadata": {},
- "source": [
- "### Add custom legend\n",
- "\n",
- "There are two ways you can add custom legends:\n",
- "\n",
- "1. Define legend labels and colors\n",
- "2. Define legend dictionary\n",
- "\n",
- "Define legend keys and colors"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "87",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "labels = [\"One\", \"Two\", \"Three\", \"Four\", \"etc\"]\n",
- "# color can be defined using either hex code or RGB (0-255, 0-255, 0-255)\n",
- "colors = [\"#8DD3C7\", \"#FFFFB3\", \"#BEBADA\", \"#FB8072\", \"#80B1D3\"]\n",
- "# colors = [(255, 0, 0), (127, 255, 0), (127, 18, 25), (36, 70, 180), (96, 68, 123)]\n",
- "\n",
- "m.add_legend(title=\"Legend\", labels=labels, colors=colors)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "88",
- "metadata": {},
- "source": [
- "Define a legend dictionary."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "89",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?\"\n",
- "m.add_wms_layer(\n",
- " url,\n",
- " layers=\"NLCD_2019_Land_Cover_L48\",\n",
- " name=\"NLCD 2019 CONUS Land Cover\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "\n",
- "legend_dict = {\n",
- " \"11 Open Water\": \"466b9f\",\n",
- " \"12 Perennial Ice/Snow\": \"d1def8\",\n",
- " \"21 Developed, Open Space\": \"dec5c5\",\n",
- " \"22 Developed, Low Intensity\": \"d99282\",\n",
- " \"23 Developed, Medium Intensity\": \"eb0000\",\n",
- " \"24 Developed High Intensity\": \"ab0000\",\n",
- " \"31 Barren Land (Rock/Sand/Clay)\": \"b3ac9f\",\n",
- " \"41 Deciduous Forest\": \"68ab5f\",\n",
- " \"42 Evergreen Forest\": \"1c5f2c\",\n",
- " \"43 Mixed Forest\": \"b5c58f\",\n",
- " \"51 Dwarf Scrub\": \"af963c\",\n",
- " \"52 Shrub/Scrub\": \"ccb879\",\n",
- " \"71 Grassland/Herbaceous\": \"dfdfc2\",\n",
- " \"72 Sedge/Herbaceous\": \"d1d182\",\n",
- " \"73 Lichens\": \"a3cc51\",\n",
- " \"74 Moss\": \"82ba9e\",\n",
- " \"81 Pasture/Hay\": \"dcd939\",\n",
- " \"82 Cultivated Crops\": \"ab6c28\",\n",
- " \"90 Woody Wetlands\": \"b8d9eb\",\n",
- " \"95 Emergent Herbaceous Wetlands\": \"6c9fb8\",\n",
- "}\n",
- "\n",
- "m.add_legend(legend_title=\"NLCD Land Cover Classification\", legend_dict=legend_dict)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "90",
- "metadata": {},
- "source": [
- "## Add colorbar\n",
- "\n",
- "### Continuous color\n",
- "\n",
- "Add a continuous colorbar with a custom palette to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "91",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"USGS 3DEP Elevation\")\n",
- "colors = [\"006633\", \"E5FFCC\", \"662A00\", \"D8D8D8\", \"F5F5F5\"]\n",
- "m.add_colorbar(colors=colors, vmin=0, vmax=4000)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "92",
- "metadata": {},
- "source": [
- "### Categorical colorbar"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "93",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "url = \"https://elevation.nationalmap.gov/arcgis/services/3DEPElevation/ImageServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url,\n",
- " layers=\"3DEPElevation:Hillshade Elevation Tinted\",\n",
- " name=\"USGS 3DEP Elevation\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "\n",
- "colors = [\"006633\", \"E5FFCC\", \"662A00\", \"D8D8D8\", \"F5F5F5\"]\n",
- "m.add_colorbar(colors=colors, vmin=0, vmax=4000, categorical=True, step=4)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "94",
- "metadata": {},
- "source": [
- "## Add colormap\n",
- "\n",
- "The colormap functionality requires the ipyleaflet plotting backend. Folium is not supported."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "95",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.colormaps as cm"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "96",
- "metadata": {},
- "source": [
- "### Common colormaps\n",
- "\n",
- "Color palette for DEM data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "97",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.palettes.dem"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "98",
- "metadata": {},
- "source": [
- "Show the DEM palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "99",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=cm.palettes.dem, axis_off=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "100",
- "metadata": {},
- "source": [
- "Color palette for NDVI data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "101",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.palettes.ndvi"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "102",
- "metadata": {},
- "source": [
- "Show the NDVI palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "103",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=cm.palettes.ndvi)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "104",
- "metadata": {},
- "source": [
- "### Custom colormaps\n",
- "\n",
- "Specify the number of classes for a palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "105",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.get_palette(\"terrain\", n_class=8)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "106",
- "metadata": {},
- "source": [
- "Show the terrain palette with 8 classes."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "107",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=cm.get_palette(\"terrain\", n_class=8))"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "108",
- "metadata": {},
- "source": [
- "Create a palette with custom colors, label, and font size."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "109",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=[\"red\", \"green\", \"blue\"], label=\"Temperature\", font_size=12)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "110",
- "metadata": {},
- "source": [
- "Create a discrete color palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "111",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(\n",
- " colors=[\"red\", \"green\", \"blue\"], discrete=True, label=\"Temperature\", font_size=12\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "112",
- "metadata": {},
- "source": [
- "Specify the width and height for the palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "113",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=8.0,\n",
- " height=0.4,\n",
- " orientation=\"horizontal\",\n",
- " vmin=0,\n",
- " vmax=1000,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "114",
- "metadata": {},
- "source": [
- "Change the orentation of the colormap to be vertical."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "115",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=0.4,\n",
- " height=4,\n",
- " orientation=\"vertical\",\n",
- " vmin=0,\n",
- " vmax=1000,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "116",
- "metadata": {},
- "source": [
- "### Horizontal colormap\n",
- "\n",
- "Add a horizontal colorbar to an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "117",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=8.0,\n",
- " height=0.4,\n",
- " orientation=\"horizontal\",\n",
- " vmin=0,\n",
- " vmax=4000,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "118",
- "metadata": {},
- "source": [
- "### Vertical colormap\n",
- "\n",
- "Add a vertical colorbar to an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "119",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=0.4,\n",
- " height=4,\n",
- " orientation=\"vertical\",\n",
- " vmin=0,\n",
- " vmax=4000,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "120",
- "metadata": {},
- "source": [
- "### List of available colormaps"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "121",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormaps(width=12, height=0.4)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "122",
- "metadata": {},
- "source": [
- "## Add vector datasets\n",
- "\n",
- "### Add CSV\n",
- "\n",
- "Read a CSV as a Pandas DataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "123",
- "metadata": {},
- "outputs": [],
- "source": [
- "in_csv = \"https://raw.githubusercontent.com/opengeos/data/main/world/world_cities.csv\"\n",
- "df = leafmap.csv_to_df(in_csv)\n",
- "df"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "124",
- "metadata": {},
- "source": [
- "Create a point layer from a CSV file containing lat/long information."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "125",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_xy_data(in_csv, x=\"longitude\", y=\"latitude\", layer_name=\"World Cities\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "126",
- "metadata": {},
- "source": [
- "Set the output directory."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "127",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_dir = os.getcwd()\n",
- "out_shp = os.path.join(out_dir, \"world_cities.shp\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "128",
- "metadata": {},
- "source": [
- "Convert a CSV file containing lat/long information to a shapefile."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "129",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.csv_to_shp(in_csv, out_shp)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "130",
- "metadata": {},
- "source": [
- "Convert a CSV file containing lat/long information to a GeoJSON."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "131",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_geojson = os.path.join(out_dir, \"world_cities.geojson\")\n",
- "leafmap.csv_to_geojson(in_csv, out_geojson)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "132",
- "metadata": {},
- "source": [
- "Convert a CSV file containing lat/long information to a GeoPandas GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "133",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = leafmap.csv_to_gdf(in_csv)\n",
- "gdf"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "134",
- "metadata": {},
- "source": [
- "### Add GeoJSON\n",
- "\n",
- "Add a GeoJSON to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "135",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "in_geojson = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cable_geo.geojson\"\n",
- "m.add_geojson(in_geojson, layer_name=\"Cable lines\", info_mode=\"on_hover\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "136",
- "metadata": {},
- "source": [
- "Add a GeoJSON with random filled color to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "137",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "m.add_geojson(\n",
- " url, layer_name=\"Countries\", fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"]\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "138",
- "metadata": {},
- "source": [
- "Use the `style_callback` function for assigning a random color to each polygon."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "139",
- "metadata": {},
- "outputs": [],
- "source": [
- "import random\n",
- "\n",
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "\n",
- "\n",
- "def random_color(feature):\n",
- " return {\n",
- " \"color\": \"black\",\n",
- " \"fillColor\": random.choice([\"red\", \"yellow\", \"green\", \"orange\"]),\n",
- " }\n",
- "\n",
- "\n",
- "m.add_geojson(url, layer_name=\"Countries\", style_callback=random_color)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "140",
- "metadata": {},
- "source": [
- "Use custom `style` and `hover_style` functions."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "141",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "style = {\n",
- " \"stroke\": True,\n",
- " \"color\": \"#0000ff\",\n",
- " \"weight\": 2,\n",
- " \"opacity\": 1,\n",
- " \"fill\": True,\n",
- " \"fillColor\": \"#0000ff\",\n",
- " \"fillOpacity\": 0.1,\n",
- "}\n",
- "hover_style = {\"fillOpacity\": 0.7}\n",
- "m.add_geojson(url, layer_name=\"Countries\", style=style, hover_style=hover_style)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "142",
- "metadata": {},
- "source": [
- "### Add shapefile"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "143",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "in_shp = \"https://github.com/opengeos/leafmap/raw/master/examples/data/countries.zip\"\n",
- "m.add_shp(in_shp, layer_name=\"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "144",
- "metadata": {},
- "source": [
- "### Add KML"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "145",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "in_kml = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_states.kml\"\n",
- "m.add_kml(in_kml, layer_name=\"US States KML\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "146",
- "metadata": {},
- "source": [
- "### Add GeoDataFrame"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "147",
- "metadata": {},
- "outputs": [],
- "source": [
- "import geopandas as gpd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "148",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "gdf = gpd.read_file(\n",
- " \"https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson\"\n",
- ")\n",
- "m.add_gdf(gdf, layer_name=\"Cable lines\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "149",
- "metadata": {},
- "source": [
- "Read the GeoPandas sample dataset as a GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "150",
- "metadata": {},
- "outputs": [],
- "source": [
- "path_to_data = (\n",
- " \"https://github.com/opengeos/datasets/releases/download/vector/nybb.geojson\"\n",
- ")\n",
- "gdf = gpd.read_file(path_to_data)\n",
- "gdf"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "151",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_gdf(gdf, layer_name=\"New York boroughs\", fill_colors=[\"red\", \"green\", \"blue\"])\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "152",
- "metadata": {},
- "source": [
- "### Add point layer\n",
- "\n",
- "Add a point layer using the interactive GUI.\n",
- "\n",
- "![](https://i.imgur.com/1QVEtlN.gif)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "153",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "154",
- "metadata": {},
- "source": [
- "Add a point layer programmatically."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "155",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.geojson\"\n",
- "m.add_point_layer(url, popup=[\"name\", \"pop_max\"], layer_name=\"US Cities\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "156",
- "metadata": {},
- "source": [
- "### Add vector\n",
- "\n",
- "The `add_vector` function supports any vector data format supported by GeoPandas."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "157",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "m.add_vector(\n",
- " url, layer_name=\"Countries\", fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"]\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "158",
- "metadata": {},
- "source": [
- "## Download OSM data\n",
- "\n",
- "### OSM from geocode\n",
- "\n",
- "Add OSM data of place(s) by name or ID to the map. Note that the leafmap custom layer control does not support GeoJSON, we need to use the ipyleaflet built-in layer control."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "159",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_geocode(\"New York City\", layer_name=\"NYC\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "160",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_geocode(\"Chicago, Illinois\", layer_name=\"Chicago, IL\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "161",
- "metadata": {},
- "source": [
- "### OSM from place\n",
- "\n",
- "Add OSM entities within boundaries of geocodable place(s) to the map."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "162",
- "metadata": {},
- "source": [
- "Show OSM feature tags.\n",
- "https://wiki.openstreetmap.org/wiki/Map_features"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "163",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.osm_tags_list()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "164",
- "metadata": {},
- "source": [
- "### OSM from address"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "165",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_address(\n",
- " address=\"New York City\", tags={\"amenity\": \"bar\"}, dist=1500, layer_name=\"NYC bars\"\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "166",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_address(\n",
- " address=\"New York City\",\n",
- " tags={\"landuse\": [\"retail\", \"commercial\"], \"building\": True},\n",
- " dist=1000,\n",
- " layer_name=\"NYC buildings\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "167",
- "metadata": {},
- "source": [
- "### OSM from bbox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "168",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "north, south, east, west = 40.7551, 40.7454, -73.9738, -73.9965\n",
- "m.add_osm_from_bbox(\n",
- " north, south, east, west, tags={\"amenity\": \"bar\"}, layer_name=\"NYC bars\"\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "169",
- "metadata": {},
- "source": [
- "### OSM from point\n",
- "\n",
- "Add OSM entities within some distance N, S, E, W of a point to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "170",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " center=[46.7808, -96.0156], zoom=12, toolbar_control=False, layers_control=True\n",
- ")\n",
- "m.add_osm_from_point(\n",
- " center_point=(46.7808, -96.0156),\n",
- " tags={\"natural\": \"water\"},\n",
- " dist=10000,\n",
- " layer_name=\"Lakes\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "171",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " center=[39.9170, 116.3908], zoom=15, toolbar_control=False, layers_control=True\n",
- ")\n",
- "m.add_osm_from_point(\n",
- " center_point=(39.9170, 116.3908),\n",
- " tags={\"building\": True, \"natural\": \"water\"},\n",
- " dist=1000,\n",
- " layer_name=\"Beijing\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "172",
- "metadata": {},
- "source": [
- "### OSM from view\n",
- "\n",
- "Add OSM entities within the current map view to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "173",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.set_center(-73.9854, 40.7500, 16)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "174",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_osm_from_view(tags={\"amenity\": \"bar\", \"building\": True}, layer_name=\"New York\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "175",
- "metadata": {},
- "source": [
- "Create a GeoPandas GeoDataFrame from place."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "176",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = leafmap.osm_gdf_from_place(\"New York City\", tags={\"amenity\": \"bar\"})\n",
- "gdf"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "177",
- "metadata": {},
- "source": [
- "## Use WhiteboxTools\n",
- "\n",
- "Use the built-in toolbox to perform geospatial analysis. For example, you can perform depression filling using the sample DEM dataset downloaded in the above step.\n",
- "\n",
- "![](https://i.imgur.com/KGHly63.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "178",
- "metadata": {},
- "source": [
- "Download a sample DEM dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "179",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://github.com/opengeos/whitebox-python/raw/master/whitebox/testdata/DEM.tif\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "180",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.download_file(url, \"dem.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "181",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "182",
- "metadata": {},
- "source": [
- "Display the toolbox using the default mode."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "183",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.whiteboxgui()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "184",
- "metadata": {},
- "source": [
- "Display the toolbox using the collapsible tree mode. Note that the tree mode does not support Google Colab."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "185",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.whiteboxgui(tree=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "186",
- "metadata": {},
- "source": [
- "Perform geospatial analysis using the [whitebox](https://github.com/opengeos/whitebox-python) package."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "187",
- "metadata": {},
- "outputs": [],
- "source": [
- "import whitebox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "188",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt = whitebox.WhiteboxTools()\n",
- "wbt.verbose = False"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "189",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.version()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "190",
- "metadata": {},
- "outputs": [],
- "source": [
- "data_dir = os.getcwd()\n",
- "wbt.set_working_dir(data_dir)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "191",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.feature_preserving_smoothing(\"dem.tif\", \"smoothed.tif\", filter=9)\n",
- "wbt.breach_depressions(\"smoothed.tif\", \"breached.tif\")\n",
- "wbt.d_inf_flow_accumulation(\"breached.tif\", \"flow_accum.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "192",
- "metadata": {},
- "outputs": [],
- "source": [
- "import matplotlib.pyplot as plt\n",
- "import imageio\n",
- "\n",
- "%matplotlib inline"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "193",
- "metadata": {},
- "outputs": [],
- "source": [
- "original = imageio.imread(os.path.join(data_dir, \"dem.tif\"))\n",
- "smoothed = imageio.imread(os.path.join(data_dir, \"smoothed.tif\"))\n",
- "breached = imageio.imread(os.path.join(data_dir, \"breached.tif\"))\n",
- "flow_accum = imageio.imread(os.path.join(data_dir, \"flow_accum.tif\"))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "194",
- "metadata": {},
- "outputs": [],
- "source": [
- "fig = plt.figure(figsize=(16, 11))\n",
- "\n",
- "ax1 = fig.add_subplot(2, 2, 1)\n",
- "ax1.set_title(\"Original DEM\")\n",
- "plt.imshow(original)\n",
- "\n",
- "ax2 = fig.add_subplot(2, 2, 2)\n",
- "ax2.set_title(\"Smoothed DEM\")\n",
- "plt.imshow(smoothed)\n",
- "\n",
- "ax3 = fig.add_subplot(2, 2, 3)\n",
- "ax3.set_title(\"Breached DEM\")\n",
- "plt.imshow(breached)\n",
- "\n",
- "ax4 = fig.add_subplot(2, 2, 4)\n",
- "ax4.set_title(\"Flow Accumulation\")\n",
- "plt.imshow(flow_accum)\n",
- "\n",
- "plt.show()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "195",
- "metadata": {},
- "source": [
- "## Create basemap gallery"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "196",
- "metadata": {},
- "outputs": [],
- "source": [
- "for basemap in leafmap.basemaps:\n",
- " print(basemap)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "197",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = list(leafmap.basemaps.keys())[17:117]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "198",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.linked_maps(rows=20, cols=5, height=\"200px\", layers=layers, labels=layers)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "199",
- "metadata": {},
- "source": [
- "## Create linked map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "200",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.basemaps.keys()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "201",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = [\"ROADMAP\", \"HYBRID\"]\n",
- "leafmap.linked_maps(rows=1, cols=2, height=\"400px\", layers=layers)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "202",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = [\"Esri.WorldTopoMap\", \"OpenTopoMap\"]\n",
- "leafmap.linked_maps(rows=1, cols=2, height=\"400px\", layers=layers)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "203",
- "metadata": {},
- "source": [
- "Create a 2 * 2 linked map to visualize land cover change. Specify the `center` and `zoom` parameters to change the default map center and zoom level."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "204",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = [str(f\"NLCD {year} CONUS Land Cover\") for year in [2001, 2006, 2011, 2016]]\n",
- "labels = [str(f\"NLCD {year}\") for year in [2001, 2006, 2011, 2016]]\n",
- "leafmap.linked_maps(\n",
- " rows=2,\n",
- " cols=2,\n",
- " height=\"300px\",\n",
- " layers=layers,\n",
- " labels=labels,\n",
- " center=[36.1, -115.2],\n",
- " zoom=9,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "205",
- "metadata": {},
- "source": [
- "## Create split-panel map\n",
- "\n",
- "Create a split-panel map by specifying the `left_layer` and `right_layer`, which can be chosen from the basemap names, or any custom XYZ tile layer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "206",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_map(left_layer=\"ROADMAP\", right_layer=\"HYBRID\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "207",
- "metadata": {},
- "source": [
- "Hide the zoom control from the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "208",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_map(\n",
- " left_layer=\"Esri.WorldTopoMap\", right_layer=\"OpenTopoMap\", zoom_control=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "209",
- "metadata": {},
- "source": [
- "Add labels to the map and change the default map center and zoom level."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "210",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_map(\n",
- " left_layer=\"NLCD 2001 CONUS Land Cover\",\n",
- " right_layer=\"NLCD 2019 CONUS Land Cover\",\n",
- " left_label=\"2001\",\n",
- " right_label=\"2019\",\n",
- " label_position=\"bottom\",\n",
- " center=[36.1, -114.9],\n",
- " zoom=10,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "211",
- "metadata": {},
- "source": [
- "## Create heat map\n",
- "\n",
- "Specify the file path to the CSV. It can either be a file locally or on the Internet."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "212",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(layers_control=True)\n",
- "in_csv = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.csv\"\n",
- "m.add_heatmap(\n",
- " in_csv,\n",
- " latitude=\"latitude\",\n",
- " longitude=\"longitude\",\n",
- " value=\"pop_max\",\n",
- " name=\"Heat map\",\n",
- " radius=20,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "213",
- "metadata": {},
- "source": [
- "Use the folium plotting backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "214",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "215",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "in_csv = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.csv\"\n",
- "m.add_heatmap(\n",
- " in_csv,\n",
- " latitude=\"latitude\",\n",
- " longitude=\"longitude\",\n",
- " value=\"pop_max\",\n",
- " name=\"Heat map\",\n",
- " radius=20,\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "216",
- "metadata": {},
- "outputs": [],
- "source": [
- "colors = [\"blue\", \"lime\", \"red\"]\n",
- "m.add_colorbar(colors=colors, vmin=0, vmax=10000)\n",
- "m.add_title(\"World Population Heat Map\", font_size=\"20px\", align=\"center\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "217",
- "metadata": {},
- "source": [
- "## Save map to HTML"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "218",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "219",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"Esri.NatGeoWorldMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "220",
- "metadata": {},
- "source": [
- "Specify the output HTML file name to save the map as a web page."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "221",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.to_html(\"mymap.html\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "222",
- "metadata": {},
- "source": [
- "If the output HTML file name is not provided, the function will return a string containing contain the source code of the HTML file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "223",
- "metadata": {},
- "outputs": [],
- "source": [
- "html = m.to_html()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "224",
- "metadata": {},
- "outputs": [],
- "source": [
- "# print(html)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "225",
- "metadata": {},
- "source": [
- "## Publish maps\n",
- "\n",
- "To follow this tutorial, you will need to [sign up](https://datapane.com/accounts/signup/) for an account with , then install and authenticate the `datapane` Python package. More information can be found [here](https://docs.datapane.com/tutorials/tut-getting-started). \n",
- "\n",
- "- `pip install datapane`\n",
- "- `datapane login`\n",
- "- `datapane ping`\n",
- "\n",
- "![](https://i.imgur.com/oSlBHb5.png)\n",
- "\n",
- "If you encounter folium version errors, please uncomment the following line to update folium and restart the kernel."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "226",
- "metadata": {},
- "outputs": [],
- "source": [
- "import datapane as dp\n",
- "import leafmap.foliumap as leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "227",
- "metadata": {},
- "outputs": [],
- "source": [
- "os.environ.get(\"DP_TOKEN\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "228",
- "metadata": {},
- "outputs": [],
- "source": [
- "if os.environ.get(\"DP_TOKEN\") is None:\n",
- " os.environ[\"DP_TOKEN\"] = \"your-api-key\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "229",
- "metadata": {},
- "outputs": [],
- "source": [
- "dp.login(token=os.environ[\"DP_TOKEN\"])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "230",
- "metadata": {},
- "source": [
- "### Elevation map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "231",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"USGS 3DEP Elevation\")\n",
- "colors = [\"006633\", \"E5FFCC\", \"662A00\", \"D8D8D8\", \"F5F5F5\"]\n",
- "vmin = 0\n",
- "vmax = 4000\n",
- "m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "232",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.publish(name=\"Elevation Map of North America\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "233",
- "metadata": {},
- "source": [
- "### Land cover map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "234",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"NLCD 2019 CONUS Land Cover\")\n",
- "m.add_legend(builtin_legend=\"NLCD\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "235",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.publish(name=\"National Land Cover Database (NLCD) 2019\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "236",
- "metadata": {},
- "source": [
- "### Population heat map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "237",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "in_csv = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.csv\"\n",
- "m.add_heatmap(\n",
- " in_csv,\n",
- " latitude=\"latitude\",\n",
- " longitude=\"longitude\",\n",
- " value=\"pop_max\",\n",
- " name=\"Heat map\",\n",
- " radius=20,\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "238",
- "metadata": {},
- "outputs": [],
- "source": [
- "colors = [\"blue\", \"lime\", \"red\"]\n",
- "vmin = 0\n",
- "vmax = 10000\n",
- "m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "239",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.publish(name=\"World Population Heat Map\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "240",
- "metadata": {},
- "source": [
- "## Use planet imagery\n",
- "\n",
- "First, you need to sign up a Planet account and get an API key. See https://www.planet.com/nicfi & https://developers.planet.com/quickstart/apis.\n",
- "Uncomment the following line to pass in your API key."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "241",
- "metadata": {},
- "outputs": [],
- "source": [
- "if os.environ.get(\"PLANET_API_KEY\") is None:\n",
- " os.environ[\"PLANET_API_KEY\"] = \"your-api-key\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "242",
- "metadata": {},
- "outputs": [],
- "source": [
- "biannual_tiles = leafmap.planet_biannual_tiles_tropical()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "243",
- "metadata": {},
- "outputs": [],
- "source": [
- "for tile in biannual_tiles:\n",
- " print(tile)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "244",
- "metadata": {},
- "outputs": [],
- "source": [
- "monthly_tiles = leafmap.planet_monthly_tiles_tropical()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "245",
- "metadata": {},
- "outputs": [],
- "source": [
- "for tile in monthly_tiles:\n",
- " print(tile)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "246",
- "metadata": {},
- "source": [
- "Add a Planet monthly mosaic by specifying year and month."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "247",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "layer = monthly_tiles[\"Planet_2021-08\"]\n",
- "m.add_layer(layer)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "248",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "layer = biannual_tiles[\"Planet_2020-06_2020-08\"]\n",
- "m.add_layer(layer)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "249",
- "metadata": {},
- "source": [
- "## Use timeseries inspector"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "250",
- "metadata": {},
- "outputs": [],
- "source": [
- "if os.environ.get(\"PLANET_API_KEY\") is None:\n",
- " os.environ[\"PLANET_API_KEY\"] = \"your-api-key\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "251",
- "metadata": {},
- "outputs": [],
- "source": [
- "biannual_tiles = leafmap.planet_biannual_tiles_tropical()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "252",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.ts_inspector(biannual_tiles, center=[8.5, -80], zoom=5)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "253",
- "metadata": {},
- "outputs": [],
- "source": [
- "monthly_tiles = leafmap.planet_monthly_tiles_tropical()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "254",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.ts_inspector(monthly_tiles, center=[8.5, -80], zoom=5)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "255",
- "metadata": {},
- "outputs": [],
- "source": [
- "tiles = leafmap.planet_tiles_tropical()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "256",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.ts_inspector(tiles, center=[8.5, -80], zoom=5)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "257",
- "metadata": {},
- "source": [
- "## Use time slider"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "258",
- "metadata": {},
- "source": [
- "Use the time slider to visualize Planet quarterly mosaic."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "259",
- "metadata": {},
- "outputs": [],
- "source": [
- "if os.environ.get(\"PLANET_API_KEY\") is None:\n",
- " os.environ[\"PLANET_API_KEY\"] = \"your-api-key\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "260",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[8.5, -80], zoom=5)\n",
- "layers_dict = leafmap.planet_monthly_tiles_tropical()\n",
- "m.add_time_slider(layers_dict, time_interval=1)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "261",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[8.5, -80], zoom=5)\n",
- "layers_dict = leafmap.planet_biannual_tiles_tropical()\n",
- "m.add_time_slider(layers_dict, time_interval=1)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "262",
- "metadata": {},
- "source": [
- "Use the time slider to visualize basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "263",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.clear_layers()\n",
- "layers_dict = leafmap.basemap_xyz_tiles()\n",
- "m.add_time_slider(layers_dict, time_interval=1)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "264",
- "metadata": {},
- "source": [
- "## Use PostGIS\n",
- "\n",
- "Setting up the conda env:\n",
- "\n",
- "```\n",
- "conda create -n geo python=3.9\n",
- "conda activate geo\n",
- "conda install geopandas\n",
- "conda install mamba -c conda-forge\n",
- "mamba install leafmap sqlalchemy psycopg2 -c conda-forge\n",
- "```\n",
- "\n",
- "Sample dataset:\n",
- "- [nyc_data.zip](https://github.com/giswqs/postgis/raw/master/data/nyc_data.zip) (Watch this [video](https://youtu.be/fROzLrjNDrs) to load data into PostGIS)\n",
- "\n",
- "### Connect to the database\n",
- "\n",
- "You can directly pass in the user name and password to access the database. Alternative, you can define environment variables. The default environment variables for user and password are `SQL_USER` and `SQL_PASSWORD`, respectively.\n",
- "\n",
- "The `try...except...` statements are only used for building the documentation website (https://leafmap.org) because the PostGIS database is not available on GitHub. If you are running the notebook with Jupyter installed locally and PostGIS set up properly, you don't need these `try...except...` statements."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "265",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " con = leafmap.connect_postgis(\n",
- " database=\"nyc\", host=\"localhost\", user=None, password=None, use_env_var=True\n",
- " )\n",
- "except:\n",
- " pass"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "266",
- "metadata": {},
- "source": [
- "### Perform SQL queries\n",
- "\n",
- "Create a GeoDataFrame from a sql query."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "267",
- "metadata": {},
- "outputs": [],
- "source": [
- "sql = \"SELECT * FROM nyc_neighborhoods\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "268",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " gdf = leafmap.read_postgis(sql, con)\n",
- " display(gdf)\n",
- "except:\n",
- " pass"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "269",
- "metadata": {},
- "source": [
- "### Display data on the map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "270",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " m = leafmap.Map()\n",
- " m.add_gdf_from_postgis(\n",
- " sql, con, layer_name=\"NYC Neighborhoods\", fill_colors=[\"red\", \"green\", \"blue\"]\n",
- " )\n",
- " display(m)\n",
- "except:\n",
- " pass"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "271",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/mAXaBCv.gif)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "272",
- "metadata": {},
- "source": [
- "## Add widget to the map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "273",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "import numpy as np\n",
- "import matplotlib.pyplot as plt\n",
- "from ipywidgets import Output\n",
- "from ipyleaflet import WidgetControl"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "274",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "# Data for plotting\n",
- "t = np.arange(0.0, 2.0, 0.01)\n",
- "s = 1 + np.sin(2 * np.pi * t)\n",
- "\n",
- "fig, ax = plt.subplots()\n",
- "ax.plot(t, s)\n",
- "\n",
- "ax.set(\n",
- " xlabel=\"time (s)\", ylabel=\"voltage (mV)\", title=\"About as simple as it gets, folks\"\n",
- ")\n",
- "ax.grid()\n",
- "\n",
- "# Create an output widget to host the plot\n",
- "output_widget = Output()\n",
- "\n",
- "# Show the plot on the widget\n",
- "with output_widget:\n",
- " output_widget.clear_output()\n",
- " plt.show()\n",
- "\n",
- "# Add the widget as a control to the map\n",
- "output_control = WidgetControl(widget=output_widget, position=\"bottomright\")\n",
- "m.add_control(output_control)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "275",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "276",
- "metadata": {},
- "source": [
- "## Develop custom widgets"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "277",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "import ipywidgets as widgets\n",
- "from ipyleaflet import WidgetControl"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "278",
- "metadata": {},
- "source": [
- "### Create a toolbar button"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "279",
- "metadata": {},
- "outputs": [],
- "source": [
- "widget_width = \"250px\"\n",
- "padding = \"0px 0px 0px 5px\" # upper, right, bottom, left\n",
- "\n",
- "toolbar_button = widgets.ToggleButton(\n",
- " value=False,\n",
- " tooltip=\"Toolbar\",\n",
- " icon=\"gears\",\n",
- " layout=widgets.Layout(width=\"28px\", height=\"28px\", padding=padding),\n",
- ")\n",
- "\n",
- "close_button = widgets.ToggleButton(\n",
- " value=False,\n",
- " tooltip=\"Close the tool\",\n",
- " icon=\"times\",\n",
- " button_style=\"primary\",\n",
- " layout=widgets.Layout(height=\"28px\", width=\"28px\", padding=padding),\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "280",
- "metadata": {},
- "outputs": [],
- "source": [
- "toolbar = widgets.HBox([toolbar_button])\n",
- "toolbar"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "281",
- "metadata": {},
- "source": [
- "### Add toolbar event"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "282",
- "metadata": {},
- "outputs": [],
- "source": [
- "def toolbar_click(change):\n",
- " if change[\"new\"]:\n",
- " toolbar.children = [toolbar_button, close_button]\n",
- " else:\n",
- " toolbar.children = [toolbar_button]\n",
- "\n",
- "\n",
- "toolbar_button.observe(toolbar_click, \"value\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "283",
- "metadata": {},
- "outputs": [],
- "source": [
- "def close_click(change):\n",
- " if change[\"new\"]:\n",
- " toolbar_button.close()\n",
- " close_button.close()\n",
- " toolbar.close()\n",
- "\n",
- "\n",
- "close_button.observe(close_click, \"value\")\n",
- "toolbar"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "284",
- "metadata": {},
- "source": [
- "### Add a toolbar grid"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "285",
- "metadata": {},
- "outputs": [],
- "source": [
- "rows = 2\n",
- "cols = 2\n",
- "grid = widgets.GridspecLayout(\n",
- " rows, cols, grid_gap=\"0px\", layout=widgets.Layout(width=\"65px\")\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "286",
- "metadata": {},
- "source": [
- "icons: https://fontawesome.com/v4.7.0/icons/"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "287",
- "metadata": {},
- "outputs": [],
- "source": [
- "icons = [\"folder-open\", \"map\", \"info\", \"question\"]\n",
- "\n",
- "for i in range(rows):\n",
- " for j in range(cols):\n",
- " grid[i, j] = widgets.Button(\n",
- " description=\"\",\n",
- " button_style=\"primary\",\n",
- " icon=icons[i * rows + j],\n",
- " layout=widgets.Layout(width=\"28px\", padding=\"0px\"),\n",
- " )\n",
- "grid"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "288",
- "metadata": {},
- "outputs": [],
- "source": [
- "toolbar = widgets.VBox([toolbar_button])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "289",
- "metadata": {},
- "outputs": [],
- "source": [
- "def toolbar_click(change):\n",
- " if change[\"new\"]:\n",
- " toolbar.children = [widgets.HBox([close_button, toolbar_button]), grid]\n",
- " else:\n",
- " toolbar.children = [toolbar_button]\n",
- "\n",
- "\n",
- "toolbar_button.observe(toolbar_click, \"value\")\n",
- "toolbar"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "290",
- "metadata": {},
- "source": [
- "### Add toolbar to leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "291",
- "metadata": {},
- "outputs": [],
- "source": [
- "toolbar_ctrl = WidgetControl(widget=toolbar, position=\"topright\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "292",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_control(toolbar_ctrl)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "293",
- "metadata": {},
- "outputs": [],
- "source": [
- "output = widgets.Output()\n",
- "output_ctrl = WidgetControl(widget=output, position=\"bottomright\")\n",
- "m.add_control(output_ctrl)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "294",
- "metadata": {},
- "outputs": [],
- "source": [
- "def tool_click(b):\n",
- " with output:\n",
- " output.clear_output()\n",
- " print(f\"You clicked the {b.icon} button\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "295",
- "metadata": {},
- "outputs": [],
- "source": [
- "for i in range(rows):\n",
- " for j in range(cols):\n",
- " tool = grid[i, j]\n",
- " tool.on_click(tool_click)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "296",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/3LbyC1Y.gif)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/workshops/ICRW_2023.ipynb b/examples/workshops/ICRW_2023.ipynb
deleted file mode 100644
index 9ce4b8a630..0000000000
--- a/examples/workshops/ICRW_2023.ipynb
+++ /dev/null
@@ -1,931 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/ICRW_2023.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/workshops/ICRW_2023.ipynb)\n",
- "\n",
- "**An Introduction to Watershed Analysis with Leafmap and WhiteboxTools**\n",
- "\n",
- "This [notebook](https://leafmap.org/workshops/ICRW_2023) provides an introduction to watershed analysis with Leafmap and WhiteboxTools. It is designed for The Interagency Conference on Research in the Watersheds ([ICRW](https://icrwatersheds.org/)) 2023 workshop - [Working with Geospatial Hydrologic Data for Watershed Analyses in R and Python Using Web Services](https://icrwatersheds.org/icrw8/icrw8-schedule/june-5-workshops/).\n",
- "\n",
- "- Leafmap: \n",
- "- WhiteboxTools: \n",
- "- WhiteboxTools User Manual: "
- ]
- },
- {
- "cell_type": "markdown",
- "id": "1",
- "metadata": {},
- "source": [
- "## Installation\n",
- "\n",
- "Uncomment and run the following cell to install necessary packages for this notebook, including leafmap, geopandas, localtileserver, rio-cogeo, pynhd, py3dep."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "2",
- "metadata": {},
- "outputs": [],
- "source": [
- "# %pip install leafmap[raster] geopandas"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "3",
- "metadata": {},
- "source": [
- "## Import libraries"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "5",
- "metadata": {},
- "source": [
- "## Create interactive maps\n",
- "\n",
- "Specify the map center, zoom level, and height."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "6",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4, height=\"600px\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7",
- "metadata": {},
- "source": [
- "## Add basemaps\n",
- "\n",
- "Add OpenTopoMap, USGS 3DEP Elevation, and USGS Hydrography basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_basemap(\"USGS 3DEP Elevation\")\n",
- "m.add_basemap(\"USGS Hydrography\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9",
- "metadata": {},
- "source": [
- "Add NLCD land cover map and legend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "10",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4)\n",
- "m.add_basemap(\"HYBRID\")\n",
- "m.add_basemap(\"NLCD 2019 CONUS Land Cover\")\n",
- "m.add_legend(builtin_legend=\"NLCD\", title=\"NLCD Land Cover Type\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "Add WMS layers."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=4)\n",
- "m.add_basemap(\"Esri.WorldImagery\")\n",
- "url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?\"\n",
- "m.add_wms_layer(\n",
- " url,\n",
- " layers=\"NLCD_2019_Land_Cover_L48\",\n",
- " name=\"NLCD 2019 CONUS Land Cover\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "m.add_legend(builtin_legend=\"NLCD\", title=\"NLCD Land Cover Type\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "## Get watershed data\n",
- "\n",
- "Let's download watershed data for the Calapooia River basin in Oregon."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = leafmap.get_nhd_basins(feature_ids=23763529, fsource=\"comid\", simplified=False)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "Plot the watershed boundary on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_gdf(gdf, layer_name=\"Catchment\", info_mode=None)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "Save the watershed boundary to a GeoJSON or shapefile."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf.to_file(\"basin.geojson\", driver=\"GeoJSON\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "19",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf.to_file(\"basin.shp\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "20",
- "metadata": {},
- "source": [
- "## Download DEM\n",
- "\n",
- "Download a digital elevation model (DEM) for the watershed from the USGS 3DEP Elevation service. Convert the DEM to a Cloud Optimized GeoTIFF (COG)."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "21",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.get_3dep_dem(\n",
- " gdf, resolution=30, output=\"dem.tif\", dst_crs=\"EPSG:3857\", to_cog=True\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "22",
- "metadata": {},
- "source": [
- "Display the DEM on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "23",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(\"dem.tif\", palette=\"terrain\", layer_name=\"DEM\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "24",
- "metadata": {},
- "source": [
- "## Get DEM metadata"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "metadata = leafmap.image_metadata(\"dem.tif\")\n",
- "metadata"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "26",
- "metadata": {},
- "source": [
- "Get a summary statistics of the DEM."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "27",
- "metadata": {},
- "outputs": [],
- "source": [
- "metadata[\"bands\"]"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "28",
- "metadata": {},
- "source": [
- "## Add colorbar"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "29",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_colormap(cmap=\"terrain\", vmin=\"60\", vmax=1500, label=\"Elevation (m)\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "30",
- "metadata": {},
- "source": [
- "## Initialize WhiteboxTools\n",
- "\n",
- "Initialize the WhiteboxTools class."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "31",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt = leafmap.WhiteboxTools()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "32",
- "metadata": {},
- "source": [
- "Check the WhiteboxTools version."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "33",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.version()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "34",
- "metadata": {},
- "source": [
- "Display the WhiteboxTools interface."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "35",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.whiteboxgui()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "36",
- "metadata": {},
- "source": [
- "## Set working directory"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "37",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.set_working_dir(os.getcwd())\n",
- "wbt.verbose = False"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "38",
- "metadata": {},
- "source": [
- "## Smooth DEM\n",
- "\n",
- "All WhiteboxTools functions will return 0 if they are successful, and 1 if they are not."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "39",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.feature_preserving_smoothing(\"dem.tif\", \"smoothed.tif\", filter=9)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "40",
- "metadata": {},
- "source": [
- "Display the smoothed DEM and watershed boundary on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "41",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_raster(\"smoothed.tif\", palette=\"terrain\", layer_name=\"Smoothed DEM\")\n",
- "m.add_geojson(\"basin.geojson\", layer_name=\"Watershed\", info_mode=None)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "42",
- "metadata": {},
- "source": [
- "## Create hillshade"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "43",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.hillshade(\"smoothed.tif\", \"hillshade.tif\", azimuth=315, altitude=35)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "44",
- "metadata": {},
- "source": [
- "Overlay the hillshade on the smoothed DEM with transparency."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "45",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(\"hillshade.tif\", layer_name=\"Hillshade\")\n",
- "m.layers[-1].opacity = 0.6"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "46",
- "metadata": {},
- "source": [
- "## Find no-flow cells\n",
- "\n",
- "Find cells with undefined flow, i.e. no valid flow direction, based on the D8 flow direction algorithm"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "47",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.find_no_flow_cells(\"smoothed.tif\", \"noflow.tif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "48",
- "metadata": {},
- "source": [
- "Display the no-flow cells on the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "49",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(\"noflow.tif\", layer_name=\"No Flow Cells\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "50",
- "metadata": {},
- "source": [
- "## Fill depressions"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "51",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.fill_depressions(\"smoothed.tif\", \"filled.tif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "52",
- "metadata": {},
- "source": [
- "Alternatively, you can use depression breaching to fill the depressions."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "53",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.breach_depressions(\"smoothed.tif\", \"breached.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "54",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.find_no_flow_cells(\"breached.tif\", \"noflow2.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "55",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(\"noflow2.tif\", layer_name=\"No Flow Cells after Breaching\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "56",
- "metadata": {},
- "source": [
- "## Delineate flow direction"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "57",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.d8_pointer(\"breached.tif\", \"flow_direction.tif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "58",
- "metadata": {},
- "source": [
- "## Calculate flow accumulation"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "59",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.d8_flow_accumulation(\"breached.tif\", \"flow_accum.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "60",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(\"flow_accum.tif\", layer_name=\"Flow Accumulation\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "61",
- "metadata": {},
- "source": [
- "## Extract streams"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "62",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.extract_streams(\"flow_accum.tif\", \"streams.tif\", threshold=5000)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "63",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(\"streams.tif\", layer_name=\"Streams\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "64",
- "metadata": {},
- "source": [
- "## Calculate distance to outlet"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "65",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.distance_to_outlet(\n",
- " \"flow_direction.tif\", streams=\"streams.tif\", output=\"distance_to_outlet.tif\"\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "66",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(\"distance_to_outlet.tif\", layer_name=\"Distance to Outlet\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "67",
- "metadata": {},
- "source": [
- "## Vectorize streams"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "68",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.raster_streams_to_vector(\n",
- " \"streams.tif\", d8_pntr=\"flow_direction.tif\", output=\"streams.shp\"\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "69",
- "metadata": {},
- "source": [
- "The raster_streams_to_vector tool has a bug. The output vector file is missing the coordinate system. Use leafmap.vector_set_crs() to set the coordinate system."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "70",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.vector_set_crs(source=\"streams.shp\", output=\"streams.shp\", crs=\"EPSG:3857\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "71",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_shp(\n",
- " \"streams.shp\", layer_name=\"Streams Vector\", style={\"color\": \"#ff0000\", \"weight\": 3}\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "72",
- "metadata": {},
- "source": [
- "## Delineate basins"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "73",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.basins(\"flow_direction.tif\", \"basins.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "74",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(\"basins.tif\", layer_name=\"Basins\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "75",
- "metadata": {},
- "source": [
- "## Delineate the longest flow path"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "76",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.longest_flowpath(\n",
- " dem=\"breached.tif\", basins=\"basins.tif\", output=\"longest_flowpath.shp\"\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "77",
- "metadata": {},
- "source": [
- "Select only the longest flow path."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "78",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.select_largest(\n",
- " \"longest_flowpath.shp\", column=\"LENGTH\", output=\"longest_flowpath.shp\"\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "79",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_shp(\n",
- " \"longest_flowpath.shp\",\n",
- " layer_name=\"Longest Flowpath\",\n",
- " style={\"color\": \"#ff0000\", \"weight\": 3},\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "80",
- "metadata": {},
- "source": [
- "## Generate a pour point"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "81",
- "metadata": {},
- "outputs": [],
- "source": [
- "if m.user_roi is not None:\n",
- " m.save_draw_features(\"pour_point.shp\", crs=\"EPSG:3857\")\n",
- "else:\n",
- " coords = [-122.613559, 44.284383]\n",
- " leafmap.coords_to_vector(coords, output=\"pour_point.shp\", crs=\"EPSG:3857\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "82",
- "metadata": {},
- "source": [
- "## Snap pour point to stream"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "83",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.snap_pour_points(\n",
- " \"pour_point.shp\", \"flow_accum.tif\", \"pour_point_snapped.shp\", snap_dist=300\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "84",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_shp(\"pour_point_snapped.shp\", layer_name=\"Pour Point\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "85",
- "metadata": {},
- "source": [
- "## Delineate watershed"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "86",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.watershed(\"flow_direction.tif\", \"pour_point_snapped.shp\", \"watershed.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "87",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(\"watershed.tif\", layer_name=\"Watershed\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "88",
- "metadata": {},
- "source": [
- "## Convert watershed raster to vector"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "89",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.raster_to_vector_polygons(\"watershed.tif\", \"watershed.shp\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "90",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_shp(\n",
- " \"watershed.shp\",\n",
- " layer_name=\"Watershed Vector\",\n",
- " style={\"color\": \"#ffff00\", \"weight\": 3},\n",
- ")"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/workshops/SIGSPATIAL_2021.ipynb b/examples/workshops/SIGSPATIAL_2021.ipynb
deleted file mode 100644
index 7a3f4c3648..0000000000
--- a/examples/workshops/SIGSPATIAL_2021.ipynb
+++ /dev/null
@@ -1,2235 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/SIGSPATIAL_2021.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://gishub.org/acm-colab)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/acm-binder)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/acm-binder-nb)\n",
- "![](https://i.imgur.com/uKiXeCl.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "1",
- "metadata": {},
- "source": [
- "**Interactive Mapping and Geospatial Analysis with Leafmap & Jupyter**\n",
- "\n",
- "\n",
- "This notebook was developed for the [leafmap workshop](https://dataoceanlab.github.io/spatial-api-2021/files/paper_1.pdf) taking place on November 2, 2021 at the [The 3rd ACM SIGSPATIAL International Workshop on APIs and Libraries for Geospatial Data Science (SpatialAPI 2021)](https://dataoceanlab.github.io/spatial-api-2021).\n",
- "\n",
- "Author: [Qiusheng Wu](https://github.com/giswqs)\n",
- "\n",
- "Launch this notebook to execute code interactively using: \n",
- "- Google Colab: https://gishub.org/acm-colab\n",
- "- Pangeo Binder JupyterLab: https://gishub.org/acm-binder\n",
- "- Pangeo Binder Jupyter Notebook: https://gishub.org/acm-binder-nb\n",
- "- Streamlit web app: https://streamlit.gishub.org\n",
- "\n",
- "\n",
- "## Introduction\n",
- "\n",
- "### Workshop description\n",
- "\n",
- "[Leafmap](https://leafmap.org) is a Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment. It is built upon a number of open-source packages, such as [folium](https://github.com/python-visualization/folium) and [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet) (for creating interactive maps), [WhiteboxTools](https://github.com/jblindsay/whitebox-tools) and [whiteboxgui](https://github.com/opengeos/whiteboxgui) (for analyzing geospatial data), and [ipywidgets](https://github.com/jupyter-widgets/ipywidgets) (for designing interactive graphical user interface). The WhiteboxTools library currently contains 480+ tools for advanced geospatial analysis. Leafmap provides many convenient functions for loading and visualizing geospatial data with only one line of code. Users can also use the interactive user interface to load geospatial data without coding. Anyone with a web browser and Internet connection can use leafmap to perform geospatial analysis and data visualization in the cloud with minimal coding. The topics that will be covered in this workshop include: \n",
- "\n",
- "1. A brief introduction to leafmap and relevant web resources \n",
- "2. Creating interactive maps using multiple plotting backends\n",
- "3. Changing basemaps\n",
- "4. Loading and visualizing vector/raster data\n",
- "5. Using Cloud Optimized GeoTIFF (COG) and SpatialTemporal Asset Catalog (STAC)\n",
- "6. Downloading OpenStreetMap data\n",
- "7. Creating custom legends and colorbars\n",
- "8. Creating split-panel maps and linked maps\n",
- "9. Performing geospatial analysis using whiteboxgui.\n",
- "10. Discussion and Q&A\n",
- "\n",
- "\n",
- "This workshop is intended for scientific programmers, data scientists, geospatial analysts, and concerned citizens of Earth. The attendees are expected to have a basic understanding of Python and the Jupyter ecosystem. Familiarity with Earth science and geospatial datasets is useful but not required. More information about leafmap can be found at https://leafmap.org.\n",
- "\n",
- "\n",
- "### Jupyter keyboard shortcuts\n",
- "\n",
- "- Shift+Enter: run cell, select below\n",
- "- Ctrl+Enter: : run selected cells\n",
- "- Alt+Enter: run cell and insert below\n",
- "- Tab: code completion or indent\n",
- "- Shift+Tab: tooltip\n",
- "- Ctrl+/: comment out code"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "## Set up environment\n",
- "\n",
- "### Required Python packages:\n",
- "* [leafmap](https://github.com/opengeos/leafmap) - A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment\n",
- "* [keplergl](https://docs.kepler.gl/docs/keplergl-jupyter) - A high-performance web-based application for visual exploration of large-scale geolocation data sets\n",
- "* [pydeck](https://deckgl.readthedocs.io/en/latest) - High-scale spatial rendering in Python, powered by deck.gl.\n",
- "* [geopandas](https://geopandas.org) - An open source project to make working with geospatial data in python easier. \n",
- "* [xarray-leaflet](https://github.com/davidbrochart/xarray_leaflet) - An xarray extension for tiled map plotting.\n",
- "\n",
- "### Use Google Colab\n",
- "\n",
- "Click the button below to open this notebook in Google Colab and execute code interactively.\n",
- "\n",
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/SIGSPATIAL_2021.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://gishub.org/acm-colab)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import subprocess\n",
- "import sys"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "import warnings\n",
- "\n",
- "warnings.filterwarnings(\"ignore\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "A function for installing Python packages."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "def install(package):\n",
- " subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", package])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Install required Python packages in Google Colab."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "pkgs = [\n",
- " \"leafmap\",\n",
- " \"geopandas\",\n",
- " \"keplergl\",\n",
- " \"pydeck\",\n",
- " \"xarray_leaflet\",\n",
- " \"osmnx\",\n",
- " \"pygeos\",\n",
- " \"imageio\",\n",
- " \"tifffile\",\n",
- "]\n",
- "if \"google.colab\" in sys.modules:\n",
- " for pkg in pkgs:\n",
- " install(pkg)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "### Use Pangeo Binder\n",
- "\n",
- "Click the buttons below to open this notebook in JupyterLab (first button) or Jupyter Notebook (second button) and execute code interactively.\n",
- "\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/acm-binder)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/acm-binder-nb)\n",
- "\n",
- "- JupyterLab: https://gishub.org/acm-binder\n",
- "- Jupyter Notebook: https://gishub.org/acm-binder-nb"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "### Use Miniconda/Anaconda\n",
- "\n",
- "If you have\n",
- "[Anaconda](https://www.anaconda.com/distribution/#download-section) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html) installed on your computer, you can install leafmap using the following commands. Leafmap has an optional dependency - [geopandas](https://geopandas.org), which can be challenging to install on some computers, especially Windows. It is highly recommended that you create a fresh conda environment to install geopandas and leafmap. Follow the commands below to set up a conda env and install geopandas, leafmap, keplergl, and xarray_leaflet. \n",
- "\n",
- "```\n",
- "conda create -n geo python=3.8\n",
- "conda activate geo\n",
- "conda install geopandas\n",
- "conda install mamba -c conda-forge\n",
- "mamba install leafmap keplergl pydeck xarray_leaflet -c conda-forge\n",
- "mamba install osmnx pygeos imageio tifffile -c conda-forge\n",
- "jupyter lab\n",
- "```"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " import leafmap\n",
- "except ImportError:\n",
- " install(\"leafmap\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "## Create an interactive map\n",
- "\n",
- "`Leafmap` has five plotting backends: [folium](https://github.com/python-visualization/folium), [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet), [here-map](https://github.com/heremaps/here-map-widget-for-jupyter), [kepler.gl](https://docs.kepler.gl/docs/keplergl-jupyter), and [pydeck](https://deckgl.readthedocs.io). Note that the backends do not offer equal functionality. Some interactive functionality in `ipyleaflet` might not be available in other plotting backends. To use a specific plotting backend, use one of the following:\n",
- "\n",
- "- `import leafmap.leafmap as leafmap`\n",
- "- `import leafmap.foliumap as leafmap`\n",
- "- `import leafmap.heremap as leafmap`\n",
- "- `import leafmap.kepler as leafmap`\n",
- "- `import leafmap.deck as leafmap`\n",
- "\n",
- "### Use ipyleaflet"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "\n",
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "### Use folium"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap\n",
- "\n",
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "### Use kepler.gl"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.kepler as leafmap\n",
- "\n",
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "If you encounter an error saying `Error displaying widget: model not found` when trying to display the map, you can use `m.static_map()` as a workaround until this [kepler.gl bug](https://github.com/keplergl/kepler.gl/issues/1165) has been resolved."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.static_map(width=1280, height=600)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "### Use pydeck"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.deck as leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "23",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "24",
- "metadata": {},
- "source": [
- "## Customize the default map\n",
- "\n",
- "### Specify map center and zoom level"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(40, -100), zoom=4) # center=(lat, lon)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "27",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(51.5, -0.15), zoom=17)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "28",
- "metadata": {},
- "source": [
- "### Change map size"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "29",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(height=\"400px\", width=\"800px\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "30",
- "metadata": {},
- "source": [
- "### Set control visibility\n",
- "\n",
- "When creating a map, set the following controls to either `True` or `False` as appropriate.\n",
- "\n",
- "* attribution_control\n",
- "* draw_control\n",
- "* fullscreen_control\n",
- "* layers_control\n",
- "* measure_control\n",
- "* scale_control\n",
- "* toolbar_control"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "31",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " draw_control=False,\n",
- " measure_control=False,\n",
- " fullscreen_control=False,\n",
- " attribution_control=False,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "32",
- "metadata": {},
- "source": [
- "Remove all controls from the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "33",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.clear_controls()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "34",
- "metadata": {},
- "source": [
- "## Change basemaps\n",
- "\n",
- "Specify a Google basemap to use, can be one of [\"ROADMAP\", \"TERRAIN\", \"SATELLITE\", \"HYBRID\"]."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "35",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "36",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(google_map=\"TERRAIN\") # HYBRID, ROADMAP, SATELLITE, TERRAIN\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "37",
- "metadata": {},
- "source": [
- "Add a basemap using the `add_basemap()` function."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "38",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"Esri.NatGeoWorldMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "39",
- "metadata": {},
- "source": [
- "Print out the list of available basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "40",
- "metadata": {},
- "outputs": [],
- "source": [
- "for basemap in leafmap.basemaps:\n",
- " print(basemap)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "41",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/T1oBWSz.png)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "42",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_tile_layer(\n",
- " url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\",\n",
- " name=\"Google Satellite\",\n",
- " attribution=\"Google\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "43",
- "metadata": {},
- "source": [
- "### Add WMS tile layer\n",
- "\n",
- "More WMS basemaps can be found at the following websites:\n",
- "\n",
- "- USGS National Map: https://viewer.nationalmap.gov/services\n",
- "- MRLC NLCD Land Cover data: https://www.mrlc.gov/data-services-page\n",
- "- FWS NWI Wetlands data: https://www.fws.gov/wetlands/Data/Web-Map-Services.html"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "44",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "naip_url = \"https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url=naip_url, layers=\"0\", name=\"NAIP Imagery\", format=\"image/png\", shown=True\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "45",
- "metadata": {},
- "source": [
- "### Add xyzservices provider\n",
- "\n",
- "Add a layer from [xyzservices](https://github.com/geopandas/xyzservices) provider object."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "46",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "import xyzservices.providers as xyz"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "47",
- "metadata": {},
- "outputs": [],
- "source": [
- "basemap = xyz.OpenTopoMap\n",
- "basemap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "48",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(basemap)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "49",
- "metadata": {},
- "source": [
- "## Add COG/STAC layers\n",
- "\n",
- "A Cloud Optimized GeoTIFF (COG) is a regular GeoTIFF file, aimed at being hosted on a HTTP file server, with an internal organization that enables more efficient workflows on the cloud. It does this by leveraging the ability of clients issuing HTTP GET range requests to ask for just the parts of a file they need. \n",
- "\n",
- "More information about COG can be found at \n",
- "\n",
- "Some publicly available Cloud Optimized GeoTIFFs:\n",
- "\n",
- "* https://stacindex.org/\n",
- "* https://cloud.google.com/storage/docs/public-datasets/landsat\n",
- "* https://www.digitalglobe.com/ecosystem/open-data\n",
- "* https://earthexplorer.usgs.gov/\n",
- "\n",
- "For this demo, we will use data from https://www.maxar.com/open-data/california-colorado-fires for mapping California and Colorado fires. A list of COGs can be found [here](https://github.com/opengeos/leafmap/blob/master/examples/data/cog_files.txt).\n",
- "\n",
- "### Add COG layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "50",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "51",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- "url2 = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-09-13.tif\"\n",
- "\n",
- "m.add_cog_layer(url, name=\"Fire (pre-event)\")\n",
- "m.add_cog_layer(url2, name=\"Fire (post-event)\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "52",
- "metadata": {},
- "source": [
- "### Add STAC layer\n",
- "\n",
- "The SpatioTemporal Asset Catalog (STAC) specification provides a common language to describe a range of geospatial information, so it can more easily be indexed and discovered. A 'spatiotemporal asset' is any file that represents information about the earth captured in a certain space and time. The initial focus is primarily remotely-sensed imagery (from satellites, but also planes, drones, balloons, etc), but the core is designed to be extensible to SAR, full motion video, point clouds, hyperspectral, LiDAR and derived data like NDVI, Digital Elevation Models, mosaics, etc. More information about STAC can be found at https://stacspec.org/\n",
- "\n",
- "Some publicly available SpatioTemporal Asset Catalog (STAC):\n",
- "\n",
- "* https://stacindex.org\n",
- "\n",
- "For this demo, we will use STAC assets from https://stacindex.org/catalogs/spot-orthoimages-canada-2005#/?t=catalogs"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "53",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\"\n",
- "m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"False color\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "54",
- "metadata": {},
- "source": [
- "## Add local raster datasets\n",
- "\n",
- "The `add_raster` function relies on the `xarray_leaflet` package and is only available for the ipyleaflet plotting backend. Therefore, Google Colab is not supported. Note that `xarray_leaflet` does not work properly on Windows ([source](https://github.com/davidbrochart/xarray_leaflet/issues/30))."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "55",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "56",
- "metadata": {},
- "source": [
- "Download samples raster datasets\n",
- "\n",
- "More datasets can be downloaded from https://viewer.nationalmap.gov/basic/"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "57",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_dir = os.getcwd()\n",
- "\n",
- "landsat = os.path.join(out_dir, \"landsat.tif\")\n",
- "dem = os.path.join(out_dir, \"dem.tif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "58",
- "metadata": {},
- "source": [
- "Download a small Landsat imagery."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "59",
- "metadata": {},
- "outputs": [],
- "source": [
- "landsat_url = (\n",
- " \"https://drive.google.com/file/d/1EV38RjNxdwEozjc9m0FcO3LFgAoAX1Uw/view?usp=sharing\"\n",
- ")\n",
- "leafmap.download_file(landsat_url, \"landsat.tif\", unzip=False)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "60",
- "metadata": {},
- "source": [
- "Download a small DEM dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "61",
- "metadata": {},
- "outputs": [],
- "source": [
- "dem_url = (\n",
- " \"https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing\"\n",
- ")\n",
- "leafmap.download_file(dem_url, \"dem.tif\", unzip=False)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "62",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "63",
- "metadata": {},
- "source": [
- "Add local raster datasets to the map\n",
- "\n",
- "More colormap can be found at https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "64",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(dem, colormap=\"terrain\", layer_name=\"DEM\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "65",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(landsat, bands=[5, 4, 3], layer_name=\"Landsat\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "66",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "67",
- "metadata": {},
- "source": [
- "## Add legend\n",
- "\n",
- "### Add built-in legend"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "68",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "69",
- "metadata": {},
- "source": [
- "List all available built-in legends."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "70",
- "metadata": {},
- "outputs": [],
- "source": [
- "legends = leafmap.builtin_legends\n",
- "for legend in legends:\n",
- " print(legend)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "71",
- "metadata": {},
- "source": [
- "Add a WMS layer and built-in legend to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "72",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?\"\n",
- "m.add_wms_layer(\n",
- " url,\n",
- " layers=\"NLCD_2019_Land_Cover_L48\",\n",
- " name=\"NLCD 2019 CONUS Land Cover\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "m.add_legend(builtin_legend=\"NLCD\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "73",
- "metadata": {},
- "source": [
- "Add U.S. National Wetlands Inventory (NWI). More info at https://www.fws.gov/wetlands."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "74",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(google_map=\"HYBRID\")\n",
- "\n",
- "url1 = \"https://www.fws.gov/wetlands/arcgis/services/Wetlands/MapServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url1, layers=\"1\", format=\"image/png\", transparent=True, name=\"NWI Wetlands Vector\"\n",
- ")\n",
- "\n",
- "url2 = \"https://www.fws.gov/wetlands/arcgis/services/Wetlands_Raster/ImageServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url2, layers=\"0\", format=\"image/png\", transparent=True, name=\"NWI Wetlands Raster\"\n",
- ")\n",
- "\n",
- "m.add_legend(builtin_legend=\"NWI\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "75",
- "metadata": {},
- "source": [
- "### Add custom legend\n",
- "\n",
- "There are two ways you can add custom legends:\n",
- "\n",
- "1. Define legend labels and colors\n",
- "2. Define legend dictionary\n",
- "\n",
- "Define legend keys and colors"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "76",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "labels = [\"One\", \"Two\", \"Three\", \"Four\", \"etc\"]\n",
- "# color can be defined using either hex code or RGB (0-255, 0-255, 0-255)\n",
- "colors = [\"#8DD3C7\", \"#FFFFB3\", \"#BEBADA\", \"#FB8072\", \"#80B1D3\"]\n",
- "# colors = [(255, 0, 0), (127, 255, 0), (127, 18, 25), (36, 70, 180), (96, 68, 123)]\n",
- "\n",
- "m.add_legend(title=\"Legend\", labels=labels, colors=colors)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "77",
- "metadata": {},
- "source": [
- "Define a legend dictionary."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "78",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?\"\n",
- "m.add_wms_layer(\n",
- " url,\n",
- " layers=\"NLCD_2019_Land_Cover_L48\",\n",
- " name=\"NLCD 2019 CONUS Land Cover\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "\n",
- "legend_dict = {\n",
- " \"11 Open Water\": \"466b9f\",\n",
- " \"12 Perennial Ice/Snow\": \"d1def8\",\n",
- " \"21 Developed, Open Space\": \"dec5c5\",\n",
- " \"22 Developed, Low Intensity\": \"d99282\",\n",
- " \"23 Developed, Medium Intensity\": \"eb0000\",\n",
- " \"24 Developed High Intensity\": \"ab0000\",\n",
- " \"31 Barren Land (Rock/Sand/Clay)\": \"b3ac9f\",\n",
- " \"41 Deciduous Forest\": \"68ab5f\",\n",
- " \"42 Evergreen Forest\": \"1c5f2c\",\n",
- " \"43 Mixed Forest\": \"b5c58f\",\n",
- " \"51 Dwarf Scrub\": \"af963c\",\n",
- " \"52 Shrub/Scrub\": \"ccb879\",\n",
- " \"71 Grassland/Herbaceous\": \"dfdfc2\",\n",
- " \"72 Sedge/Herbaceous\": \"d1d182\",\n",
- " \"73 Lichens\": \"a3cc51\",\n",
- " \"74 Moss\": \"82ba9e\",\n",
- " \"81 Pasture/Hay\": \"dcd939\",\n",
- " \"82 Cultivated Crops\": \"ab6c28\",\n",
- " \"90 Woody Wetlands\": \"b8d9eb\",\n",
- " \"95 Emergent Herbaceous Wetlands\": \"6c9fb8\",\n",
- "}\n",
- "\n",
- "m.add_legend(title=\"NLCD Land Cover Classification\", legend_dict=legend_dict)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "79",
- "metadata": {},
- "source": [
- "## Add colormap\n",
- "\n",
- "The colormap functionality requires the ipyleaflet plotting backend. Folium is not supported."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "80",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "import leafmap.colormaps as cm"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "81",
- "metadata": {},
- "source": [
- "### Common colormaps\n",
- "\n",
- "Color palette for DEM data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "82",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.palettes.dem"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "83",
- "metadata": {},
- "source": [
- "Show the DEM palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "84",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=cm.palettes.dem, axis_off=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "85",
- "metadata": {},
- "source": [
- "Color palette for NDVI data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "86",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.palettes.ndvi"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "87",
- "metadata": {},
- "source": [
- "Show the NDVI palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "88",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=cm.palettes.ndvi)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "89",
- "metadata": {},
- "source": [
- "### Custom colormaps\n",
- "\n",
- "Specify the number of classes for a palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "90",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.get_palette(\"terrain\", n_class=8)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "91",
- "metadata": {},
- "source": [
- "Show the terrain palette with 8 classes."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "92",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=cm.get_palette(\"terrain\", n_class=8))"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "93",
- "metadata": {},
- "source": [
- "Create a palette with custom colors, label, and font size."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "94",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=[\"red\", \"green\", \"blue\"], label=\"Temperature\", font_size=12)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "95",
- "metadata": {},
- "source": [
- "Create a discrete color palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "96",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(\n",
- " colors=[\"red\", \"green\", \"blue\"], discrete=True, label=\"Temperature\", font_size=12\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "97",
- "metadata": {},
- "source": [
- "Specify the width and height for the palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "98",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=8.0,\n",
- " height=0.4,\n",
- " orientation=\"horizontal\",\n",
- " vmin=0,\n",
- " vmax=1000,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "99",
- "metadata": {},
- "source": [
- "Change the orentation of the colormap to be vertical."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "100",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=0.4,\n",
- " height=4,\n",
- " orientation=\"vertical\",\n",
- " vmin=0,\n",
- " vmax=1000,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "101",
- "metadata": {},
- "source": [
- "### Horizontal colormap\n",
- "\n",
- "Add a horizontal colorbar to an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "102",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=8.0,\n",
- " height=0.4,\n",
- " orientation=\"horizontal\",\n",
- " vmin=0,\n",
- " vmax=4000,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "103",
- "metadata": {},
- "source": [
- "### Vertical colormap\n",
- "\n",
- "Add a vertical colorbar to an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "104",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=0.4,\n",
- " height=4,\n",
- " orientation=\"vertical\",\n",
- " vmin=0,\n",
- " vmax=4000,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "105",
- "metadata": {},
- "source": [
- "### List of available colormaps"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "106",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormaps(width=12, height=0.4)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "107",
- "metadata": {},
- "source": [
- "## Add vector datasets\n",
- "\n",
- "### Add CSV\n",
- "\n",
- "Read a CSV as a Pandas DataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "108",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "109",
- "metadata": {},
- "outputs": [],
- "source": [
- "in_csv = \"https://raw.githubusercontent.com/opengeos/data/main/world/world_cities.csv\"\n",
- "df = leafmap.csv_to_df(in_csv)\n",
- "df"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "110",
- "metadata": {},
- "source": [
- "Create a point layer from a CSV file containing lat/long information."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "111",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_xy_data(in_csv, x=\"longitude\", y=\"latitude\", layer_name=\"World Cities\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "112",
- "metadata": {},
- "source": [
- "Set the output directory."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "113",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_dir = os.getcwd()\n",
- "out_shp = os.path.join(out_dir, \"world_cities.shp\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "114",
- "metadata": {},
- "source": [
- "Convert a CSV file containing lat/long information to a shapefile."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "115",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.csv_to_shp(in_csv, out_shp)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "116",
- "metadata": {},
- "source": [
- "Convert a CSV file containing lat/long information to a GeoJSON."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "117",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_geojson = os.path.join(out_dir, \"world_cities.geojson\")\n",
- "leafmap.csv_to_geojson(in_csv, out_geojson)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "118",
- "metadata": {},
- "source": [
- "Convert a CSV file containing lat/long information to a GeoPandas GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "119",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = leafmap.csv_to_gdf(in_csv)\n",
- "gdf"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "120",
- "metadata": {},
- "source": [
- "### Add GeoJSON\n",
- "\n",
- "Add a GeoJSON to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "121",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "in_geojson = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cable_geo.geojson\"\n",
- "m.add_geojson(in_geojson, layer_name=\"Cable lines\", info_mode=\"on_hover\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "122",
- "metadata": {},
- "source": [
- "Add a GeoJSON with random filled color to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "123",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "m.add_geojson(\n",
- " url, layer_name=\"Countries\", fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"]\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "124",
- "metadata": {},
- "source": [
- "### Add shapefile"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "125",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "in_shp = \"https://github.com/opengeos/leafmap/raw/master/examples/data/countries.zip\"\n",
- "m.add_shp(in_shp, layer_name=\"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "126",
- "metadata": {},
- "source": [
- "### Add KML"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "127",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "128",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "in_kml = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_states.kml\"\n",
- "m.add_kml(in_kml, layer_name=\"US States KML\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "129",
- "metadata": {},
- "source": [
- "### Add GeoDataFrame"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "130",
- "metadata": {},
- "outputs": [],
- "source": [
- "import geopandas as gpd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "131",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "gdf = gpd.read_file(\n",
- " \"https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson\"\n",
- ")\n",
- "m.add_gdf(gdf, layer_name=\"Cable lines\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "132",
- "metadata": {},
- "source": [
- "### Add point layer\n",
- "\n",
- "Add a point layer using the interactive GUI.\n",
- "\n",
- "![](https://i.imgur.com/1QVEtlN.gif)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "133",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "134",
- "metadata": {},
- "source": [
- "Add a point layer programmatically."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "135",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.geojson\"\n",
- "m.add_point_layer(url, popup=[\"name\", \"pop_max\"], layer_name=\"US Cities\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "136",
- "metadata": {},
- "source": [
- "### Add vector\n",
- "\n",
- "The `add_vector` function supports any vector data format supported by GeoPandas."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "137",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "m.add_vector(\n",
- " url, layer_name=\"Countries\", fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"]\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "138",
- "metadata": {},
- "source": [
- "## Download OSM data\n",
- "\n",
- "### OSM from geocode\n",
- "\n",
- "Add OSM data of place(s) by name or ID to the map. Note that the leafmap custom layer control does not support GeoJSON, we need to use the ipyleaflet built-in layer control."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "139",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "140",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_geocode(\"New York City\", layer_name=\"NYC\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "141",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_geocode(\"Chicago, Illinois\", layer_name=\"Chicago, IL\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "142",
- "metadata": {},
- "source": [
- "### OSM from place\n",
- "\n",
- "Add OSM entities within boundaries of geocodable place(s) to the map."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "143",
- "metadata": {},
- "source": [
- "Show OSM feature tags.\n",
- "https://wiki.openstreetmap.org/wiki/Map_features"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "144",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.osm_tags_list()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "145",
- "metadata": {},
- "source": [
- "### OSM from address"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "146",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_address(\n",
- " address=\"New York City\", tags={\"amenity\": \"bar\"}, dist=1500, layer_name=\"NYC bars\"\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "147",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_address(\n",
- " address=\"New York City\",\n",
- " tags={\"landuse\": [\"retail\", \"commercial\"], \"building\": True},\n",
- " dist=1000,\n",
- " layer_name=\"NYC buildings\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "148",
- "metadata": {},
- "source": [
- "### OSM from bbox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "149",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "north, south, east, west = 40.7551, 40.7454, -73.9738, -73.9965\n",
- "m.add_osm_from_bbox(\n",
- " north, south, east, west, tags={\"amenity\": \"bar\"}, layer_name=\"NYC bars\"\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "150",
- "metadata": {},
- "source": [
- "### OSM from point\n",
- "\n",
- "Add OSM entities within some distance N, S, E, W of a point to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "151",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " center=[46.7808, -96.0156], zoom=12, toolbar_control=False, layers_control=True\n",
- ")\n",
- "m.add_osm_from_point(\n",
- " center_point=(46.7808, -96.0156),\n",
- " tags={\"natural\": \"water\"},\n",
- " dist=10000,\n",
- " layer_name=\"Lakes\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "152",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " center=[39.9170, 116.3908], zoom=15, toolbar_control=False, layers_control=True\n",
- ")\n",
- "m.add_osm_from_point(\n",
- " center_point=(39.9170, 116.3908),\n",
- " tags={\"building\": True, \"natural\": \"water\"},\n",
- " dist=1000,\n",
- " layer_name=\"Beijing\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "153",
- "metadata": {},
- "source": [
- "### OSM from view\n",
- "\n",
- "Add OSM entities within the current map view to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "154",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.set_center(-73.9854, 40.7500, 16)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "155",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_osm_from_view(tags={\"amenity\": \"bar\", \"building\": True}, layer_name=\"New York\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "156",
- "metadata": {},
- "source": [
- "Create a GeoPandas GeoDataFrame from place."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "157",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = leafmap.osm_gdf_from_place(\"New York City\", tags={\"amenity\": \"bar\"})\n",
- "gdf"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "158",
- "metadata": {},
- "source": [
- "## Use WhiteboxTools\n",
- "\n",
- "Use the built-in toolbox to perform geospatial analysis. For example, you can perform depression filling using the sample DEM dataset downloaded in the above step.\n",
- "\n",
- "![](https://i.imgur.com/KGHly63.png)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "159",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap\n",
- "import urllib.request"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "160",
- "metadata": {},
- "source": [
- "Download a sample DEM dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "161",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://github.com/opengeos/whitebox-python/raw/master/whitebox/testdata/DEM.tif\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "162",
- "metadata": {},
- "outputs": [],
- "source": [
- "urllib.request.urlretrieve(url, \"dem.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "163",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "164",
- "metadata": {},
- "source": [
- "Display the toolbox using the default mode."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "165",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.whiteboxgui()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "166",
- "metadata": {},
- "source": [
- "Display the toolbox using the collapsible tree mode. Note that the tree mode does not support Google Colab."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "167",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.whiteboxgui(tree=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "168",
- "metadata": {},
- "source": [
- "Perform geospatial analysis using the [whitebox](https://github.com/opengeos/whitebox-python) package."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "169",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import whitebox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "170",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt = whitebox.WhiteboxTools()\n",
- "wbt.verbose = False"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "171",
- "metadata": {},
- "outputs": [],
- "source": [
- "data_dir = os.getcwd()\n",
- "wbt.set_working_dir(data_dir)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "172",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.feature_preserving_smoothing(\"dem.tif\", \"smoothed.tif\", filter=9)\n",
- "wbt.breach_depressions(\"smoothed.tif\", \"breached.tif\")\n",
- "wbt.d_inf_flow_accumulation(\"breached.tif\", \"flow_accum.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "173",
- "metadata": {},
- "outputs": [],
- "source": [
- "import matplotlib.pyplot as plt\n",
- "import imageio\n",
- "\n",
- "%matplotlib inline"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "174",
- "metadata": {},
- "outputs": [],
- "source": [
- "original = imageio.imread(os.path.join(data_dir, \"dem.tif\"))\n",
- "smoothed = imageio.imread(os.path.join(data_dir, \"smoothed.tif\"))\n",
- "breached = imageio.imread(os.path.join(data_dir, \"breached.tif\"))\n",
- "flow_accum = imageio.imread(os.path.join(data_dir, \"flow_accum.tif\"))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "175",
- "metadata": {},
- "outputs": [],
- "source": [
- "fig = plt.figure(figsize=(16, 11))\n",
- "\n",
- "ax1 = fig.add_subplot(2, 2, 1)\n",
- "ax1.set_title(\"Original DEM\")\n",
- "plt.imshow(original)\n",
- "\n",
- "ax2 = fig.add_subplot(2, 2, 2)\n",
- "ax2.set_title(\"Smoothed DEM\")\n",
- "plt.imshow(smoothed)\n",
- "\n",
- "ax3 = fig.add_subplot(2, 2, 3)\n",
- "ax3.set_title(\"Breached DEM\")\n",
- "plt.imshow(breached)\n",
- "\n",
- "ax4 = fig.add_subplot(2, 2, 4)\n",
- "ax4.set_title(\"Flow Accumulation\")\n",
- "plt.imshow(flow_accum)\n",
- "\n",
- "plt.show()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "176",
- "metadata": {},
- "source": [
- "## Create linked map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "177",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "178",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.basemaps.keys()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "179",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = [\"ROADMAP\", \"HYBRID\"]\n",
- "leafmap.linked_maps(rows=1, cols=2, height=\"400px\", layers=layers)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "180",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = [\"Esri.WorldTopoMap\", \"OpenTopoMap\"]\n",
- "leafmap.linked_maps(rows=1, cols=2, height=\"400px\", layers=layers)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "181",
- "metadata": {},
- "source": [
- "Create a 2 * 2 linked map to visualize land cover change. Specify the `center` and `zoom` parameters to change the default map center and zoom level."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "182",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = [str(f\"NLCD {year} CONUS Land Cover\") for year in [2001, 2006, 2011, 2016]]\n",
- "labels = [str(f\"NLCD {year}\") for year in [2001, 2006, 2011, 2016]]\n",
- "leafmap.linked_maps(\n",
- " rows=2,\n",
- " cols=2,\n",
- " height=\"300px\",\n",
- " layers=layers,\n",
- " labels=labels,\n",
- " center=[36.1, -115.2],\n",
- " zoom=9,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "183",
- "metadata": {},
- "source": [
- "## Create split-panel map\n",
- "\n",
- "Create a split-panel map by specifying the `left_layer` and `right_layer`, which can be chosen from the basemap names, or any custom XYZ tile layer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "184",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "185",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_map(left_layer=\"ROADMAP\", right_layer=\"HYBRID\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "186",
- "metadata": {},
- "source": [
- "Hide the zoom control from the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "187",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_map(\n",
- " left_layer=\"Esri.WorldTopoMap\", right_layer=\"OpenTopoMap\", zoom_control=False\n",
- ")"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/examples/workshops/YouthMappers_2021.ipynb b/examples/workshops/YouthMappers_2021.ipynb
deleted file mode 100644
index a2fabe5256..0000000000
--- a/examples/workshops/YouthMappers_2021.ipynb
+++ /dev/null
@@ -1,3129 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "0",
- "metadata": {},
- "source": [
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/YouthMappers_2021.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://gishub.org/ym-colab)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/ym-binder)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/ym-binder-nb)\n",
- "![](https://i.imgur.com/5FhzCc0.png)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "1",
- "metadata": {},
- "source": [
- "**Interactive Mapping and Geospatial Analysis with Leafmap and Jupyter**\n",
- "\n",
- "\n",
- "This notebook was developed for the 90-min [leafmap workshop](https://www.eventbrite.com/e/interactive-mapping-and-geospatial-analysis-tickets-188600217327?keep_tld=1) taking place on November 9, 2021. The workshop is hosted by [YouthMappers](https://www.youthmappers.org).\n",
- "\n",
- "- Author: [Qiusheng Wu](https://github.com/opengeos)\n",
- "- Slides: https://gishub.org/ym \n",
- "- Streamlit web app: https://streamlit.gishub.org\n",
- "\n",
- "Launch this notebook to execute code interactively using: \n",
- "- Google Colab: https://gishub.org/ym-colab\n",
- "- Pangeo Binder JupyterLab: https://gishub.org/ym-binder\n",
- "- Pangeo Binder Jupyter Notebook: https://gishub.org/ym-binder-nb\n",
- "\n",
- "## Introduction\n",
- "\n",
- "### Workshop description\n",
- "\n",
- "[Leafmap](https://leafmap.org) is a Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment. It is built upon a number of open-source packages, such as [folium](https://github.com/python-visualization/folium) and [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet) (for creating interactive maps), [WhiteboxTools](https://github.com/jblindsay/whitebox-tools) and [whiteboxgui](https://github.com/opengeos/whiteboxgui) (for analyzing geospatial data), and [ipywidgets](https://github.com/jupyter-widgets/ipywidgets) (for designing interactive graphical user interface). The WhiteboxTools library currently contains 480+ tools for advanced geospatial analysis. Leafmap provides many convenient functions for loading and visualizing geospatial data with only one line of code. Users can also use the interactive user interface to load geospatial data without coding. Anyone with a web browser and Internet connection can use leafmap to perform geospatial analysis and data visualization in the cloud with minimal coding. The topics that will be covered in this workshop include: \n",
- "\n",
- "- A brief introduction to Jupyter and Colab\n",
- "- A brief introduction to leafmap and relevant web resources \n",
- "- Creating interactive maps using multiple plotting backends\n",
- "- Searching and loading basemaps\n",
- "- Loading and visualizing vector/raster data\n",
- "- Using Cloud Optimized GeoTIFF (COG) and SpatialTemporal Asset Catalog (STAC)\n",
- "- Downloading OpenStreetMap data\n",
- "- Loading data from a PostGIS database\n",
- "- Creating custom legends and colorbars\n",
- "- Creating split-panel maps and linked maps\n",
- "- Visualizing Planet global monthly/quarterly mosaic\n",
- "- Designing and publishing interactive web apps\n",
- "- Performing geospatial analysis (e.g., hydrological analysis) using whiteboxgui\n",
- "\n",
- "This workshop is intended for scientific programmers, data scientists, geospatial analysts, and concerned citizens of Earth. The attendees are expected to have a basic understanding of Python and the Jupyter ecosystem. Familiarity with Earth science and geospatial datasets is useful but not required. More information about leafmap can be found at https://leafmap.org.\n",
- "\n",
- "\n",
- "### Jupyter keyboard shortcuts\n",
- "\n",
- "- Shift+Enter: run cell, select below\n",
- "- Ctrl+Enter: : run selected cells\n",
- "- Alt+Enter: run cell and insert below\n",
- "- Tab: code completion or indent\n",
- "- Shift+Tab: tooltip\n",
- "- Ctrl+/: comment out code"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2",
- "metadata": {},
- "source": [
- "## Set up environment\n",
- "\n",
- "### Required Python packages:\n",
- "* [leafmap](https://github.com/opengeos/leafmap) - A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment.\n",
- "* [keplergl](https://docs.kepler.gl/docs/keplergl-jupyter) - A high-performance web-based application for visual exploration of large-scale geolocation data sets.\n",
- "* [pydeck](https://deckgl.readthedocs.io/en/latest) - High-scale spatial rendering in Python, powered by deck.gl.\n",
- "* [geopandas](https://geopandas.org) - An open source project to make working with geospatial data in python easier. \n",
- "* [xarray-leaflet](https://github.com/davidbrochart/xarray_leaflet) - An xarray extension for tiled map plotting.\n",
- "\n",
- "### Use Google Colab\n",
- "\n",
- "Click the button below to open this notebook in Google Colab and execute code interactively.\n",
- "\n",
- "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=workshops/YouthMappers_2021.ipynb)\n",
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/examples/workshops/YouthMappers_2021.ipynb)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "3",
- "metadata": {},
- "outputs": [],
- "source": [
- "# !pip install leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "4",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import subprocess\n",
- "import sys"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5",
- "metadata": {},
- "outputs": [],
- "source": [
- "import warnings\n",
- "\n",
- "warnings.filterwarnings(\"ignore\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6",
- "metadata": {},
- "source": [
- "A function for installing Python packages."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "7",
- "metadata": {},
- "outputs": [],
- "source": [
- "def install(package):\n",
- " subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", package])"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8",
- "metadata": {},
- "source": [
- "Install required Python packages in Google Colab."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "9",
- "metadata": {},
- "outputs": [],
- "source": [
- "pkgs = [\n",
- " \"leafmap\",\n",
- " \"geopandas\",\n",
- " \"keplergl\",\n",
- " \"pydeck\",\n",
- " \"xarray_leaflet\",\n",
- " \"osmnx\",\n",
- " \"pygeos\",\n",
- " \"imageio\",\n",
- " \"tifffile\",\n",
- "]\n",
- "if \"google.colab\" in sys.modules:\n",
- " for pkg in pkgs:\n",
- " install(pkg)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "10",
- "metadata": {},
- "source": [
- "### Use Pangeo Binder\n",
- "\n",
- "Click the buttons below to open this notebook in JupyterLab (first button) or Jupyter Notebook (second button) and execute code interactively.\n",
- "\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/ym-binder)\n",
- "[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/ym-binder-nb)\n",
- "\n",
- "- JupyterLab: https://gishub.org/ym-binder\n",
- "- Jupyter Notebook: https://gishub.org/ym-binder-nb"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "11",
- "metadata": {},
- "source": [
- "### Use Miniconda/Anaconda\n",
- "\n",
- "If you have\n",
- "[Anaconda](https://www.anaconda.com/distribution/#download-section) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html) installed on your computer, you can install leafmap using the following commands. Leafmap has an optional dependency - [geopandas](https://geopandas.org), which can be challenging to install on some computers, especially Windows. It is highly recommended that you create a fresh conda environment to install geopandas and leafmap. Follow the commands below to set up a conda env and install geopandas, leafmap, pydeck, keplergl, and xarray_leaflet. \n",
- "\n",
- "```\n",
- "conda create -n geo python=3.8\n",
- "conda activate geo\n",
- "conda install geopandas\n",
- "conda install mamba -c conda-forge\n",
- "mamba install leafmap keplergl pydeck xarray_leaflet -c conda-forge\n",
- "mamba install osmnx pygeos imageio tifffile -c conda-forge\n",
- "jupyter lab\n",
- "```"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "12",
- "metadata": {},
- "outputs": [],
- "source": [
- "try:\n",
- " import leafmap\n",
- "except ImportError:\n",
- " install(\"leafmap\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "13",
- "metadata": {},
- "source": [
- "## Create an interactive map\n",
- "\n",
- "`Leafmap` has five plotting backends: [folium](https://github.com/python-visualization/folium), [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet), [here-map](https://github.com/heremaps/here-map-widget-for-jupyter), [kepler.gl](https://docs.kepler.gl/docs/keplergl-jupyter), and [pydeck](https://deckgl.readthedocs.io). Note that the backends do not offer equal functionality. Some interactive functionality in `ipyleaflet` might not be available in other plotting backends. To use a specific plotting backend, use one of the following:\n",
- "\n",
- "- `import leafmap.leafmap as leafmap`\n",
- "- `import leafmap.foliumap as leafmap`\n",
- "- `import leafmap.heremap as leafmap`\n",
- "- `import leafmap.kepler as leafmap`\n",
- "- `import leafmap.deck as leafmap`\n",
- "\n",
- "### Use ipyleaflet"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "14",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "\n",
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "15",
- "metadata": {},
- "source": [
- "### Use folium"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "16",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.foliumap as leafmap\n",
- "\n",
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "17",
- "metadata": {},
- "source": [
- "### Use kepler.gl"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "18",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.kepler as leafmap\n",
- "\n",
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19",
- "metadata": {},
- "source": [
- "If you encounter an error saying `Error displaying widget: model not found` when trying to display the map, you can use `m.static_map()` as a workaround until this [kepler.gl bug](https://github.com/keplergl/kepler.gl/issues/1165) has been resolved."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "20",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.static_map(width=1280, height=600)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21",
- "metadata": {},
- "source": [
- "### Use pydeck"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "22",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.deck as leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "23",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "24",
- "metadata": {},
- "source": [
- "## Customize the default map\n",
- "\n",
- "### Specify map center and zoom level"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "25",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "26",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(40, -100), zoom=4) # center=[lat, lon]\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "27",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=(51.5, -0.15), zoom=17)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "28",
- "metadata": {},
- "source": [
- "### Change map size"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "29",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(height=\"400px\", width=\"800px\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "30",
- "metadata": {},
- "source": [
- "### Set control visibility\n",
- "\n",
- "When creating a map, set the following controls to either `True` or `False` as appropriate.\n",
- "\n",
- "* attribution_control\n",
- "* draw_control\n",
- "* fullscreen_control\n",
- "* layers_control\n",
- "* measure_control\n",
- "* scale_control\n",
- "* toolbar_control"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "31",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " draw_control=False,\n",
- " measure_control=False,\n",
- " fullscreen_control=False,\n",
- " attribution_control=False,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "32",
- "metadata": {},
- "source": [
- "Remove all controls from the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "33",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.clear_controls()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "34",
- "metadata": {},
- "source": [
- "## Change basemaps\n",
- "\n",
- "Specify a Google basemap to use, can be one of [\"ROADMAP\", \"TERRAIN\", \"SATELLITE\", \"HYBRID\"]."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "35",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "36",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(google_map=\"TERRAIN\") # HYBRID, ROADMAP, SATELLITE, TERRAIN\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "37",
- "metadata": {},
- "source": [
- "Add a basemap using the `add_basemap()` function."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "38",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"Esri.NatGeoWorldMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "39",
- "metadata": {},
- "source": [
- "Print out the list of available basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "40",
- "metadata": {},
- "outputs": [],
- "source": [
- "for basemap in leafmap.basemaps:\n",
- " print(basemap)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "41",
- "metadata": {},
- "source": [
- "![](https://i.imgur.com/T1oBWSz.png)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "42",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_tile_layer(\n",
- " url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\",\n",
- " name=\"Google Satellite\",\n",
- " attribution=\"Google\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "43",
- "metadata": {},
- "source": [
- "## Add tile layers\n",
- "\n",
- "### Add XYZ tile layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "44",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "45",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_tile_layer(\n",
- " url=\"https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}\",\n",
- " name=\"Google Satellite\",\n",
- " attribution=\"Google\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "46",
- "metadata": {},
- "source": [
- "### Add WMS tile layer\n",
- "\n",
- "More WMS basemaps can be found at the following websites:\n",
- "\n",
- "- USGS National Map: https://viewer.nationalmap.gov/services\n",
- "- MRLC NLCD Land Cover data: https://www.mrlc.gov/data-services-page\n",
- "- FWS NWI Wetlands data: https://www.fws.gov/wetlands/Data/Web-Map-Services.html"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "47",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "naip_url = \"https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url=naip_url, layers=\"0\", name=\"NAIP Imagery\", format=\"image/png\", shown=True\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "48",
- "metadata": {},
- "source": [
- "### Add xyzservices provider\n",
- "\n",
- "Add a layer from [xyzservices](https://github.com/geopandas/xyzservices) provider object."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "49",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import xyzservices.providers as xyz"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "50",
- "metadata": {},
- "outputs": [],
- "source": [
- "basemap = xyz.OpenTopoMap\n",
- "basemap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "51",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(basemap)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "52",
- "metadata": {},
- "source": [
- "## Add COG/STAC layers\n",
- "\n",
- "A Cloud Optimized GeoTIFF (COG) is a regular GeoTIFF file, aimed at being hosted on a HTTP file server, with an internal organization that enables more efficient workflows on the cloud. It does this by leveraging the ability of clients issuing HTTP GET range requests to ask for just the parts of a file they need. \n",
- "\n",
- "More information about COG can be found at \n",
- "\n",
- "Some publicly available Cloud Optimized GeoTIFFs:\n",
- "\n",
- "* https://stacindex.org/\n",
- "* https://cloud.google.com/storage/docs/public-datasets/landsat\n",
- "* https://www.digitalglobe.com/ecosystem/open-data\n",
- "* https://earthexplorer.usgs.gov/\n",
- "\n",
- "For this demo, we will use data from https://www.maxar.com/open-data/california-colorado-fires for mapping California and Colorado fires. A list of COGs can be found [here](https://github.com/opengeos/leafmap/blob/master/examples/data/cog_files.txt).\n",
- "\n",
- "### Add COG layer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "53",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "54",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"\n",
- "url2 = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-09-13.tif\"\n",
- "\n",
- "m.add_cog_layer(url, name=\"Fire (pre-event)\")\n",
- "m.add_cog_layer(url2, name=\"Fire (post-event)\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "55",
- "metadata": {},
- "source": [
- "### Add STAC layer\n",
- "\n",
- "The SpatioTemporal Asset Catalog (STAC) specification provides a common language to describe a range of geospatial information, so it can more easily be indexed and discovered. A 'spatiotemporal asset' is any file that represents information about the earth captured in a certain space and time. The initial focus is primarily remotely-sensed imagery (from satellites, but also planes, drones, balloons, etc), but the core is designed to be extensible to SAR, full motion video, point clouds, hyperspectral, LiDAR and derived data like NDVI, Digital Elevation Models, mosaics, etc. More information about STAC can be found at https://stacspec.org/\n",
- "\n",
- "Some publicly available SpatioTemporal Asset Catalog (STAC):\n",
- "\n",
- "* https://stacindex.org\n",
- "\n",
- "For this demo, we will use STAC assets from https://stacindex.org/catalogs/spot-orthoimages-canada-2005#/?t=catalogs"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "56",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json\"\n",
- "m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"False color\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "57",
- "metadata": {},
- "source": [
- "## Add local raster datasets\n",
- "\n",
- "The `add_raster` function relies on the `xarray_leaflet` package and is only available for the ipyleaflet plotting backend. Therefore, Google Colab is not supported. Note that `xarray_leaflet` does not work properly on Windows ([source](https://github.com/davidbrochart/xarray_leaflet/issues/30))."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "58",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "59",
- "metadata": {},
- "source": [
- "Download samples raster datasets. More datasets can be downloaded from https://viewer.nationalmap.gov/basic/"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "60",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_dir = os.getcwd()\n",
- "\n",
- "landsat = os.path.join(out_dir, \"landsat.tif\")\n",
- "dem = os.path.join(out_dir, \"dem.tif\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "61",
- "metadata": {},
- "source": [
- "Download a small Landsat imagery."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "62",
- "metadata": {},
- "outputs": [],
- "source": [
- "landsat_url = (\n",
- " \"https://drive.google.com/file/d/1EV38RjNxdwEozjc9m0FcO3LFgAoAX1Uw/view?usp=sharing\"\n",
- ")\n",
- "leafmap.download_file(landsat_url, \"landsat.tif\", unzip=False)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "63",
- "metadata": {},
- "source": [
- "Download a small DEM dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "64",
- "metadata": {},
- "outputs": [],
- "source": [
- "dem_url = (\n",
- " \"https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing\"\n",
- ")\n",
- "leafmap.download_file(dem_url, \"dem.tif\", unzip=False)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "65",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "66",
- "metadata": {},
- "source": [
- "Add local raster datasets to the map\n",
- "\n",
- "More colormap can be found at https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "67",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(dem, colormap=\"terrain\", layer_name=\"DEM\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "68",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_raster(landsat, bands=[5, 4, 3], layer_name=\"Landsat\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "69",
- "metadata": {},
- "outputs": [],
- "source": [
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "70",
- "metadata": {},
- "source": [
- "## Add legend\n",
- "\n",
- "### Add built-in legend"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "71",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "72",
- "metadata": {},
- "source": [
- "List all available built-in legends."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "73",
- "metadata": {},
- "outputs": [],
- "source": [
- "legends = leafmap.builtin_legends\n",
- "for legend in legends:\n",
- " print(legend)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "74",
- "metadata": {},
- "source": [
- "Add a WMS layer and built-in legend to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "75",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?\"\n",
- "m.add_wms_layer(\n",
- " url,\n",
- " layers=\"NLCD_2019_Land_Cover_L48\",\n",
- " name=\"NLCD 2019 CONUS Land Cover\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "m.add_legend(builtin_legend=\"NLCD\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "76",
- "metadata": {},
- "source": [
- "Add U.S. National Wetlands Inventory (NWI). More info at https://www.fws.gov/wetlands."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "77",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(google_map=\"HYBRID\")\n",
- "\n",
- "url1 = \"https://www.fws.gov/wetlands/arcgis/services/Wetlands/MapServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url1, layers=\"1\", format=\"image/png\", transparent=True, name=\"NWI Wetlands Vector\"\n",
- ")\n",
- "\n",
- "url2 = \"https://www.fws.gov/wetlands/arcgis/services/Wetlands_Raster/ImageServer/WMSServer?\"\n",
- "m.add_wms_layer(\n",
- " url2, layers=\"0\", format=\"image/png\", transparent=True, name=\"NWI Wetlands Raster\"\n",
- ")\n",
- "\n",
- "m.add_legend(builtin_legend=\"NWI\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "78",
- "metadata": {},
- "source": [
- "### Add custom legend\n",
- "\n",
- "There are two ways you can add custom legends:\n",
- "\n",
- "1. Define legend labels and colors\n",
- "2. Define legend dictionary\n",
- "\n",
- "Define legend keys and colors."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "79",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "labels = [\"One\", \"Two\", \"Three\", \"Four\", \"etc\"]\n",
- "# color can be defined using either hex code or RGB (0-255, 0-255, 0-255)\n",
- "colors = [\"#8DD3C7\", \"#FFFFB3\", \"#BEBADA\", \"#FB8072\", \"#80B1D3\"]\n",
- "# colors = [(255, 0, 0), (127, 255, 0), (127, 18, 25), (36, 70, 180), (96, 68, 123)]\n",
- "\n",
- "m.add_legend(title=\"Legend\", labels=labels, colors=colors)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "80",
- "metadata": {},
- "source": [
- "Define a legend dictionary."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "81",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "\n",
- "url = \"https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?\"\n",
- "m.add_wms_layer(\n",
- " url,\n",
- " layers=\"NLCD_2019_Land_Cover_L48\",\n",
- " name=\"NLCD 2019 CONUS Land Cover\",\n",
- " format=\"image/png\",\n",
- " transparent=True,\n",
- ")\n",
- "\n",
- "legend_dict = {\n",
- " \"11 Open Water\": \"466b9f\",\n",
- " \"12 Perennial Ice/Snow\": \"d1def8\",\n",
- " \"21 Developed, Open Space\": \"dec5c5\",\n",
- " \"22 Developed, Low Intensity\": \"d99282\",\n",
- " \"23 Developed, Medium Intensity\": \"eb0000\",\n",
- " \"24 Developed High Intensity\": \"ab0000\",\n",
- " \"31 Barren Land (Rock/Sand/Clay)\": \"b3ac9f\",\n",
- " \"41 Deciduous Forest\": \"68ab5f\",\n",
- " \"42 Evergreen Forest\": \"1c5f2c\",\n",
- " \"43 Mixed Forest\": \"b5c58f\",\n",
- " \"51 Dwarf Scrub\": \"af963c\",\n",
- " \"52 Shrub/Scrub\": \"ccb879\",\n",
- " \"71 Grassland/Herbaceous\": \"dfdfc2\",\n",
- " \"72 Sedge/Herbaceous\": \"d1d182\",\n",
- " \"73 Lichens\": \"a3cc51\",\n",
- " \"74 Moss\": \"82ba9e\",\n",
- " \"81 Pasture/Hay\": \"dcd939\",\n",
- " \"82 Cultivated Crops\": \"ab6c28\",\n",
- " \"90 Woody Wetlands\": \"b8d9eb\",\n",
- " \"95 Emergent Herbaceous Wetlands\": \"6c9fb8\",\n",
- "}\n",
- "\n",
- "m.add_legend(title=\"NLCD Land Cover Classification\", legend_dict=legend_dict)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "82",
- "metadata": {},
- "source": [
- "## Add colormap\n",
- "\n",
- "The colormap functionality requires the ipyleaflet plotting backend. Folium is not supported."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "83",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap\n",
- "import leafmap.colormaps as cm"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "84",
- "metadata": {},
- "source": [
- "### Common colormaps\n",
- "\n",
- "Color palette for DEM data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "85",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.palettes.dem"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "86",
- "metadata": {},
- "source": [
- "Show the DEM palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "87",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=cm.palettes.dem, axis_off=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "88",
- "metadata": {},
- "source": [
- "Color palette for NDVI data."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "89",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.palettes.ndvi"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "90",
- "metadata": {},
- "source": [
- "Show the NDVI palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "91",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=cm.palettes.ndvi)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "92",
- "metadata": {},
- "source": [
- "### Custom colormaps\n",
- "\n",
- "Specify the number of classes for a palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "93",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.get_palette(\"terrain\", n_class=8)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "94",
- "metadata": {},
- "source": [
- "Show the terrain palette with 8 classes."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "95",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=cm.get_palette(\"terrain\", n_class=8))"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "96",
- "metadata": {},
- "source": [
- "Create a palette with custom colors, label, and font size."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "97",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(colors=[\"red\", \"green\", \"blue\"], label=\"Temperature\", font_size=12)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "98",
- "metadata": {},
- "source": [
- "Create a discrete color palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "99",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(\n",
- " colors=[\"red\", \"green\", \"blue\"], discrete=True, label=\"Temperature\", font_size=12\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "100",
- "metadata": {},
- "source": [
- "Specify the width and height for the palette."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "101",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=8.0,\n",
- " height=0.4,\n",
- " orientation=\"horizontal\",\n",
- " vmin=0,\n",
- " vmax=1000,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "102",
- "metadata": {},
- "source": [
- "Change the orentation of the colormap to be vertical."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "103",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=0.4,\n",
- " height=4,\n",
- " orientation=\"vertical\",\n",
- " vmin=0,\n",
- " vmax=1000,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "104",
- "metadata": {},
- "source": [
- "### Horizontal colormap\n",
- "\n",
- "Add a horizontal colorbar to an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "105",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=8.0,\n",
- " height=0.4,\n",
- " orientation=\"horizontal\",\n",
- " vmin=0,\n",
- " vmax=4000,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "106",
- "metadata": {},
- "source": [
- "### Vertical colormap\n",
- "\n",
- "Add a vertical colorbar to an interactive map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "107",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"OpenTopoMap\")\n",
- "m.add_colormap(\n",
- " \"terrain\",\n",
- " label=\"Elevation\",\n",
- " width=0.4,\n",
- " height=4,\n",
- " orientation=\"vertical\",\n",
- " vmin=0,\n",
- " vmax=4000,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "108",
- "metadata": {},
- "source": [
- "### List of available colormaps"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "109",
- "metadata": {},
- "outputs": [],
- "source": [
- "cm.plot_colormaps(width=12, height=0.4)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "110",
- "metadata": {},
- "source": [
- "## Add vector datasets\n",
- "\n",
- "### Add CSV\n",
- "\n",
- "Read a CSV as a Pandas DataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "111",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "112",
- "metadata": {},
- "outputs": [],
- "source": [
- "in_csv = \"https://raw.githubusercontent.com/opengeos/data/main/world/world_cities.csv\"\n",
- "df = leafmap.csv_to_df(in_csv)\n",
- "df"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "113",
- "metadata": {},
- "source": [
- "Create a point layer from a CSV file containing lat/long information."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "114",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_xy_data(in_csv, x=\"longitude\", y=\"latitude\", layer_name=\"World Cities\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "115",
- "metadata": {},
- "source": [
- "Set the output directory."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "116",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_dir = os.getcwd()\n",
- "out_shp = os.path.join(out_dir, \"world_cities.shp\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "117",
- "metadata": {},
- "source": [
- "Convert a CSV file containing lat/long information to a shapefile."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "118",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.csv_to_shp(in_csv, out_shp)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "119",
- "metadata": {},
- "source": [
- "Convert a CSV file containing lat/long information to a GeoJSON."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "120",
- "metadata": {},
- "outputs": [],
- "source": [
- "out_geojson = os.path.join(out_dir, \"world_cities.geojson\")\n",
- "leafmap.csv_to_geojson(in_csv, out_geojson)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "121",
- "metadata": {},
- "source": [
- "Convert a CSV file containing lat/long information to a GeoPandas GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "122",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = leafmap.csv_to_gdf(in_csv)\n",
- "gdf"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "123",
- "metadata": {},
- "source": [
- "### Add GeoJSON\n",
- "\n",
- "Add a GeoJSON to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "124",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "in_geojson = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cable_geo.geojson\"\n",
- "m.add_geojson(in_geojson, layer_name=\"Cable lines\", info_mode=\"on_hover\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "125",
- "metadata": {},
- "source": [
- "Add a GeoJSON with random filled color to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "126",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "m.add_geojson(\n",
- " url, layer_name=\"Countries\", fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"]\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "127",
- "metadata": {},
- "source": [
- "Use the `style_callback` function for assigning a random color to each polygon."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "128",
- "metadata": {},
- "outputs": [],
- "source": [
- "import random\n",
- "\n",
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "\n",
- "\n",
- "def random_color(feature):\n",
- " return {\n",
- " \"color\": \"black\",\n",
- " \"fillColor\": random.choice([\"red\", \"yellow\", \"green\", \"orange\"]),\n",
- " }\n",
- "\n",
- "\n",
- "m.add_geojson(url, layer_name=\"Countries\", style_callback=random_color)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "129",
- "metadata": {},
- "source": [
- "Use custom `style` and `hover_style` functions."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "130",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "style = {\n",
- " \"stroke\": True,\n",
- " \"color\": \"#0000ff\",\n",
- " \"weight\": 2,\n",
- " \"opacity\": 1,\n",
- " \"fill\": True,\n",
- " \"fillColor\": \"#0000ff\",\n",
- " \"fillOpacity\": 0.1,\n",
- "}\n",
- "hover_style = {\"fillOpacity\": 0.7}\n",
- "m.add_geojson(url, layer_name=\"Countries\", style=style, hover_style=hover_style)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "131",
- "metadata": {},
- "source": [
- "### Add shapefile"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "132",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "in_shp = \"https://github.com/opengeos/leafmap/raw/master/examples/data/countries.zip\"\n",
- "m.add_shp(in_shp, layer_name=\"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "133",
- "metadata": {},
- "source": [
- "### Add KML"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "134",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "135",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "in_kml = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_states.kml\"\n",
- "m.add_kml(in_kml, layer_name=\"US States KML\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "136",
- "metadata": {},
- "source": [
- "### Add GeoDataFrame"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "137",
- "metadata": {},
- "outputs": [],
- "source": [
- "import geopandas as gpd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "138",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "gdf = gpd.read_file(\n",
- " \"https://github.com/opengeos/leafmap/raw/master/examples/data/cable_geo.geojson\"\n",
- ")\n",
- "m.add_gdf(gdf, layer_name=\"Cable lines\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "139",
- "metadata": {},
- "source": [
- "Read the GeoPandas sample dataset as a GeoDataFrame."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "140",
- "metadata": {},
- "outputs": [],
- "source": [
- "path_to_data = (\n",
- " \"https://github.com/opengeos/datasets/releases/download/vector/nybb.geojson\"\n",
- ")\n",
- "gdf = gpd.read_file(path_to_data)\n",
- "gdf"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "141",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_gdf(gdf, layer_name=\"New York boroughs\", fill_colors=[\"red\", \"green\", \"blue\"])\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "142",
- "metadata": {},
- "source": [
- "### Add point layer\n",
- "\n",
- "Add a point layer using the interactive GUI.\n",
- "\n",
- "![](https://i.imgur.com/1QVEtlN.gif)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "143",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "144",
- "metadata": {},
- "source": [
- "Add a point layer programmatically."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "145",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.geojson\"\n",
- "m.add_point_layer(url, popup=[\"name\", \"pop_max\"], layer_name=\"US Cities\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "146",
- "metadata": {},
- "source": [
- "### Add vector\n",
- "\n",
- "The `add_vector` function supports any vector data format supported by GeoPandas."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "147",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[0, 0], zoom=2)\n",
- "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n",
- "m.add_vector(\n",
- " url, layer_name=\"Countries\", fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"]\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "148",
- "metadata": {},
- "source": [
- "## Download OSM data\n",
- "\n",
- "### OSM from geocode\n",
- "\n",
- "Add OSM data of place(s) by name or ID to the map. Note that the leafmap custom layer control does not support GeoJSON, we need to use the ipyleaflet built-in layer control."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "149",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "150",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_geocode(\"New York City\", layer_name=\"NYC\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "151",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_geocode(\"Chicago, Illinois\", layer_name=\"Chicago, IL\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "152",
- "metadata": {},
- "source": [
- "### OSM from place\n",
- "\n",
- "Add OSM entities within boundaries of geocodable place(s) to the map."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "153",
- "metadata": {},
- "source": [
- "Show OSM feature tags.\n",
- "https://wiki.openstreetmap.org/wiki/Map_features"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "154",
- "metadata": {},
- "outputs": [],
- "source": [
- "# leafmap.osm_tags_list()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "155",
- "metadata": {},
- "source": [
- "### OSM from address"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "156",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_address(\n",
- " address=\"New York City\", tags={\"amenity\": \"bar\"}, dist=1500, layer_name=\"NYC bars\"\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "157",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.add_osm_from_address(\n",
- " address=\"New York City\",\n",
- " tags={\"landuse\": [\"retail\", \"commercial\"], \"building\": True},\n",
- " dist=1000,\n",
- " layer_name=\"NYC buildings\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "158",
- "metadata": {},
- "source": [
- "### OSM from bbox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "159",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "north, south, east, west = 40.7551, 40.7454, -73.9738, -73.9965\n",
- "m.add_osm_from_bbox(\n",
- " north, south, east, west, tags={\"amenity\": \"bar\"}, layer_name=\"NYC bars\"\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "160",
- "metadata": {},
- "source": [
- "### OSM from point\n",
- "\n",
- "Add OSM entities within some distance N, S, E, W of a point to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "161",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " center=[46.7808, -96.0156], zoom=12, toolbar_control=False, layers_control=True\n",
- ")\n",
- "m.add_osm_from_point(\n",
- " center_point=(46.7808, -96.0156),\n",
- " tags={\"natural\": \"water\"},\n",
- " dist=10000,\n",
- " layer_name=\"Lakes\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "162",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(\n",
- " center=[39.9170, 116.3908], zoom=15, toolbar_control=False, layers_control=True\n",
- ")\n",
- "m.add_osm_from_point(\n",
- " center_point=(39.9170, 116.3908),\n",
- " tags={\"building\": True, \"natural\": \"water\"},\n",
- " dist=1000,\n",
- " layer_name=\"Beijing\",\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "163",
- "metadata": {},
- "source": [
- "### OSM from view\n",
- "\n",
- "Add OSM entities within the current map view to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "164",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(toolbar_control=False, layers_control=True)\n",
- "m.set_center(-73.9854, 40.7500, 16)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "165",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.add_osm_from_view(tags={\"amenity\": \"bar\", \"building\": True}, layer_name=\"New York\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "166",
- "metadata": {},
- "source": [
- "Create a GeoPandas GeoDataFrame from place."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "167",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = leafmap.osm_gdf_from_place(\"New York City\", tags={\"amenity\": \"bar\"})\n",
- "gdf"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "168",
- "metadata": {},
- "source": [
- "## Use WhiteboxTools\n",
- "\n",
- "Use the built-in toolbox to perform geospatial analysis. For example, you can perform depression filling using the sample DEM dataset downloaded in the above step.\n",
- "\n",
- "![](https://i.imgur.com/KGHly63.png)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "169",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap\n",
- "import urllib.request"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "170",
- "metadata": {},
- "source": [
- "Download a sample DEM dataset."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "171",
- "metadata": {},
- "outputs": [],
- "source": [
- "url = \"https://github.com/opengeos/whitebox-python/raw/master/whitebox/testdata/DEM.tif\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "172",
- "metadata": {},
- "outputs": [],
- "source": [
- "urllib.request.urlretrieve(url, \"dem.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "173",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "174",
- "metadata": {},
- "source": [
- "Display the toolbox using the default mode."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "175",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.whiteboxgui()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "176",
- "metadata": {},
- "source": [
- "Display the toolbox using the collapsible tree mode. Note that the tree mode does not support Google Colab."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "177",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.whiteboxgui(tree=True)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "178",
- "metadata": {},
- "source": [
- "Perform geospatial analysis using the [whitebox](https://github.com/opengeos/whitebox-python) package."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "179",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import whitebox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "180",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt = whitebox.WhiteboxTools()\n",
- "wbt.verbose = False"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "181",
- "metadata": {},
- "outputs": [],
- "source": [
- "data_dir = os.getcwd()\n",
- "wbt.set_working_dir(data_dir)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "182",
- "metadata": {},
- "outputs": [],
- "source": [
- "wbt.feature_preserving_smoothing(\"dem.tif\", \"smoothed.tif\", filter=9)\n",
- "wbt.breach_depressions(\"smoothed.tif\", \"breached.tif\")\n",
- "wbt.d_inf_flow_accumulation(\"breached.tif\", \"flow_accum.tif\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "183",
- "metadata": {},
- "outputs": [],
- "source": [
- "import matplotlib.pyplot as plt\n",
- "import imageio\n",
- "\n",
- "%matplotlib inline"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "184",
- "metadata": {},
- "outputs": [],
- "source": [
- "original = imageio.imread(os.path.join(data_dir, \"dem.tif\"))\n",
- "smoothed = imageio.imread(os.path.join(data_dir, \"smoothed.tif\"))\n",
- "breached = imageio.imread(os.path.join(data_dir, \"breached.tif\"))\n",
- "flow_accum = imageio.imread(os.path.join(data_dir, \"flow_accum.tif\"))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "185",
- "metadata": {},
- "outputs": [],
- "source": [
- "fig = plt.figure(figsize=(16, 11))\n",
- "\n",
- "ax1 = fig.add_subplot(2, 2, 1)\n",
- "ax1.set_title(\"Original DEM\")\n",
- "plt.imshow(original)\n",
- "\n",
- "ax2 = fig.add_subplot(2, 2, 2)\n",
- "ax2.set_title(\"Smoothed DEM\")\n",
- "plt.imshow(smoothed)\n",
- "\n",
- "ax3 = fig.add_subplot(2, 2, 3)\n",
- "ax3.set_title(\"Breached DEM\")\n",
- "plt.imshow(breached)\n",
- "\n",
- "ax4 = fig.add_subplot(2, 2, 4)\n",
- "ax4.set_title(\"Flow Accumulation\")\n",
- "plt.imshow(flow_accum)\n",
- "\n",
- "plt.show()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "186",
- "metadata": {},
- "source": [
- "## Create basemap gallery"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "187",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "188",
- "metadata": {},
- "outputs": [],
- "source": [
- "for basemap in leafmap.basemaps:\n",
- " print(basemap)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "189",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = list(leafmap.basemaps.keys())[17:117]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "190",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.linked_maps(rows=20, cols=5, height=\"200px\", layers=layers, labels=layers)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "191",
- "metadata": {},
- "source": [
- "## Create linked map"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "192",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "193",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.basemaps.keys()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "194",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = [\"ROADMAP\", \"HYBRID\"]\n",
- "leafmap.linked_maps(rows=1, cols=2, height=\"400px\", layers=layers)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "195",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = [\"Esri.WorldTopoMap\", \"OpenTopoMap\"]\n",
- "leafmap.linked_maps(rows=1, cols=2, height=\"400px\", layers=layers)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "196",
- "metadata": {},
- "source": [
- "Create a 2 * 2 linked map to visualize land cover change. Specify the `center` and `zoom` parameters to change the default map center and zoom level."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "197",
- "metadata": {},
- "outputs": [],
- "source": [
- "layers = [str(f\"NLCD {year} CONUS Land Cover\") for year in [2001, 2006, 2011, 2016]]\n",
- "labels = [str(f\"NLCD {year}\") for year in [2001, 2006, 2011, 2016]]\n",
- "leafmap.linked_maps(\n",
- " rows=2,\n",
- " cols=2,\n",
- " height=\"300px\",\n",
- " layers=layers,\n",
- " labels=labels,\n",
- " center=[36.1, -115.2],\n",
- " zoom=9,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "198",
- "metadata": {},
- "source": [
- "## Create split-panel map\n",
- "\n",
- "Create a split-panel map by specifying the `left_layer` and `right_layer`, which can be chosen from the basemap names, or any custom XYZ tile layer."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "199",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "200",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_map(left_layer=\"ROADMAP\", right_layer=\"HYBRID\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "201",
- "metadata": {},
- "source": [
- "Hide the zoom control from the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "202",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_map(\n",
- " left_layer=\"Esri.WorldTopoMap\", right_layer=\"OpenTopoMap\", zoom_control=False\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "203",
- "metadata": {},
- "source": [
- "Add labels to the map and change the default map center and zoom level."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "204",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.split_map(\n",
- " left_layer=\"NLCD 2001 CONUS Land Cover\",\n",
- " right_layer=\"NLCD 2019 CONUS Land Cover\",\n",
- " left_label=\"2001\",\n",
- " right_label=\"2019\",\n",
- " label_position=\"bottom\",\n",
- " center=[36.1, -114.9],\n",
- " zoom=10,\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "205",
- "metadata": {},
- "source": [
- "## Create heat map\n",
- "\n",
- "Specify the file path to the CSV. It can either be a file locally or on the Internet."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "206",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "207",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(layers_control=True)\n",
- "in_csv = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.csv\"\n",
- "m.add_heatmap(\n",
- " in_csv,\n",
- " latitude=\"latitude\",\n",
- " longitude=\"longitude\",\n",
- " value=\"pop_max\",\n",
- " name=\"Heat map\",\n",
- " radius=20,\n",
- ")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "208",
- "metadata": {},
- "source": [
- "Use the folium plotting backend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "209",
- "metadata": {},
- "outputs": [],
- "source": [
- "from leafmap import foliumap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "210",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = foliumap.Map()\n",
- "in_csv = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.csv\"\n",
- "m.add_heatmap(\n",
- " in_csv,\n",
- " latitude=\"latitude\",\n",
- " longitude=\"longitude\",\n",
- " value=\"pop_max\",\n",
- " name=\"Heat map\",\n",
- " radius=20,\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "211",
- "metadata": {},
- "outputs": [],
- "source": [
- "colors = [\"blue\", \"lime\", \"red\"]\n",
- "m.add_colorbar(colors=colors, vmin=0, vmax=10000)\n",
- "m.add_title(\"World Population Heat Map\", font_size=\"20px\", align=\"center\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "212",
- "metadata": {},
- "source": [
- "## Save map to HTML"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "213",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "214",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_basemap(\"Esri.NatGeoWorldMap\")\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "215",
- "metadata": {},
- "source": [
- "Specify the output HTML file name to save the map as a web page."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "216",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.to_html(\"mymap.html\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "217",
- "metadata": {},
- "source": [
- "If the output HTML file name is not provided, the function will return a string containing contain the source code of the HTML file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "218",
- "metadata": {},
- "outputs": [],
- "source": [
- "html = m.to_html()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "219",
- "metadata": {},
- "outputs": [],
- "source": [
- "# print(html)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "220",
- "metadata": {},
- "source": [
- "## Use kepler plotting backend"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "221",
- "metadata": {},
- "outputs": [],
- "source": [
- "import leafmap.kepler as leafmap"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "222",
- "metadata": {},
- "source": [
- "### Create an interactive map\n",
- "\n",
- "Create an interactive map. You can specify various parameters to initialize the map, such as `center`, `zoom`, `height`, and `widescreen`."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "223",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[40, -100], zoom=2, height=600, widescreen=False)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "224",
- "metadata": {},
- "source": [
- "If you encounter an error saying `Error displaying widget: model not found` when trying to display the map, you can use `m.static_map()` as a workaround until this [kepler.gl bug](https://github.com/keplergl/kepler.gl/issues/1165) has been resolved."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "225",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.static_map(width=1280, height=600)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "226",
- "metadata": {},
- "source": [
- "### Add CSV\n",
- "\n",
- "Add a CSV to the map. If you have a map config file, you can directly apply config to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "227",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[37.7621, -122.4143], zoom=12)\n",
- "in_csv = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/hex_data.csv\"\n",
- "config = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/hex_config.json\"\n",
- "m.add_csv(in_csv, layer_name=\"hex_data\", config=config)\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "228",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.static_map(width=1280, height=600)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "229",
- "metadata": {},
- "source": [
- "### Save map config\n",
- "\n",
- "Save the map configuration as a JSON file."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "230",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.save_config(\"cache/config.json\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "231",
- "metadata": {},
- "source": [
- "### Save map as html\n",
- "\n",
- "Save the map to an interactive html."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "232",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.to_html(outfile=\"cache/kepler_hex.html\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "233",
- "metadata": {},
- "source": [
- "### Add GeoJONS\n",
- "\n",
- "Add a GeoJSON with US state boundaries to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "234",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[50, -110], zoom=2)\n",
- "polygons = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_states.json\"\n",
- "m.add_geojson(polygons, layer_name=\"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "235",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.static_map(width=1280, height=600)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "236",
- "metadata": {},
- "source": [
- "### Add shapefile\n",
- "\n",
- "Add a shapefile to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "237",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[20, 0], zoom=1)\n",
- "in_shp = \"https://github.com/opengeos/leafmap/raw/master/examples/data/countries.zip\"\n",
- "m.add_shp(in_shp, \"Countries\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "238",
- "metadata": {},
- "outputs": [],
- "source": [
- "m.static_map(width=1280, height=600)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "239",
- "metadata": {},
- "source": [
- "### Add GeoDataFrame\n",
- "\n",
- "Add a GeoPandas GeoDataFrame to the map."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "240",
- "metadata": {},
- "outputs": [],
- "source": [
- "import geopandas as gpd"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "241",
- "metadata": {},
- "outputs": [],
- "source": [
- "gdf = gpd.read_file(\n",
- " \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.geojson\"\n",
- ")\n",
- "gdf"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "242",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[20, 0], zoom=1)\n",
- "m.add_gdf(gdf, \"World cities\")\n",
- "m"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "243",
- "metadata": {},
- "outputs": [],
- "source": [
- "# m.static_map(width=1280, height=600)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "244",
- "metadata": {},
- "source": [
- "## Use planet imagery\n",
- "\n",
- "First, you need to [sign up](https://www.planet.com/login/?mode=signup) a Planet account and get an API key. See https://developers.planet.com/quickstart/apis.\n",
- "Uncomment the following line to pass in your API key."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "245",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "246",
- "metadata": {},
- "outputs": [],
- "source": [
- "if os.environ.get(\"PLANET_API_KEY\") is None:\n",
- " os.environ[\"PLANET_API_KEY\"] = \"your-api-key\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "247",
- "metadata": {},
- "outputs": [],
- "source": [
- "quarterly_tiles = leafmap.planet_quarterly_tiles()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "248",
- "metadata": {},
- "outputs": [],
- "source": [
- "for tile in quarterly_tiles:\n",
- " print(tile)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "249",
- "metadata": {},
- "outputs": [],
- "source": [
- "monthly_tiles = leafmap.planet_monthly_tiles()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "250",
- "metadata": {},
- "outputs": [],
- "source": [
- "for tile in monthly_tiles:\n",
- " print(tile)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "251",
- "metadata": {},
- "source": [
- "Add a Planet monthly mosaic by specifying year and month."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "252",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_planet_by_month(year=2020, month=8)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "253",
- "metadata": {},
- "source": [
- "Add a Planet quarterly mosaic by specifying year and quarter."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "254",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.add_planet_by_quarter(year=2019, quarter=2)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "255",
- "metadata": {},
- "source": [
- "## Use timeseries inspector"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "256",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "257",
- "metadata": {},
- "outputs": [],
- "source": [
- "if os.environ.get(\"PLANET_API_KEY\") is None:\n",
- " os.environ[\"PLANET_API_KEY\"] = \"your-api-key\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "258",
- "metadata": {},
- "outputs": [],
- "source": [
- "tiles = leafmap.planet_tiles()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "259",
- "metadata": {},
- "outputs": [],
- "source": [
- "leafmap.ts_inspector(tiles, center=[40, -100], zoom=4)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "260",
- "metadata": {},
- "source": [
- "## Use time slider"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "261",
- "metadata": {},
- "source": [
- "Use the time slider to visualize Planet quarterly mosaic.\n",
- "\n",
- "![](https://i.imgur.com/ipVJ4cb.gif)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "262",
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "import leafmap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "263",
- "metadata": {},
- "outputs": [],
- "source": [
- "if os.environ.get(\"PLANET_API_KEY\") is None:\n",
- " os.environ[\"PLANET_API_KEY\"] = \"your-api-key\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "264",
- "metadata": {},
- "source": [
- "Specify the map center and zoom level."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "265",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map(center=[38.2659, -103.2447], zoom=13)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "266",
- "metadata": {},
- "source": [
- "Use the time slider to visualize Planet quarterly mosaic."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "267",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "layers_dict = leafmap.planet_quarterly_tiles()\n",
- "m.add_time_slider(layers_dict, time_interval=1)\n",
- "m"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "268",
- "metadata": {},
- "source": [
- "Use the time slider to visualize basemaps."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "269",
- "metadata": {},
- "outputs": [],
- "source": [
- "m = leafmap.Map()\n",
- "m.clear_layers()\n",
- "layers_dict = leafmap.basemap_xyz_tiles()\n",
- "m.add_time_slider(layers_dict, time_interval=1)\n",
- "m"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}