├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── feature_request.md ├── dependabot.yml └── workflows │ ├── codeql.yml │ ├── dependency-review.yml │ ├── docker-delete-pr-tags.yml │ ├── docker-image.yml │ ├── docker-publish.yml │ ├── docs-build.yml │ ├── docs.yml │ ├── installation.yml │ ├── macos.yml │ ├── py313.yml │ ├── pypi.yml │ ├── ubuntu.yml │ └── windows.yml ├── .gitignore ├── .mergify.yml ├── .pre-commit-config.yaml ├── CITATION.cff ├── CODE_OF_CONDUCT.md ├── Dockerfile ├── LICENSE ├── MANIFEST.in ├── README.md ├── docs ├── CNAME ├── ads.txt ├── assets │ ├── README.md │ ├── archive │ │ ├── README.md │ │ ├── favicon.png │ │ └── logo.png │ ├── favicon.png │ ├── logo.png │ └── logo_rect.png ├── basemaps.md ├── bokehmap.md ├── changelog.md ├── changelog_update.py ├── check_maplibre.py ├── colormaps.md ├── common.md ├── contributing.md ├── data │ ├── README.md │ ├── cable_geo.geojson │ ├── cog_files.txt │ ├── cog_post_event.txt │ ├── cog_pre_event.txt │ ├── countries.cpg │ ├── countries.dbf │ ├── countries.geojson │ ├── countries.prj │ ├── countries.shp │ ├── countries.shx │ ├── countries.zip │ ├── hex_config.json │ ├── hex_data.csv │ ├── sf_zip_geo.json │ ├── states.csv │ ├── states.kmz │ ├── us_cities.cpg │ ├── us_cities.csv │ ├── us_cities.dbf │ ├── us_cities.geojson │ ├── us_cities.json │ ├── us_cities.prj │ ├── us_cities.shp │ ├── us_cities.shx │ ├── us_states.cpg │ ├── us_states.dbf │ ├── us_states.json │ ├── us_states.kml │ ├── us_states.kmz │ ├── us_states.prj │ ├── us_states.shp │ ├── us_states.shx │ ├── world_cities.cpg │ ├── world_cities.csv │ ├── world_cities.dbf │ ├── world_cities.geojson │ ├── world_cities.prj │ ├── world_cities.shp │ └── world_cities.shx ├── deck.md ├── deckgl.md ├── download.md ├── examples.md ├── faq.md ├── foliumap.md ├── get-started.md ├── html │ ├── kepler.html │ ├── kepler_cities.html │ ├── kepler_countries.html │ ├── kepler_hex.html │ ├── kepler_lines.html │ └── kepler_states.html ├── index.md ├── installation.md ├── kepler.md ├── leafmap.md ├── legends.md ├── map_widgets.md ├── maplibre │ ├── 3d_buildings.ipynb │ ├── 3d_choropleth.ipynb │ ├── 3d_indoor_mapping.ipynb │ ├── 3d_pmtiles.ipynb │ ├── 3d_style.ipynb │ ├── 3d_terrain.ipynb │ ├── MGRS.ipynb │ ├── _template.ipynb │ ├── add_3d_buildings.ipynb │ ├── add_a_marker.ipynb │ ├── add_colorbar.ipynb │ ├── add_components.ipynb │ ├── add_deckgl_layer.ipynb │ ├── add_gif.ipynb │ ├── add_html.ipynb │ ├── add_icon.ipynb │ ├── add_image.ipynb │ ├── add_image_generated.ipynb │ ├── add_labels.ipynb │ ├── add_legend.ipynb │ ├── add_logo.ipynb │ ├── add_text.ipynb │ ├── animate_a_line.ipynb │ ├── animate_camera_around_point.ipynb │ ├── animate_images.ipynb │ ├── animate_point_along_line.ipynb │ ├── animate_point_along_route.ipynb │ ├── attribution_position.ipynb │ ├── basemaps.ipynb │ ├── center_on_symbol.ipynb │ ├── change_building_color.ipynb │ ├── change_case_of_labels.ipynb │ ├── choropleth.ipynb │ ├── cloud_optimized_geotiff.ipynb │ ├── cluster.ipynb │ ├── color_switcher.ipynb │ ├── countries_filter.ipynb │ ├── create_vector.ipynb │ ├── custom_marker.ipynb │ ├── data_driven_lines.ipynb │ ├── disable_scroll_zoom.ipynb │ ├── display_rich_text.ipynb │ ├── drag_a_marker.ipynb │ ├── draw_features.ipynb │ ├── edit_vector.ipynb │ ├── fallback_image.ipynb │ ├── fields_of_the_world.ipynb │ ├── fill_pattern.ipynb │ ├── fit_bounds.ipynb │ ├── fly_to.ipynb │ ├── fly_to_options.ipynb │ ├── fullscreen.ipynb │ ├── geojson_layer_in_stack.ipynb │ ├── geojson_line.ipynb │ ├── geojson_points.ipynb │ ├── geojson_polygon.ipynb │ ├── geopandas.ipynb │ ├── globe_control.ipynb │ ├── google_earth_engine.ipynb │ ├── gps_trace.ipynb │ ├── heatmap_layer.ipynb │ ├── housing_prices.ipynb │ ├── interactive_false.ipynb │ ├── jump_to.ipynb │ ├── language_switch.ipynb │ ├── layer_control.ipynb │ ├── layer_groups.ipynb │ ├── layer_manager.ipynb │ ├── layer_styling.ipynb │ ├── line_gradient.ipynb │ ├── live_geojson.ipynb │ ├── live_update_feature.ipynb │ ├── local_geojson.ipynb │ ├── local_raster.ipynb │ ├── locate_user.ipynb │ ├── map_tiles.ipynb │ ├── mapillary.ipynb │ ├── maptiler_styles.ipynb │ ├── mouse_position.ipynb │ ├── multiple_geometries.ipynb │ ├── nasa_opera.ipynb │ ├── navigation.ipynb │ ├── ocean_bathymetry.ipynb │ ├── openfreemap.ipynb │ ├── openstreetmap.ipynb │ ├── overture.ipynb │ ├── overview.md │ ├── pmtiles.ipynb │ ├── restrict_bounds.ipynb │ ├── satellite_map.ipynb │ ├── search_control.ipynb │ ├── set_pitch_bearing.ipynb │ ├── sidebar.ipynb │ ├── stac.ipynb │ ├── to_html.ipynb │ ├── variable_label_placement.ipynb │ ├── variable_offset_label_placement.ipynb │ ├── vector_tile.ipynb │ ├── video_on_a_map.ipynb │ ├── visualize_population_density.ipynb │ ├── wms_source.ipynb │ └── zoom_to_linestring.ipynb ├── maplibregl.md ├── maps.md ├── notebooks │ ├── 00_key_features.ipynb │ ├── 01_leafmap_intro.ipynb │ ├── 02_using_basemaps.ipynb │ ├── 03_cog_stac.ipynb │ ├── 04_cog_mosaic.ipynb │ ├── 05_load_raster.ipynb │ ├── 06_legend.ipynb │ ├── 07_colorbar.ipynb │ ├── 08_whitebox.ipynb │ ├── 09_csv_to_points.ipynb │ ├── 100_nlcd.ipynb │ ├── 101_nasa_opera.ipynb │ ├── 102_fused.ipynb │ ├── 103_raster_colormap.ipynb │ ├── 104_point_style.ipynb │ ├── 105_vector_time_slider.ipynb │ ├── 10_add_vector.ipynb │ ├── 11_linked_maps.ipynb │ ├── 12_split_map.ipynb │ ├── 13_geopandas.ipynb │ ├── 14_postgis.ipynb │ ├── 15_openstreetmap.ipynb │ ├── 16_heremap.ipynb │ ├── 17_vector_tile_layer.ipynb │ ├── 18_point_layer.ipynb │ ├── 19_map_to_html.ipynb │ ├── 20_planet_imagery.ipynb │ ├── 21_ts_inspector.ipynb │ ├── 22_time_slider.ipynb │ ├── 23_colormaps.ipynb │ ├── 24_heatmap.ipynb │ ├── 25_map_title.ipynb │ ├── 26_kepler_gl.ipynb │ ├── 27_basemap_gallery.ipynb │ ├── 28_publish_map.ipynb │ ├── 29_pydeck.ipynb │ ├── 30_census_data.ipynb │ ├── 31_search_basemaps.ipynb │ ├── 32_local_tile.ipynb │ ├── 33_image_overlay.ipynb │ ├── 34_add_points_from_xy.ipynb │ ├── 35_circle_markers.ipynb │ ├── 36_add_labels.ipynb │ ├── 37_planetary_computer.ipynb │ ├── 38_plotly.ipynb │ ├── 39_inspector_tool.ipynb │ ├── 40_plotly_gui.ipynb │ ├── 41_raster_gui.ipynb │ ├── 42_create_cog.ipynb │ ├── 43_search_control.ipynb │ ├── 44_attribute_table.ipynb │ ├── 45_create_vector.ipynb │ ├── 46_edit_vector.ipynb │ ├── 47_numpy_to_cog.ipynb │ ├── 48_lidar.ipynb │ ├── 49_split_control.ipynb │ ├── 50_marker_cluster.ipynb │ ├── 51_clip_image.ipynb │ ├── 52_netcdf.ipynb │ ├── 53_choropleth.ipynb │ ├── 54_plot_raster.ipynb │ ├── 55_lidar.ipynb │ ├── 56_download_ned.ipynb │ ├── 57_national_map.ipynb │ ├── 58_bokeh.ipynb │ ├── 59_create_legend.ipynb │ ├── 60_add_widget.ipynb │ ├── 61_vector_to_gif.ipynb │ ├── 62_folium_colorbar.ipynb │ ├── 63_arcgis.ipynb │ ├── 64_stac_search.ipynb │ ├── 65_sagemaker.ipynb │ ├── 66_gradio.ipynb │ ├── 67_maxar_open_data.ipynb │ ├── 68_openaerialmap.ipynb │ ├── 69_turkey_earthquake.ipynb │ ├── 70_zonal_stats.ipynb │ ├── 71_aws_s3.ipynb │ ├── 72_timelapse.ipynb │ ├── 73_custom_stac.ipynb │ ├── 74_map_tiles_to_geotiff.ipynb │ ├── 75_segment_anything.ipynb │ ├── 76_image_comparison.ipynb │ ├── 77_split_raster.ipynb │ ├── 78_read_raster.ipynb │ ├── 79_timeseries.ipynb │ ├── 80_solar.ipynb │ ├── 81_buildings.ipynb │ ├── 82_pmtiles.ipynb │ ├── 83_vector_viz.ipynb │ ├── 84_read_parquet.ipynb │ ├── 85_gedi.ipynb │ ├── 86_add_markers.ipynb │ ├── 87_actinia.ipynb │ ├── 88_nasa_earth_data.ipynb │ ├── 89_image_array_viz.ipynb │ ├── 90_pixel_inspector.ipynb │ ├── 91_raster_viz_gui.ipynb │ ├── 92_maplibre.ipynb │ ├── 93_maplibre_pmtiles.ipynb │ ├── 94_mapbox.ipynb │ ├── 95_edit_vector.ipynb │ ├── 96_batch_edit_vector.ipynb │ ├── 97_overture_data.ipynb │ ├── 98_watershed.ipynb │ ├── 99_wetlands.ipynb │ └── zz_notebook_template.ipynb ├── osm.md ├── overrides │ └── main.html ├── pc.md ├── plot.md ├── plotlymap.md ├── search_bk.md ├── search_docs.html ├── stac.md ├── toolbar.md ├── tutorials.md ├── usage.md └── workshops │ ├── CVPR_2025.ipynb │ ├── EarthCube_2023.ipynb │ ├── FOSS4G_2021.ipynb │ ├── HGAC_2024.ipynb │ ├── ICRW_2023.ipynb │ ├── SIGSPATIAL_2021.ipynb │ ├── Taiwan_2024.ipynb │ └── YouthMappers_2021.ipynb ├── environment.yml ├── examples ├── README.md ├── batch_update.py ├── check_colab.py └── data │ ├── README.md │ ├── cable_geo.geojson │ ├── cog.tif │ ├── cog_files.txt │ ├── cog_post_event.txt │ ├── cog_pre_event.txt │ ├── countries.cpg │ ├── countries.dbf │ ├── countries.geojson │ ├── countries.gpkg │ ├── countries.prj │ ├── countries.shp │ ├── countries.shx │ ├── countries.zip │ ├── hex_config.json │ ├── hex_data.csv │ ├── mask.geojson │ ├── sf_zip_geo.json │ ├── states.csv │ ├── states.kmz │ ├── training_samples.geojson │ ├── us_cities.cpg │ ├── us_cities.csv │ ├── us_cities.dbf │ ├── us_cities.geojson │ ├── us_cities.prj │ ├── us_cities.qmd │ ├── us_cities.shp │ ├── us_cities.shx │ ├── us_regions.geojson │ ├── us_states.cpg │ ├── us_states.dbf │ ├── us_states.json │ ├── us_states.kml │ ├── us_states.kmz │ ├── us_states.prj │ ├── us_states.shp │ ├── us_states.shx │ ├── world_cities.cpg │ ├── world_cities.csv │ ├── world_cities.dbf │ ├── world_cities.geojson │ ├── world_cities.prj │ ├── world_cities.shp │ └── world_cities.shx ├── leafmap ├── __init__.py ├── basemaps.py ├── bokehmap.py ├── colormaps.py ├── common.py ├── data │ ├── census_data.json │ ├── fonts │ │ └── arial.ttf │ ├── pc_inventory.json │ └── template │ │ ├── legend.html │ │ ├── legend.txt │ │ └── legend_style.html ├── deck.py ├── deckgl.py ├── download.py ├── examples │ ├── __init__.py │ └── datasets.txt ├── foliumap.py ├── heremap.py ├── javascript │ └── mapbox.js ├── kepler.py ├── leafmap.py ├── legends.py ├── map_widgets.py ├── mapbox.py ├── maplibregl.py ├── osm.py ├── pc.py ├── plot.py ├── plotlymap.py ├── report.py ├── stac.py ├── styles │ └── mapbox.css └── toolbar.py ├── mkdocs.yml ├── paper ├── SIGSPATIAL_Workshop.pdf ├── paper.bib └── paper.md ├── pyproject.toml ├── requirements.txt ├── requirements_dev.txt ├── requirements_docs.txt ├── tests ├── __init__.py ├── test_common.py ├── test_foliumap.py ├── test_leafmap.py ├── test_osm.py └── test_toolbar.py └── uv.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | charset = utf-8 11 | end_of_line = lf 12 | 13 | [*.bat] 14 | indent_style = tab 15 | end_of_line = crlf 16 | 17 | [LICENSE] 18 | insert_final_newline = false 19 | 20 | [Makefile] 21 | indent_style = tab 22 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: giswqs 2 | custom: 3 | - buymeacoffee.com/giswqs 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a bug report to help us improve 4 | labels: bug 5 | --- 6 | 7 | 8 | 9 | ### Environment Information 10 | 11 | - leafmap version: 12 | - Python version: 13 | - Operating System: 14 | 15 | ### Description 16 | 17 | Describe what you were trying to get done. 18 | Tell us what happened, what went wrong, and what you expected to happen. 19 | 20 | ### What I Did 21 | 22 | ``` 23 | Paste the command(s) you ran and the output. 24 | If there was a crash, please include the traceback here. 25 | ``` 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: Ask questions 3 | url: https://github.com/opengeos/leafmap/discussions/categories/q-a 4 | about: Please ask and answer questions here. 5 | - name: Ideas 6 | url: https://github.com/opengeos/leafmap/discussions/categories/ideas 7 | about: Please share your ideas here. 8 | - name: Ask questions from the GIS community 9 | url: https://gis.stackexchange.com 10 | about: To get answers from questions in the GIS commminuty, please ask and answer questions here. 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Submit a feature request to help us improve 4 | labels: Feature Request 5 | --- 6 | 7 | 8 | 9 | ### Description 10 | 11 | Describe the feature (e.g., new functions/tutorials) you would like to propose. 12 | Tell us what can be achieved with this new feature and what's the expected outcome. 13 | 14 | ### Source code 15 | 16 | ``` 17 | Paste your source code here if have sample code to share. 18 | ``` 19 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "docker" 9 | directory: "/" 10 | schedule: 11 | interval: "weekly" 12 | - package-ecosystem: "pip" 13 | directory: "/" 14 | schedule: 15 | interval: "weekly" 16 | - package-ecosystem: "github-actions" 17 | directory: "/" 18 | schedule: 19 | interval: "weekly" 20 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: ["master"] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: ["master"] 20 | schedule: 21 | - cron: "15 20 * * 1" 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: ["python"] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 37 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v4 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v3 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | 52 | # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 53 | # queries: security-extended,security-and-quality 54 | 55 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 56 | # If this step fails, then you should remove it and run the build manually (see below) 57 | - name: Autobuild 58 | uses: github/codeql-action/autobuild@v3 59 | 60 | # ℹ️ Command-line programs to run using the OS shell. 61 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 62 | 63 | # If the Autobuild fails above, remove it and uncomment the following three lines. 64 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. 65 | 66 | # - run: | 67 | # echo "Run, Build Application using script" 68 | # ./location_of_script_within_repo/buildscript.sh 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v3 72 | with: 73 | category: "/language:${{matrix.language}}" 74 | -------------------------------------------------------------------------------- /.github/workflows/dependency-review.yml: -------------------------------------------------------------------------------- 1 | # Dependency Review Action 2 | # 3 | # This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging. 4 | # 5 | # Source repository: https://github.com/actions/dependency-review-action 6 | # Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement 7 | name: "Dependency Review" 8 | on: [pull_request] 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | dependency-review: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: "Checkout Repository" 18 | uses: actions/checkout@v4 19 | - name: "Dependency Review" 20 | uses: actions/dependency-review-action@v4 21 | -------------------------------------------------------------------------------- /.github/workflows/docker-delete-pr-tags.yml: -------------------------------------------------------------------------------- 1 | name: Delete All GHCR PR Tags 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | workflow_dispatch: 8 | 9 | jobs: 10 | delete-pr-tags: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Delete all GHCR image tags starting with "pr-" 15 | env: 16 | GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} 17 | REPO: ${{ github.event.repository.name }} 18 | OWNER: ${{ github.repository_owner }} 19 | run: | 20 | echo "Fetching GHCR container versions for ghcr.io/${OWNER}/${REPO}..." 21 | 22 | response=$(curl -s -H "Authorization: Bearer ${GHCR_TOKEN}" \ 23 | "https://api.github.com/orgs/${OWNER}/packages/container/${REPO}/versions") 24 | 25 | # Check that the response is a JSON array 26 | if ! echo "$response" | jq -e 'type == "array"' > /dev/null; then 27 | echo "❌ Unexpected response from GitHub API:" 28 | echo "$response" 29 | exit 1 30 | fi 31 | 32 | echo "$response" | jq -c '.[]' | while read -r version; do 33 | version_id=$(echo "$version" | jq -r '.id') 34 | tag_names=$(echo "$version" | jq -r '.metadata.container.tags[]?') 35 | 36 | for tag in $tag_names; do 37 | if [[ "$tag" == pr-* ]]; then 38 | echo "🗑️ Deleting tag: $tag (version ID: $version_id)" 39 | curl -s -X DELETE -H "Authorization: Bearer ${GHCR_TOKEN}" \ 40 | "https://api.github.com/orgs/${OWNER}/packages/container/${REPO}/versions/${version_id}" 41 | break # One deletion per version is sufficient 42 | fi 43 | done 44 | done 45 | -------------------------------------------------------------------------------- /.github/workflows/docker-image.yml: -------------------------------------------------------------------------------- 1 | name: Build Docker Image 2 | 3 | on: 4 | release: 5 | types: [published] 6 | push: 7 | branches: 8 | - master 9 | pull_request: 10 | types: [opened, synchronize, reopened] 11 | 12 | jobs: 13 | build-and-push: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | contents: read 17 | packages: write 18 | 19 | steps: 20 | - name: Checkout code 21 | uses: actions/checkout@v4 22 | 23 | - name: Set up Docker Buildx 24 | uses: docker/setup-buildx-action@v3 25 | 26 | - name: Log in to GitHub Container Registry (ghcr.io) 27 | uses: docker/login-action@v3 28 | with: 29 | registry: ghcr.io 30 | username: ${{ github.actor }} 31 | password: ${{ secrets.GITHUB_TOKEN }} 32 | 33 | - name: Set Docker image tags 34 | id: meta 35 | run: | 36 | REPO=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} 37 | 38 | if [[ "${{ github.event_name }}" == "release" ]]; then 39 | VERSION_TAG=${{ github.event.release.tag_name }} 40 | echo "tags<> $GITHUB_OUTPUT 41 | echo "${REPO}:${VERSION_TAG}" >> $GITHUB_OUTPUT 42 | echo "${REPO}:latest" >> $GITHUB_OUTPUT 43 | echo "EOF" >> $GITHUB_OUTPUT 44 | 45 | elif [[ "${{ github.event_name }}" == "pull_request" ]]; then 46 | PR_NUMBER=${{ github.event.pull_request.number }} 47 | echo "tags=${REPO}:pr-${PR_NUMBER}" >> $GITHUB_OUTPUT 48 | 49 | else 50 | echo "tags=${REPO}:dev" >> $GITHUB_OUTPUT 51 | fi 52 | 53 | - name: Build and push multi-platform image 54 | uses: docker/build-push-action@v6 55 | with: 56 | context: . 57 | platforms: linux/amd64,linux/arm64 58 | push: true 59 | tags: ${{ steps.meta.outputs.tags }} 60 | provenance: false 61 | cache-from: type=gha 62 | cache-to: type=gha,mode=max 63 | -------------------------------------------------------------------------------- /.github/workflows/docker-publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish Docker image 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | push_to_registries: 9 | name: Push Docker image to multiple registries 10 | runs-on: ubuntu-latest 11 | permissions: 12 | packages: write 13 | contents: read 14 | steps: 15 | - name: Check out the repo 16 | uses: actions/checkout@v4 17 | 18 | - name: Log in to Docker Hub 19 | uses: docker/login-action@v3 20 | with: 21 | username: ${{ secrets.DOCKER_USERNAME }} 22 | password: ${{ secrets.DOCKER_PASSWORD }} 23 | 24 | - name: Log in to the Container registry 25 | uses: docker/login-action@v3 26 | with: 27 | registry: ghcr.io 28 | username: ${{ github.actor }} 29 | password: ${{ secrets.GITHUB_TOKEN }} 30 | 31 | - name: Extract metadata (tags, labels) for Docker 32 | id: meta 33 | uses: docker/metadata-action@v5 34 | with: 35 | images: | 36 | giswqs/leafmap 37 | ghcr.io/${{ github.repository }} 38 | 39 | - name: Build and push Docker images 40 | uses: docker/build-push-action@v6 41 | with: 42 | context: . 43 | push: true 44 | tags: ${{ steps.meta.outputs.tags }} 45 | labels: ${{ steps.meta.outputs.labels }} 46 | -------------------------------------------------------------------------------- /.github/workflows/docs-build.yml: -------------------------------------------------------------------------------- 1 | name: docs-build 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | docs-build: 10 | runs-on: ubuntu-latest 11 | strategy: 12 | matrix: 13 | python-version: ["3.12"] 14 | 15 | env: 16 | PLANET_API_KEY: ${{ secrets.PLANET_API_KEY }} 17 | USE_FOLIUM: ${{ secrets.USE_FOLIUM }} 18 | USE_MKDOCS: ${{ secrets.USE_MKDOCS }} 19 | MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }} 20 | AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} 21 | AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 22 | EARTHDATA_USERNAME: ${{ secrets.EARTHDATA_USERNAME }} 23 | EARTHDATA_PASSWORD: ${{ secrets.EARTHDATA_PASSWORD }} 24 | MAPILLARY_API_KEY: ${{ secrets.MAPILLARY_API_KEY }} 25 | steps: 26 | - uses: actions/checkout@v4 27 | with: 28 | fetch-depth: 0 29 | 30 | - name: Install uv 31 | uses: astral-sh/setup-uv@v6 32 | with: 33 | version: "0.4.16" 34 | # enable-cache: true 35 | 36 | - name: Set up Python ${{ matrix.python-version }} 37 | run: uv python install ${{ matrix.python-version }} 38 | 39 | - name: Install dependencies 40 | run: | 41 | uv venv --python ${{ matrix.python-version }} 42 | uv pip install . 43 | 44 | - name: Install optional dependencies 45 | run: | 46 | uv pip install --find-links https://girder.github.io/large_image_wheels GDAL pyproj 47 | uv pip install pytest 48 | uv pip install -r requirements_dev.txt 49 | 50 | - name: Test import 51 | run: | 52 | uv run python -c "import leafmap; print('leafmap import successful')" 53 | uv run python -c "from osgeo import gdal; print('gdal import successful')" 54 | uv run gdalinfo --version 55 | 56 | - name: Running pytest 57 | run: | 58 | uv run pytest . --verbose 59 | 60 | - name: Install mkdocs 61 | run: | 62 | uv pip install -r requirements_docs.txt 63 | uv run mkdocs build 64 | 65 | - name: Deploy to Netlify 66 | uses: nwtgck/actions-netlify@v3.0 67 | with: 68 | publish-dir: "./site" 69 | production-branch: master 70 | github-token: ${{ secrets.GITHUB_TOKEN }} 71 | deploy-message: "Deploy from GitHub Actions" 72 | enable-pull-request-comment: true 73 | enable-commit-comment: false 74 | overwrites-pull-request-comment: true 75 | env: 76 | NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} 77 | NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} 78 | 79 | - name: Cleanup 80 | if: always() 81 | run: | 82 | echo "Cleaning up resources." 83 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: docs 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-latest 11 | strategy: 12 | matrix: 13 | python-version: ["3.12"] 14 | 15 | env: 16 | PLANET_API_KEY: ${{ secrets.PLANET_API_KEY }} 17 | USE_FOLIUM: ${{ secrets.USE_FOLIUM }} 18 | USE_MKDOCS: ${{ secrets.USE_MKDOCS }} 19 | MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }} 20 | AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} 21 | AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 22 | EARTHDATA_USERNAME: ${{ secrets.EARTHDATA_USERNAME }} 23 | EARTHDATA_PASSWORD: ${{ secrets.EARTHDATA_PASSWORD }} 24 | MAPILLARY_API_KEY: ${{ secrets.MAPILLARY_API_KEY }} 25 | steps: 26 | - uses: actions/checkout@v4 27 | with: 28 | fetch-depth: 0 29 | 30 | - name: Install uv 31 | uses: astral-sh/setup-uv@v6 32 | with: 33 | version: "0.4.16" 34 | # enable-cache: true 35 | 36 | - name: Set up Python ${{ matrix.python-version }} 37 | run: uv python install ${{ matrix.python-version }} 38 | 39 | - name: Install dependencies 40 | run: | 41 | uv venv --python ${{ matrix.python-version }} 42 | uv pip install . 43 | 44 | - name: Install optional dependencies 45 | run: | 46 | uv pip install --find-links https://girder.github.io/large_image_wheels GDAL pyproj 47 | uv pip install pytest 48 | uv pip install -r requirements_dev.txt 49 | 50 | - name: Test import 51 | run: | 52 | uv run python -c "import leafmap; print('leafmap import successful')" 53 | uv run python -c "from osgeo import gdal; print('gdal import successful')" 54 | uv run gdalinfo --version 55 | 56 | - name: Running pytest 57 | run: | 58 | uv run pytest . --verbose 59 | 60 | - name: Install mkdocs 61 | run: | 62 | uv pip install -r requirements_docs.txt 63 | uv run mkdocs gh-deploy --force 64 | -------------------------------------------------------------------------------- /.github/workflows/installation.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | pull_request: 6 | branches: 7 | - master 8 | 9 | name: Linux installation 10 | jobs: 11 | test-ubuntu: 12 | runs-on: ubuntu-latest 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | python-version: ["3.12"] 17 | steps: 18 | - uses: actions/checkout@v4 19 | 20 | - name: Install uv 21 | uses: astral-sh/setup-uv@v6 22 | with: 23 | version: "0.4.16" 24 | # enable-cache: true 25 | 26 | - name: Set up Python ${{ matrix.python-version }} 27 | run: uv python install ${{ matrix.python-version }} 28 | 29 | - name: Install dependencies 30 | run: | 31 | uv venv --python ${{ matrix.python-version }} 32 | uv pip install . 33 | 34 | - name: Test import 35 | run: uv run python -c "import leafmap; print('leafmap import successful')" 36 | -------------------------------------------------------------------------------- /.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | pull_request: 6 | branches: 7 | - master 8 | 9 | name: macOS build 10 | jobs: 11 | test-macOS: 12 | runs-on: ${{ matrix.config.os }} 13 | name: ${{ matrix.config.os }} (${{ matrix.config.py }}) 14 | strategy: 15 | fail-fast: false 16 | matrix: 17 | config: 18 | - { os: macOS-latest, py: "3.12" } 19 | env: 20 | SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk 21 | steps: 22 | - uses: actions/checkout@v4 23 | 24 | - name: Install uv 25 | uses: astral-sh/setup-uv@v6 26 | with: 27 | version: "0.4.16" 28 | # enable-cache: true 29 | 30 | - name: Set up Python ${{ matrix.config.py }} 31 | run: uv python install ${{ matrix.config.py }} 32 | 33 | - name: Install dependencies 34 | run: | 35 | uv venv --python ${{ matrix.config.py }} 36 | uv pip install . 37 | 38 | - name: Test import 39 | run: | 40 | uv run python -c "import leafmap; print('leafmap import successful')" 41 | -------------------------------------------------------------------------------- /.github/workflows/py313.yml: -------------------------------------------------------------------------------- 1 | name: TestingLeafmapUbuntu 2 | 3 | on: 4 | push: 5 | branches: ["master"] 6 | pull_request: 7 | branches: ["master"] 8 | 9 | jobs: 10 | test-ubuntu: 11 | runs-on: ubuntu-latest 12 | 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | python-version: ["3.13"] 17 | 18 | env: 19 | PLANET_API_KEY: ${{ secrets.PLANET_API_KEY }} 20 | USE_FOLIUM: ${{ secrets.USE_FOLIUM }} 21 | USE_MKDOCS: ${{ secrets.USE_MKDOCS }} 22 | HEREMAPS_API_KEY: ${{ secrets.HEREMAPS_API_KEY }} 23 | DP_TOKEN: ${{ secrets.DP_TOKEN }} 24 | MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }} 25 | AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} 26 | AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 27 | 28 | MAPILLARY_API_KEY: ${{ secrets.MAPILLARY_API_KEY }} 29 | 30 | steps: 31 | - uses: actions/checkout@v4 32 | 33 | - name: Install uv 34 | uses: astral-sh/setup-uv@v6 35 | with: 36 | version: "0.4.16" 37 | enable-cache: false 38 | 39 | - name: Set up Python ${{ matrix.python-version }} 40 | run: uv python install ${{ matrix.python-version }} 41 | 42 | - name: Install dependencies 43 | run: | 44 | uv venv --python ${{ matrix.python-version }} 45 | uv pip install . 46 | 47 | # - name: Test import 48 | # run: | 49 | # uv run python -c "import leafmap; print('leafmap import successful')" 50 | -------------------------------------------------------------------------------- /.github/workflows/pypi.yml: -------------------------------------------------------------------------------- 1 | # This workflows will upload a Python Package using Twine when a release is created 2 | # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries 3 | 4 | name: pypi 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | deploy: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: Set up Python 17 | uses: actions/setup-python@v5 18 | with: 19 | python-version: "3.x" 20 | - name: Install dependencies 21 | run: | 22 | python -m pip install --upgrade pip 23 | pip install setuptools wheel twine 24 | - name: Build and publish 25 | env: 26 | TWINE_USERNAME: ${{ secrets.PYPI_USERS }} 27 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 28 | run: | 29 | pip install build 30 | python -m build 31 | twine upload dist/* 32 | -------------------------------------------------------------------------------- /.github/workflows/ubuntu.yml: -------------------------------------------------------------------------------- 1 | name: TestingLeafmapUbuntu 2 | 3 | on: 4 | push: 5 | branches: ["master"] 6 | pull_request: 7 | branches: ["master"] 8 | 9 | jobs: 10 | test-ubuntu: 11 | runs-on: ubuntu-latest 12 | 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | python-version: ["3.9", "3.10", "3.11", "3.12"] 17 | 18 | env: 19 | PLANET_API_KEY: ${{ secrets.PLANET_API_KEY }} 20 | USE_FOLIUM: ${{ secrets.USE_FOLIUM }} 21 | USE_MKDOCS: ${{ secrets.USE_MKDOCS }} 22 | HEREMAPS_API_KEY: ${{ secrets.HEREMAPS_API_KEY }} 23 | DP_TOKEN: ${{ secrets.DP_TOKEN }} 24 | MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }} 25 | AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} 26 | AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 27 | MAPILLARY_API_KEY: ${{ secrets.MAPILLARY_API_KEY }} 28 | 29 | steps: 30 | - uses: actions/checkout@v4 31 | 32 | - name: Install uv 33 | uses: astral-sh/setup-uv@v6 34 | with: 35 | version: "0.4.16" 36 | # enable-cache: true 37 | 38 | - name: Set up Python ${{ matrix.python-version }} 39 | run: uv python install ${{ matrix.python-version }} 40 | 41 | - name: Install dependencies 42 | run: | 43 | uv venv --python ${{ matrix.python-version }} 44 | uv pip install . 45 | 46 | - name: Install optional dependencies 47 | run: | 48 | uv pip install --find-links https://girder.github.io/large_image_wheels gdal pyproj 49 | uv pip install pytest 50 | uv pip install -r requirements_dev.txt 51 | 52 | - name: Test import 53 | run: | 54 | uv run python -c "import leafmap; print('leafmap import successful')" 55 | uv run python -c "from osgeo import gdal; print('gdal import successful')" 56 | uv run gdalinfo --version 57 | 58 | - name: Running pytest 59 | run: | 60 | uv run pytest . --verbose 61 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: "TestingLeafmapWindows" 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | jobs: 11 | test-windows: 12 | runs-on: windows-latest 13 | strategy: 14 | matrix: 15 | python-version: ["3.12"] 16 | 17 | env: 18 | PLANET_API_KEY: ${{ secrets.PLANET_API_KEY }} 19 | USE_FOLIUM: ${{ secrets.USE_FOLIUM }} 20 | USE_MKDOCS: ${{ secrets.USE_MKDOCS }} 21 | MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }} 22 | AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} 23 | AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 24 | MAPILLARY_API_KEY: ${{ secrets.MAPILLARY_API_KEY }} 25 | 26 | steps: 27 | - uses: actions/checkout@v4 28 | 29 | - name: Install uv 30 | uses: astral-sh/setup-uv@v6 31 | with: 32 | version: "0.4.16" 33 | # enable-cache: true 34 | 35 | - name: Set up Python ${{ matrix.python-version }} 36 | run: uv python install ${{ matrix.python-version }} 37 | 38 | - name: Install dependencies 39 | run: | 40 | uv venv --python ${{ matrix.python-version }} 41 | uv pip install . 42 | 43 | - name: Test import 44 | run: | 45 | uv run python -c "import leafmap; print('leafmap import successful')" 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | # *.tif 6 | # *.png 7 | **/.DS_Store 8 | # C extensions 9 | *.so 10 | docs/maplibre/*.md 11 | 12 | # Distribution / packaging 13 | docs/maplibre/*.tif 14 | examples/notebooks/cache/ 15 | examples/notebooks/*.tif 16 | examples/notebooks/*.gif 17 | examples/notebooks/*.zip 18 | examples/notebooks/*.jpg 19 | docs/notebooks/cache/ 20 | docs/javascripts/ 21 | docs/notebooks/*.html 22 | docs/html/*.html 23 | docs/notebooks/*.tif 24 | docs/notebooks/*.xml 25 | docs/notebooks/*.las 26 | docs/notebooks/*.laz 27 | docs/notebooks/*.las 28 | docs/notebooks/*.zip 29 | docs/notebooks/*.geojson 30 | docs/notebooks/*.kml 31 | docs/notebooks/*.nc 32 | docs/notebooks/*.csv 33 | docs/notebooks/*.png 34 | docs/notebooks/*.gif 35 | docs/notebooks/**/*.tif 36 | examples/notebooks/*.html 37 | examples/notebooks/*.tif 38 | examples/**/*.tif 39 | examples/html/ 40 | docs/cache/ 41 | docs/changelog_update.md 42 | **/*.las 43 | # docs/*.html 44 | cache/ 45 | testing/ 46 | private/ 47 | .Python 48 | env/ 49 | build/ 50 | develop-eggs/ 51 | dist/ 52 | downloads/ 53 | eggs/ 54 | .eggs/ 55 | lib/ 56 | lib64/ 57 | parts/ 58 | sdist/ 59 | var/ 60 | wheels/ 61 | *.egg-info/ 62 | .installed.cfg 63 | *.egg 64 | 65 | # PyInstaller 66 | # Usually these files are written by a python script from a template 67 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 68 | *.manifest 69 | *.spec 70 | 71 | # Installer logs 72 | pip-log.txt 73 | pip-delete-this-directory.txt 74 | 75 | # Unit test / coverage reports 76 | htmlcov/ 77 | .tox/ 78 | .coverage 79 | .coverage.* 80 | .cache 81 | nosetests.xml 82 | coverage.xml 83 | *.cover 84 | .hypothesis/ 85 | .pytest_cache/ 86 | 87 | # Translations 88 | *.mo 89 | *.pot 90 | 91 | # Django stuff: 92 | *.log 93 | local_settings.py 94 | 95 | # Flask stuff: 96 | instance/ 97 | .webassets-cache 98 | 99 | # Scrapy stuff: 100 | .scrapy 101 | 102 | # Sphinx documentation 103 | docs/_build/ 104 | 105 | # PyBuilder 106 | target/ 107 | 108 | # Jupyter Notebook 109 | .ipynb_checkpoints 110 | 111 | # pyenv 112 | .python-version 113 | 114 | # celery beat schedule file 115 | celerybeat-schedule 116 | 117 | # SageMath parsed files 118 | *.sage.py 119 | 120 | # dotenv 121 | .env 122 | 123 | # virtualenv 124 | .venv 125 | venv/ 126 | ENV/ 127 | 128 | # Spyder project settings 129 | .spyderproject 130 | .spyproject 131 | 132 | # Rope project settings 133 | .ropeproject 134 | 135 | # mkdocs documentation 136 | /site 137 | 138 | # mypy 139 | .mypy_cache/ 140 | 141 | # IDE settings 142 | .vscode/ 143 | .idea/ 144 | 145 | tests/test_testings.py 146 | docs/changelog_update.py 147 | -------------------------------------------------------------------------------- /.mergify.yml: -------------------------------------------------------------------------------- 1 | pull_request_rules: 2 | - name: CI automerge when passing all test 3 | conditions: 4 | # If the requirement are satisfied 5 | # The bot will trigger automerge 6 | - label=ready-to-merge 7 | - check-success=CodeQL 8 | - check-success=test-ubuntu (3.9) 9 | - check-success=test-ubuntu (3.10) 10 | - check-success=test-ubuntu (3.11) 11 | - check-success=test-ubuntu (3.12) 12 | - check-success=test-ubuntu (3.13) 13 | - check-success=test-windows (3.12) 14 | - check-success=macOS-latest (3.12) 15 | - check-success=docs-build (3.12) 16 | # Approval by reviewer at least one maintainer 17 | # - "#approved-reviews-by>=1" 18 | - base=master 19 | actions: 20 | comment: 21 | # message if the pull request success to merge 22 | message: Thanks for the contribution @{{author}} 🤩 23 | label: 24 | # adding label to merged pull request 25 | add: 26 | - already reviewed 27 | merge: 28 | method: squash 29 | 30 | - name: Information about conflicts pull request 31 | conditions: 32 | # If the requirement are satisfied 33 | # The bot will trigger conflict process 34 | - conflict 35 | actions: 36 | comment: 37 | # Message if there's conflict on pull request 38 | message: Your pull request are in conflict @{{author}}, please fix it! 39 | label: 40 | # adding label on pull request if get trigger 41 | add: 42 | - conflicts pull request 43 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v5.0.0 4 | hooks: 5 | - id: check-toml 6 | - id: check-yaml 7 | - id: end-of-file-fixer 8 | types: [python] 9 | - id: trailing-whitespace 10 | - id: requirements-txt-fixer 11 | - id: check-added-large-files 12 | args: ["--maxkb=500"] 13 | 14 | - repo: https://github.com/psf/black 15 | rev: 25.1.0 16 | hooks: 17 | - id: black-jupyter 18 | 19 | - repo: https://github.com/codespell-project/codespell 20 | rev: v2.4.1 21 | hooks: 22 | - id: codespell 23 | args: 24 | [ 25 | "--ignore-words-list=aci,acount,acounts,fallow,ges,hart,hist,nd,ned,ois,wqs,watermask,tre,mape", 26 | "--skip=*.csv,*.geojson,*.json,*.yml*.js,*.html,*cff,*.pdf", 27 | ] 28 | 29 | - repo: https://github.com/kynan/nbstripout 30 | rev: 0.8.1 31 | hooks: 32 | - id: nbstripout 33 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.1.0 2 | message: "If you use this software, please cite it as below." 3 | authors: 4 | - family-names: Wu 5 | given-names: Qiusheng 6 | orcid: https://orcid.org/0000-0001-5437-4073 7 | title: "Leafmap: A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment" 8 | version: 0.3.5 9 | doi: 10.21105/joss.03414 10 | date-released: 2021-07-26 11 | url: "https://github.com/opengeos/leafmap" 12 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # ------------------------------ 2 | # Base image from Jupyter stack 3 | # ------------------------------ 4 | FROM quay.io/jupyter/base-notebook:latest 5 | 6 | # ------------------------------ 7 | # 1. Switch to root to install system packages 8 | # ------------------------------ 9 | USER root 10 | 11 | RUN apt-get update && \ 12 | apt-get install -y --no-install-recommends \ 13 | git \ 14 | && apt-get clean && rm -rf /var/lib/apt/lists/* 15 | 16 | # ------------------------------ 17 | # 2. Install conda packages into base env 18 | # ------------------------------ 19 | RUN mamba install -n base -c conda-forge -y \ 20 | gdal \ 21 | proj \ 22 | geos \ 23 | fiona \ 24 | rasterio \ 25 | pyproj \ 26 | fiona \ 27 | geopandas \ 28 | maplibre \ 29 | pmtiles \ 30 | flask \ 31 | flask-cors \ 32 | localtileserver \ 33 | jupyter-server-proxy \ 34 | h5netcdf \ 35 | h5py \ 36 | opera-utils \ 37 | rioxarray \ 38 | rio-cogeo \ 39 | && mamba clean --all --yes \ 40 | && fix-permissions $CONDA_DIR 41 | 42 | # RUN mamba install -c conda-forge gdal==3.11.0 -y 43 | 44 | # ------------------------------ 45 | # 2b. Create missing sqlite symlinks (after files exist) 46 | # ------------------------------ 47 | RUN ln -s $CONDA_PREFIX/lib/libsqlite3.so.3.50.0 $CONDA_PREFIX/lib/libsqlite3.so \ 48 | && ln -s $CONDA_PREFIX/lib/libsqlite3.so.3.50.0 $CONDA_PREFIX/lib/libsqlite3.so.0 49 | 50 | 51 | # ------------------------------ 52 | # 3. Set geospatial environment variables 53 | # ------------------------------ 54 | ENV PROJ_LIB=$CONDA_DIR/share/proj \ 55 | GDAL_DATA=$CONDA_DIR/share/gdal \ 56 | LOCALTILESERVER_CLIENT_PREFIX='proxy/{port}' 57 | 58 | # ------------------------------ 59 | # 4. Copy source code after env setup 60 | # ------------------------------ 61 | COPY . /home/jovyan/leafmap 62 | WORKDIR /home/jovyan/leafmap 63 | 64 | # ------------------------------ 65 | # 5. Install leafmap from source 66 | # ------------------------------ 67 | # Prevent version resolution errors in CI 68 | ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_LEAFMAP=0.0.0 69 | 70 | RUN pip install . && \ 71 | rm -rf ./build ./dist *.egg-info && \ 72 | mkdir -p /home/jovyan/work && \ 73 | fix-permissions /home/jovyan 74 | 75 | # ------------------------------ 76 | # 6. Switch back to default user 77 | # ------------------------------ 78 | USER $NB_UID 79 | WORKDIR /home/jovyan 80 | 81 | # ------------------------------ 82 | # Usage: 83 | # docker pull giswqs/leafmap:latest 84 | # docker run -it -p 8888:8888 -v $(pwd):/home/jovyan/work giswqs/leafmap:latest 85 | # ------------------------------ 86 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021, Qiusheng Wu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include README.md 3 | include requirements.txt 4 | include requirements_dev.txt 5 | include requirements_docs.txt 6 | 7 | recursive-include leafmap/data * 8 | recursive-include leafmap/examples * 9 | recursive-include leafmap/javascript * 10 | recursive-include leafmap/styles * 11 | recursive-include tests * 12 | recursive-exclude * __pycache__ 13 | recursive-exclude * *.py[co] 14 | 15 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | leafmap.org -------------------------------------------------------------------------------- /docs/ads.txt: -------------------------------------------------------------------------------- 1 | google.com, pub-6224089686474451, DIRECT, f08c47fec0942fa0 -------------------------------------------------------------------------------- /docs/assets/README.md: -------------------------------------------------------------------------------- 1 | # Credits 2 | 3 | Credits to [Khalil Misbah](https://www.linkedin.com/in/khalil-misbah) for the original design of the leafmap logo. 4 | 5 | ![logo](https://raw.githubusercontent.com/opengeos/leafmap/master/docs/assets/logo.png) 6 | -------------------------------------------------------------------------------- /docs/assets/archive/README.md: -------------------------------------------------------------------------------- 1 | # Credits 2 | 3 | Credits to [Iban Ameztoy](https://twitter.com/i_ameztoy) for designing the first leafmap logo. 4 | 5 | ![logo](https://raw.githubusercontent.com/opengeos/leafmap/master/docs/assets/archive/logo.png) 6 | -------------------------------------------------------------------------------- /docs/assets/archive/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/assets/archive/favicon.png -------------------------------------------------------------------------------- /docs/assets/archive/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/assets/archive/logo.png -------------------------------------------------------------------------------- /docs/assets/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/assets/favicon.png -------------------------------------------------------------------------------- /docs/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/assets/logo.png -------------------------------------------------------------------------------- /docs/assets/logo_rect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/assets/logo_rect.png -------------------------------------------------------------------------------- /docs/basemaps.md: -------------------------------------------------------------------------------- 1 | # basemaps module 2 | 3 | ::: leafmap.basemaps 4 | -------------------------------------------------------------------------------- /docs/bokehmap.md: -------------------------------------------------------------------------------- 1 | # bokehmap module 2 | 3 | ::: leafmap.bokehmap 4 | -------------------------------------------------------------------------------- /docs/changelog_update.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # Copy the release notes from the GitHub release page 4 | markdown_text = """ 5 | ## What's Changed 6 | * Add 3d terrain style by @giswqs in https://github.com/opengeos/leafmap/pull/779 7 | 8 | 9 | **Full Changelog**: https://github.com/opengeos/leafmap/compare/v0.34.1...v0.34.2 10 | """ 11 | 12 | # Regular expression pattern to match the Markdown hyperlinks 13 | pattern = r"https://github\.com/opengeos/leafmap/pull/(\d+)" 14 | 15 | 16 | # Function to replace matched URLs with the desired format 17 | def replace_url(match): 18 | pr_number = match.group(1) 19 | return f"[#{pr_number}](https://github.com/opengeos/leafmap/pull/{pr_number})" 20 | 21 | 22 | # Use re.sub to replace URLs with the desired format 23 | formatted_text = re.sub(pattern, replace_url, markdown_text) 24 | 25 | for line in formatted_text.splitlines(): 26 | if "Full Changelog" in line: 27 | prefix = line.split(": ")[0] 28 | link = line.split(": ")[1] 29 | version = line.split("/")[-1] 30 | formatted_text = ( 31 | formatted_text.replace(line, f"{prefix}: [{version}]({link})") 32 | .replace("## What's Changed", "**What's Changed**") 33 | .replace("## New Contributors", "**New Contributors**") 34 | ) 35 | 36 | 37 | with open("docs/changelog_update.md", "w") as f: 38 | f.write(formatted_text) 39 | 40 | # Print the formatted text 41 | print(formatted_text) 42 | 43 | # Copy the formatted text and paste it to the CHANGELOG.md file 44 | -------------------------------------------------------------------------------- /docs/check_maplibre.py: -------------------------------------------------------------------------------- 1 | import os 2 | import leafmap.maplibregl as leafmap 3 | 4 | in_dir = "docs/maplibre/" 5 | out_dir = os.path.expanduser("~/Downloads/maplibre") 6 | files = leafmap.find_files(in_dir, "*.ipynb") 7 | leafmap.execute_maplibre_notebook_dir(in_dir, out_dir, replace_api_key=True) 8 | -------------------------------------------------------------------------------- /docs/colormaps.md: -------------------------------------------------------------------------------- 1 | # colormaps module 2 | 3 | ::: leafmap.colormaps 4 | -------------------------------------------------------------------------------- /docs/common.md: -------------------------------------------------------------------------------- 1 | # common module 2 | 3 | ::: leafmap.common 4 | -------------------------------------------------------------------------------- /docs/data/README.md: -------------------------------------------------------------------------------- 1 | ## Data Sources 2 | 3 | Some datasets contained in the repository were downloaded from various sources. Credits to the original owners of the datasets. 4 | 5 | The following datasets are downloaded from https://github.com/keplergl/kepler.gl/tree/master/bindings/kepler.gl-jupyter/notebooks 6 | 7 | - hex_data.csv 8 | - hex_config.json 9 | - sf_zip_geo.json 10 | -------------------------------------------------------------------------------- /docs/data/countries.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /docs/data/countries.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/countries.dbf -------------------------------------------------------------------------------- /docs/data/countries.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] -------------------------------------------------------------------------------- /docs/data/countries.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/countries.shp -------------------------------------------------------------------------------- /docs/data/countries.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/countries.shx -------------------------------------------------------------------------------- /docs/data/countries.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/countries.zip -------------------------------------------------------------------------------- /docs/data/states.csv: -------------------------------------------------------------------------------- 1 | system:index,id,name 2 | 0,AL,Alabama 3 | 1,AK,Alaska 4 | 2,AZ,Arizona 5 | 3,AR,Arkansas 6 | 4,CA,California 7 | 5,CO,Colorado 8 | 6,CT,Connecticut 9 | 7,DE,Delaware 10 | 8,FL,Florida 11 | 9,GA,Georgia 12 | 10,HI,Hawaii 13 | 11,ID,Idaho 14 | 12,IL,Illinois 15 | 13,IN,Indiana 16 | 14,IA,Iowa 17 | 15,KS,Kansas 18 | 16,KY,Kentucky 19 | 17,LA,Louisiana 20 | 18,ME,Maine 21 | 19,MD,Maryland 22 | 20,MA,Massachusetts 23 | 21,MI,Michigan 24 | 22,MN,Minnesota 25 | 23,MS,Mississippi 26 | 24,MO,Missouri 27 | 25,MT,Montana 28 | 26,NE,Nebraska 29 | 27,NV,Nevada 30 | 28,NH,New Hampshire 31 | 29,NJ,New Jersey 32 | 30,NM,New Mexico 33 | 31,NY,New York 34 | 32,NC,North Carolina 35 | 33,ND,North Dakota 36 | 34,OH,Ohio 37 | 35,OK,Oklahoma 38 | 36,OR,Oregon 39 | 37,PA,Pennsylvania 40 | 38,RI,Rhode Island 41 | 39,SC,South Carolina 42 | 40,SD,South Dakota 43 | 41,TN,Tennessee 44 | 42,TX,Texas 45 | 43,UT,Utah 46 | 44,VT,Vermont 47 | 45,VA,Virginia 48 | 46,WA,Washington 49 | 47,WV,West Virginia 50 | 48,WI,Wisconsin 51 | 49,WY,Wyoming 52 | -------------------------------------------------------------------------------- /docs/data/states.kmz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/states.kmz -------------------------------------------------------------------------------- /docs/data/us_cities.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /docs/data/us_cities.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/us_cities.dbf -------------------------------------------------------------------------------- /docs/data/us_cities.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /docs/data/us_cities.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/us_cities.shp -------------------------------------------------------------------------------- /docs/data/us_cities.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/us_cities.shx -------------------------------------------------------------------------------- /docs/data/us_states.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /docs/data/us_states.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/us_states.dbf -------------------------------------------------------------------------------- /docs/data/us_states.kmz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/us_states.kmz -------------------------------------------------------------------------------- /docs/data/us_states.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /docs/data/us_states.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/us_states.shp -------------------------------------------------------------------------------- /docs/data/us_states.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/us_states.shx -------------------------------------------------------------------------------- /docs/data/world_cities.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /docs/data/world_cities.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/world_cities.dbf -------------------------------------------------------------------------------- /docs/data/world_cities.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] -------------------------------------------------------------------------------- /docs/data/world_cities.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/world_cities.shp -------------------------------------------------------------------------------- /docs/data/world_cities.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/docs/data/world_cities.shx -------------------------------------------------------------------------------- /docs/deck.md: -------------------------------------------------------------------------------- 1 | # pydeck module 2 | 3 | ::: leafmap.deck 4 | -------------------------------------------------------------------------------- /docs/deckgl.md: -------------------------------------------------------------------------------- 1 | # deckgl module 2 | 3 | ::: leafmap.deckgl 4 | -------------------------------------------------------------------------------- /docs/download.md: -------------------------------------------------------------------------------- 1 | # download module 2 | 3 | ::: leafmap.download 4 | -------------------------------------------------------------------------------- /docs/examples.md: -------------------------------------------------------------------------------- 1 | # examples module 2 | 3 | ::: leafmap.examples 4 | -------------------------------------------------------------------------------- /docs/foliumap.md: -------------------------------------------------------------------------------- 1 | # foliumap module 2 | 3 | ::: leafmap.foliumap 4 | -------------------------------------------------------------------------------- /docs/kepler.md: -------------------------------------------------------------------------------- 1 | # kepler module 2 | 3 | ::: leafmap.kepler 4 | -------------------------------------------------------------------------------- /docs/leafmap.md: -------------------------------------------------------------------------------- 1 | 2 | # leafmap module 3 | 4 | ::: leafmap.leafmap -------------------------------------------------------------------------------- /docs/legends.md: -------------------------------------------------------------------------------- 1 | # legends module 2 | 3 | ::: leafmap.legends 4 | -------------------------------------------------------------------------------- /docs/map_widgets.md: -------------------------------------------------------------------------------- 1 | # map_widgets module 2 | 3 | ::: leafmap.map_widgets 4 | -------------------------------------------------------------------------------- /docs/maplibre/_template.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/_template_.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/_template.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**MapLibre Example**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [maplibre_xxx](https://maplibre.org/maplibre-gl-js/docs/examples/maplibre_xxx/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(center=[-100, 40], zoom=3, style=\"streets\")\n", 60 | "m" 61 | ] 62 | } 63 | ], 64 | "metadata": { 65 | "kernelspec": { 66 | "display_name": "Python 3 (ipykernel)", 67 | "language": "python", 68 | "name": "python3" 69 | }, 70 | "language_info": { 71 | "codemirror_mode": { 72 | "name": "ipython", 73 | "version": 3 74 | }, 75 | "file_extension": ".py", 76 | "mimetype": "text/x-python", 77 | "name": "python", 78 | "nbconvert_exporter": "python", 79 | "pygments_lexer": "ipython3", 80 | "version": "3.1.-1" 81 | } 82 | }, 83 | "nbformat": 4, 84 | "nbformat_minor": 4 85 | } 86 | -------------------------------------------------------------------------------- /docs/maplibre/add_a_marker.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/add_marker.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/add_marker.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Add a default marker**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [Add a default marker](https://maplibre.org/maplibre-gl-js/docs/examples/add-a-marker/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": null, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "m = leafmap.Map(center=[12.550343, 55.665957], zoom=8, style=\"positron\")\n", 43 | "m.add_marker(lng_lat=[12.550343, 55.665957])\n", 44 | "m" 45 | ] 46 | }, 47 | { 48 | "cell_type": "markdown", 49 | "metadata": {}, 50 | "source": [ 51 | "![](https://i.imgur.com/ufmqTzx.png)" 52 | ] 53 | } 54 | ], 55 | "metadata": { 56 | "kernelspec": { 57 | "display_name": "Python 3 (ipykernel)", 58 | "language": "python", 59 | "name": "python3" 60 | }, 61 | "language_info": { 62 | "codemirror_mode": { 63 | "name": "ipython", 64 | "version": 3 65 | }, 66 | "file_extension": ".py", 67 | "mimetype": "text/x-python", 68 | "name": "python", 69 | "nbconvert_exporter": "python", 70 | "pygments_lexer": "ipython3", 71 | "version": "3.11.9" 72 | } 73 | }, 74 | "nbformat": 4, 75 | "nbformat_minor": 4 76 | } 77 | -------------------------------------------------------------------------------- /docs/maplibre/add_gif.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/add_gif.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/add_gif.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Add GIF animations to the map**\n", 12 | "\n", 13 | "This example shows how to add GIF animations to the map.\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": null, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "m = leafmap.Map(center=[-100, 40], zoom=3, style=\"positron\")\n", 43 | "image = \"https://i.imgur.com/KeiAsTv.gif\"\n", 44 | "m.add_image(image=image, width=250, height=250, position=\"bottom-right\")\n", 45 | "text = \"I love sloth!🦥\"\n", 46 | "m.add_text(text, fontsize=35, padding=\"20px\")\n", 47 | "image2 = \"https://i.imgur.com/kZC2tpr.gif\"\n", 48 | "m.add_image(image=image2, bg_color=\"transparent\", position=\"bottom-left\")\n", 49 | "m" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "![](https://i.imgur.com/auytBtD.png)" 57 | ] 58 | } 59 | ], 60 | "metadata": { 61 | "kernelspec": { 62 | "display_name": "Python 3 (ipykernel)", 63 | "language": "python", 64 | "name": "python3" 65 | }, 66 | "language_info": { 67 | "codemirror_mode": { 68 | "name": "ipython", 69 | "version": 3 70 | }, 71 | "file_extension": ".py", 72 | "mimetype": "text/x-python", 73 | "name": "python", 74 | "nbconvert_exporter": "python", 75 | "pygments_lexer": "ipython3", 76 | "version": "3.11.9" 77 | } 78 | }, 79 | "nbformat": 4, 80 | "nbformat_minor": 4 81 | } 82 | -------------------------------------------------------------------------------- /docs/maplibre/add_html.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/add_html.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/add_html.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Add HTML content to the map**\n", 12 | "\n", 13 | "This example shows how to add HTML content to the map using the `add_html()` method.\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": null, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "m = leafmap.Map(center=[-100, 40], zoom=3, style=\"positron\")\n", 43 | "html = \"\"\"\n", 44 | "\n", 45 | "\n", 50 | "\n", 51 | "\n", 52 | "🚀\n", 53 | "

I will display 🚁

\n", 54 | "

I will display 🚂

\n", 55 | "\n", 56 | "\n", 57 | "\n", 58 | "\"\"\"\n", 59 | "m.add_html(html, bg_color=\"transparent\")\n", 60 | "m" 61 | ] 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "metadata": {}, 66 | "source": [ 67 | "![](https://i.imgur.com/TgalNOv.png)" 68 | ] 69 | } 70 | ], 71 | "metadata": { 72 | "kernelspec": { 73 | "display_name": "Python 3 (ipykernel)", 74 | "language": "python", 75 | "name": "python3" 76 | }, 77 | "language_info": { 78 | "codemirror_mode": { 79 | "name": "ipython", 80 | "version": 3 81 | }, 82 | "file_extension": ".py", 83 | "mimetype": "text/x-python", 84 | "name": "python", 85 | "nbconvert_exporter": "python", 86 | "pygments_lexer": "ipython3", 87 | "version": "3.11.8" 88 | } 89 | }, 90 | "nbformat": 4, 91 | "nbformat_minor": 4 92 | } 93 | -------------------------------------------------------------------------------- /docs/maplibre/add_logo.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/add_logo.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/add_logo.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Add a logo to the map**\n", 12 | "\n", 13 | "This example shows how to add a logo to the map.\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": null, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "m = leafmap.Map(center=[-100, 40], zoom=3, style=\"positron\")\n", 43 | "image = \"https://i.imgur.com/LmTETPX.png\"\n", 44 | "m.add_image(image=image, position=\"bottom-right\")\n", 45 | "m" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": null, 51 | "metadata": {}, 52 | "outputs": [], 53 | "source": [ 54 | "m = leafmap.Map(center=[-100, 40], zoom=3, style=\"positron\")\n", 55 | "content = ''\n", 56 | "m.add_html(content, bg_color=\"transparent\", position=\"bottom-right\")\n", 57 | "m" 58 | ] 59 | }, 60 | { 61 | "cell_type": "markdown", 62 | "metadata": {}, 63 | "source": [ 64 | "![](https://i.imgur.com/Pp9U4Li.png)" 65 | ] 66 | } 67 | ], 68 | "metadata": { 69 | "kernelspec": { 70 | "display_name": "Python 3 (ipykernel)", 71 | "language": "python", 72 | "name": "python3" 73 | }, 74 | "language_info": { 75 | "codemirror_mode": { 76 | "name": "ipython", 77 | "version": 3 78 | }, 79 | "file_extension": ".py", 80 | "mimetype": "text/x-python", 81 | "name": "python", 82 | "nbconvert_exporter": "python", 83 | "pygments_lexer": "ipython3", 84 | "version": "3.11.8" 85 | } 86 | }, 87 | "nbformat": 4, 88 | "nbformat_minor": 4 89 | } 90 | -------------------------------------------------------------------------------- /docs/maplibre/add_text.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/add_text.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/add_text.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Add text to the map**\n", 12 | "\n", 13 | "Add HTML text to the map.\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(center=[-100, 40], zoom=3, style=\"streets\")\n", 60 | "text = \"Hello World\"\n", 61 | "m.add_text(text, fontsize=20, position=\"bottom-right\")\n", 62 | "text2 = \"Awesome Text!\"\n", 63 | "m.add_text(text2, fontsize=25, bg_color=\"rgba(255, 255, 255, 0.8)\", position=\"top-left\")\n", 64 | "m" 65 | ] 66 | }, 67 | { 68 | "cell_type": "markdown", 69 | "metadata": {}, 70 | "source": [ 71 | "![](https://i.imgur.com/UAtlh3r.png)" 72 | ] 73 | } 74 | ], 75 | "metadata": { 76 | "kernelspec": { 77 | "display_name": "Python 3 (ipykernel)", 78 | "language": "python", 79 | "name": "python3" 80 | }, 81 | "language_info": { 82 | "codemirror_mode": { 83 | "name": "ipython", 84 | "version": 3 85 | }, 86 | "file_extension": ".py", 87 | "mimetype": "text/x-python", 88 | "name": "python", 89 | "nbconvert_exporter": "python", 90 | "pygments_lexer": "ipython3", 91 | "version": "3.11.9" 92 | } 93 | }, 94 | "nbformat": 4, 95 | "nbformat_minor": 4 96 | } 97 | -------------------------------------------------------------------------------- /docs/maplibre/attribution_position.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/attribution_position.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/attribution_position.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Change the default position for attribution**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [Change the default position for attribution](https://maplibre.org/maplibre-gl-js/docs/examples/attribution-position/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(center=[-77.04, 38.907], zoom=11, style=\"streets\", controls={})\n", 60 | "m.add_control(\"attribution\", position=\"top-left\")\n", 61 | "m" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "![](https://i.imgur.com/DsmqIOy.png)" 69 | ] 70 | } 71 | ], 72 | "metadata": { 73 | "kernelspec": { 74 | "display_name": "Python 3 (ipykernel)", 75 | "language": "python", 76 | "name": "python3" 77 | }, 78 | "language_info": { 79 | "codemirror_mode": { 80 | "name": "ipython", 81 | "version": 3 82 | }, 83 | "file_extension": ".py", 84 | "mimetype": "text/x-python", 85 | "name": "python", 86 | "nbconvert_exporter": "python", 87 | "pygments_lexer": "ipython3", 88 | "version": "3.11.9" 89 | } 90 | }, 91 | "nbformat": 4, 92 | "nbformat_minor": 4 93 | } 94 | -------------------------------------------------------------------------------- /docs/maplibre/color_switcher.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/color_switcher.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/color_switcher.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Change a layer's color with buttons**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [Change a layer's color with buttons](https://maplibre.org/maplibre-gl-js/docs/examples/color-switcher/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(center=[12.338, 45.4385], zoom=17, style=\"streets\")\n", 60 | "m" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": null, 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [ 69 | "m.style_layer_interact(id=\"water\")" 70 | ] 71 | }, 72 | { 73 | "attachments": {}, 74 | "cell_type": "markdown", 75 | "metadata": {}, 76 | "source": [ 77 | "![](https://i.imgur.com/Q3BbItI.png)" 78 | ] 79 | } 80 | ], 81 | "metadata": { 82 | "kernelspec": { 83 | "display_name": "Python 3 (ipykernel)", 84 | "language": "python", 85 | "name": "python3" 86 | }, 87 | "language_info": { 88 | "codemirror_mode": { 89 | "name": "ipython", 90 | "version": 3 91 | }, 92 | "file_extension": ".py", 93 | "mimetype": "text/x-python", 94 | "name": "python", 95 | "nbconvert_exporter": "python", 96 | "pygments_lexer": "ipython3", 97 | "version": "3.11.9" 98 | } 99 | }, 100 | "nbformat": 4, 101 | "nbformat_minor": 4 102 | } 103 | -------------------------------------------------------------------------------- /docs/maplibre/disable_scroll_zoom.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/disable_scroll_zoom.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/disable_scroll_zoom.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Disable scroll zoom**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [Disable scroll zoom](https://maplibre.org/maplibre-gl-js/docs/examples/disable-scroll-zoom/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(center=[-122.65, 45.52], zoom=9, scroll_zoom=False, style=\"streets\")\n", 60 | "m" 61 | ] 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "metadata": {}, 66 | "source": [ 67 | "![](https://i.imgur.com/ShhYGaq.png)" 68 | ] 69 | } 70 | ], 71 | "metadata": { 72 | "kernelspec": { 73 | "display_name": "Python 3 (ipykernel)", 74 | "language": "python", 75 | "name": "python3" 76 | }, 77 | "language_info": { 78 | "codemirror_mode": { 79 | "name": "ipython", 80 | "version": 3 81 | }, 82 | "file_extension": ".py", 83 | "mimetype": "text/x-python", 84 | "name": "python", 85 | "nbconvert_exporter": "python", 86 | "pygments_lexer": "ipython3", 87 | "version": "3.11.9" 88 | } 89 | }, 90 | "nbformat": 4, 91 | "nbformat_minor": 4 92 | } 93 | -------------------------------------------------------------------------------- /docs/maplibre/drag_a_marker.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/drag_a_marker.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/drag_a_marker.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Create a draggable Marker**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [Create a draggable Marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(center=[0, 0], zoom=2, style=\"streets\")\n", 60 | "m.add_marker(lng_lat=[0, 0], options={\"draggable\": True})\n", 61 | "m" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "![](https://i.imgur.com/9RNVuRf.png)" 69 | ] 70 | } 71 | ], 72 | "metadata": { 73 | "kernelspec": { 74 | "display_name": "Python 3 (ipykernel)", 75 | "language": "python", 76 | "name": "python3" 77 | }, 78 | "language_info": { 79 | "codemirror_mode": { 80 | "name": "ipython", 81 | "version": 3 82 | }, 83 | "file_extension": ".py", 84 | "mimetype": "text/x-python", 85 | "name": "python", 86 | "nbconvert_exporter": "python", 87 | "pygments_lexer": "ipython3", 88 | "version": "3.11.9" 89 | } 90 | }, 91 | "nbformat": 4, 92 | "nbformat_minor": 4 93 | } 94 | -------------------------------------------------------------------------------- /docs/maplibre/edit_vector.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/edit_vector.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/edit_vector.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Edit Vector Data Interactively**\n", 12 | "\n", 13 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": null, 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# %pip install \"leafmap[maplibre]\"" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "metadata": {}, 29 | "outputs": [], 30 | "source": [ 31 | "import leafmap.maplibregl as leafmap" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "m = leafmap.Map()\n", 41 | "m.add_basemap(\"Google Satellite\")\n", 42 | "url = \"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/naip_train_buildings.geojson\"\n", 43 | "properties = {\n", 44 | " \"class\": [\"apartments\", \"terrace\", \"detached\", \"house\", \"shed\", None],\n", 45 | " \"height\": 0.0,\n", 46 | "}\n", 47 | "widget = leafmap.edit_vector_data(m, url, properties=properties)\n", 48 | "m.add_layer_control()\n", 49 | "widget" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "![image](https://github.com/user-attachments/assets/c86f78ee-1f50-418e-981e-b01fe61b2b53)" 57 | ] 58 | } 59 | ], 60 | "metadata": { 61 | "kernelspec": { 62 | "display_name": "Python 3 (ipykernel)", 63 | "language": "python", 64 | "name": "python3" 65 | }, 66 | "language_info": { 67 | "codemirror_mode": { 68 | "name": "ipython", 69 | "version": 3 70 | }, 71 | "file_extension": ".py", 72 | "mimetype": "text/x-python", 73 | "name": "python", 74 | "nbconvert_exporter": "python", 75 | "pygments_lexer": "ipython3", 76 | "version": "3.12.2" 77 | } 78 | }, 79 | "nbformat": 4, 80 | "nbformat_minor": 4 81 | } 82 | -------------------------------------------------------------------------------- /docs/maplibre/fly_to.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/fly_to.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/fly_to.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Fly to a location**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [Fly to a location](https://maplibre.org/maplibre-gl-js/docs/examples/flyto/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(center=[-2.242467, 53.478122], zoom=9, style=\"streets\")\n", 60 | "m" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": null, 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [ 69 | "m.fly_to(lon=-73.983609, lat=40.754368, zoom=12)" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "metadata": {}, 75 | "source": [ 76 | "![](https://i.imgur.com/UVlvpi9.png)" 77 | ] 78 | } 79 | ], 80 | "metadata": { 81 | "kernelspec": { 82 | "display_name": "Python 3 (ipykernel)", 83 | "language": "python", 84 | "name": "python3" 85 | }, 86 | "language_info": { 87 | "codemirror_mode": { 88 | "name": "ipython", 89 | "version": 3 90 | }, 91 | "file_extension": ".py", 92 | "mimetype": "text/x-python", 93 | "name": "python", 94 | "nbconvert_exporter": "python", 95 | "pygments_lexer": "ipython3", 96 | "version": "3.11.9" 97 | } 98 | }, 99 | "nbformat": 4, 100 | "nbformat_minor": 4 101 | } 102 | -------------------------------------------------------------------------------- /docs/maplibre/fullscreen.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/fullscreen.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/fullscreen.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**View a fullscreen map**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [View a fullscreen map](https://maplibre.org/maplibre-gl-js/docs/examples/fullscreen/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(center=[11.255, 43.77], zoom=13, style=\"streets\", controls={})\n", 60 | "m.add_control(\"navigation\", position=\"top-left\")\n", 61 | "m.add_control(\"fullscreen\", position=\"top-right\")\n", 62 | "m" 63 | ] 64 | }, 65 | { 66 | "cell_type": "markdown", 67 | "metadata": {}, 68 | "source": [ 69 | "![](https://i.imgur.com/Vn3carH.png)" 70 | ] 71 | } 72 | ], 73 | "metadata": { 74 | "kernelspec": { 75 | "display_name": "Python 3 (ipykernel)", 76 | "language": "python", 77 | "name": "python3" 78 | }, 79 | "language_info": { 80 | "codemirror_mode": { 81 | "name": "ipython", 82 | "version": 3 83 | }, 84 | "file_extension": ".py", 85 | "mimetype": "text/x-python", 86 | "name": "python", 87 | "nbconvert_exporter": "python", 88 | "pygments_lexer": "ipython3", 89 | "version": "3.11.9" 90 | } 91 | }, 92 | "nbformat": 4, 93 | "nbformat_minor": 4 94 | } 95 | -------------------------------------------------------------------------------- /docs/maplibre/geopandas.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/geopandas.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/geopandas.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Add a GeoPandas GeoDataFrame to the map**\n", 12 | "\n", 13 | "The following notebook demonstrates how to add a GeoPandas GeoDataFrame to the map.\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import geopandas as gpd\n", 34 | "import leafmap.maplibregl as leafmap" 35 | ] 36 | }, 37 | { 38 | "cell_type": "markdown", 39 | "metadata": {}, 40 | "source": [ 41 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": null, 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "# import os\n", 51 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": null, 57 | "metadata": {}, 58 | "outputs": [], 59 | "source": [ 60 | "m = leafmap.Map(center=[-100, 40], zoom=3, style=\"streets\")\n", 61 | "url = \"https://github.com/opengeos/datasets/releases/download/us/us_states.geojson\"\n", 62 | "gdf = gpd.read_file(url)\n", 63 | "paint = {\n", 64 | " \"fill-color\": \"#3388ff\",\n", 65 | " \"fill-opacity\": 0.8,\n", 66 | " \"fill-outline-color\": \"#ffffff\",\n", 67 | "}\n", 68 | "m.add_gdf(gdf, layer_type=\"fill\", name=\"States\", paint=paint)\n", 69 | "m" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "metadata": {}, 75 | "source": [ 76 | "![](https://i.imgur.com/CQHcD7N.png)" 77 | ] 78 | } 79 | ], 80 | "metadata": { 81 | "kernelspec": { 82 | "display_name": "Python 3 (ipykernel)", 83 | "language": "python", 84 | "name": "python3" 85 | }, 86 | "language_info": { 87 | "codemirror_mode": { 88 | "name": "ipython", 89 | "version": 3 90 | }, 91 | "file_extension": ".py", 92 | "mimetype": "text/x-python", 93 | "name": "python", 94 | "nbconvert_exporter": "python", 95 | "pygments_lexer": "ipython3", 96 | "version": "3.11.9" 97 | } 98 | }, 99 | "nbformat": 4, 100 | "nbformat_minor": 4 101 | } 102 | -------------------------------------------------------------------------------- /docs/maplibre/gps_trace.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/gps_trace.ipynb)\n", 9 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/gps_trace.ipynb)\n", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "**Visualizing GPS Trace Data**\n", 13 | "\n", 14 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": null, 20 | "id": "1", 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "id": "2", 31 | "metadata": {}, 32 | "outputs": [], 33 | "source": [ 34 | "import leafmap.maplibregl as leafmap" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": null, 40 | "id": "3", 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [ 44 | "data = (\n", 45 | " \"https://github.com/opengeos/datasets/releases/download/vector/hike_gps_trace.csv\"\n", 46 | ")" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": null, 52 | "id": "4", 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "m = leafmap.Map(style=\"3d-hybrid\")\n", 57 | "m.add_gps_trace(data, radius=5, add_line=True)\n", 58 | "m.add_layer_control()\n", 59 | "m" 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "id": "5", 65 | "metadata": {}, 66 | "source": [ 67 | "![image](https://github.com/user-attachments/assets/2a669b4d-c43f-4382-bf66-8918b4719b48)" 68 | ] 69 | } 70 | ], 71 | "metadata": { 72 | "kernelspec": { 73 | "display_name": "Python 3 (ipykernel)", 74 | "language": "python", 75 | "name": "python3" 76 | }, 77 | "language_info": { 78 | "codemirror_mode": { 79 | "name": "ipython", 80 | "version": 3 81 | }, 82 | "file_extension": ".py", 83 | "mimetype": "text/x-python", 84 | "name": "python", 85 | "nbconvert_exporter": "python", 86 | "pygments_lexer": "ipython3", 87 | "version": "3.11.9" 88 | } 89 | }, 90 | "nbformat": 4, 91 | "nbformat_minor": 5 92 | } 93 | -------------------------------------------------------------------------------- /docs/maplibre/interactive_false.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/interactive_false.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/interactive_false.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Display a non-interactive map**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [Display a non-interactive map](https://maplibre.org/maplibre-gl-js/docs/examples/interactive-false/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(\n", 60 | " center=[-74.5, 40], zoom=9, interactive=False, style=\"streets\", controls={}\n", 61 | ")\n", 62 | "m" 63 | ] 64 | }, 65 | { 66 | "cell_type": "markdown", 67 | "metadata": {}, 68 | "source": [ 69 | "![](https://i.imgur.com/qZw8g3C.png)" 70 | ] 71 | } 72 | ], 73 | "metadata": { 74 | "kernelspec": { 75 | "display_name": "Python 3 (ipykernel)", 76 | "language": "python", 77 | "name": "python3" 78 | }, 79 | "language_info": { 80 | "codemirror_mode": { 81 | "name": "ipython", 82 | "version": 3 83 | }, 84 | "file_extension": ".py", 85 | "mimetype": "text/x-python", 86 | "name": "python", 87 | "nbconvert_exporter": "python", 88 | "pygments_lexer": "ipython3", 89 | "version": "3.11.9" 90 | } 91 | }, 92 | "nbformat": 4, 93 | "nbformat_minor": 4 94 | } 95 | -------------------------------------------------------------------------------- /docs/maplibre/layer_groups.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/layer_groups.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/layer_groups.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Create layer group toggle buttons**\n", 12 | "\n", 13 | "This example shows how to create layer group toggle buttons for the layer manager.\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": null, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "m = leafmap.Map()\n", 43 | "\n", 44 | "## Add basemap layers\n", 45 | "m.add_basemap(\"USGS.Imagery\")\n", 46 | "m.add_basemap(\"OpenTopoMap\")\n", 47 | "\n", 48 | "# Add GeoJSON layers\n", 49 | "point_url = (\n", 50 | " \"https://github.com/opengeos/datasets/releases/download/world/world_cities.geojson\"\n", 51 | ")\n", 52 | "m.add_geojson(point_url, name=\"Points\")\n", 53 | "line_url = (\n", 54 | " \"https://github.com/opengeos/datasets/releases/download/vector/cables.geojson\"\n", 55 | ")\n", 56 | "m.add_geojson(line_url, name=\"Lines\")\n", 57 | "\n", 58 | "# Create layer groups\n", 59 | "groups = {\"Basemap\": [\"USGS.Imagery\", \"OpenTopoMap\"], \"GeoJSON\": [\"Points\", \"Lines\"]}\n", 60 | "\n", 61 | "# Add a layer manager with group toggle buttons\n", 62 | "m.add_layer_manager(label=\"Layer Manager\", groups=groups)\n", 63 | "\n", 64 | "# Display the map\n", 65 | "m" 66 | ] 67 | }, 68 | { 69 | "cell_type": "markdown", 70 | "metadata": {}, 71 | "source": [ 72 | "![image](https://github.com/user-attachments/assets/313f60da-1ee7-4bc1-b125-7a3c0a0c3850)" 73 | ] 74 | } 75 | ], 76 | "metadata": { 77 | "kernelspec": { 78 | "display_name": "geo", 79 | "language": "python", 80 | "name": "python3" 81 | }, 82 | "language_info": { 83 | "codemirror_mode": { 84 | "name": "ipython", 85 | "version": 3 86 | }, 87 | "file_extension": ".py", 88 | "mimetype": "text/x-python", 89 | "name": "python", 90 | "nbconvert_exporter": "python", 91 | "pygments_lexer": "ipython3", 92 | "version": "3.12.2" 93 | } 94 | }, 95 | "nbformat": 4, 96 | "nbformat_minor": 4 97 | } 98 | -------------------------------------------------------------------------------- /docs/maplibre/layer_manager.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/layer_manager.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/layer_manager.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Control layer visibility and opacity with the Layer Manager**\n", 12 | "\n", 13 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": null, 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# %pip install \"leafmap[maplibre]\"" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "metadata": {}, 29 | "outputs": [], 30 | "source": [ 31 | "import leafmap.maplibregl as leafmap" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "m = leafmap.Map(\n", 41 | " style=\"3d-terrain\", projection=\"globe\", height=\"700px\", sidebar_visible=True\n", 42 | ")\n", 43 | "m.add_ee_layer(asset_id=\"ESA/WorldCover/v200\", opacity=0.5)\n", 44 | "m.add_legend(builtin_legend=\"ESA_WorldCover\", title=\"ESA Landcover\")\n", 45 | "m.add_overture_3d_buildings()\n", 46 | "m" 47 | ] 48 | }, 49 | { 50 | "cell_type": "markdown", 51 | "metadata": {}, 52 | "source": [ 53 | "![image](https://github.com/user-attachments/assets/d6624b02-332c-4df2-805e-ee39772081f1)" 54 | ] 55 | } 56 | ], 57 | "metadata": { 58 | "kernelspec": { 59 | "display_name": "Python 3 (ipykernel)", 60 | "language": "python", 61 | "name": "python3" 62 | }, 63 | "language_info": { 64 | "codemirror_mode": { 65 | "name": "ipython", 66 | "version": 3 67 | }, 68 | "file_extension": ".py", 69 | "mimetype": "text/x-python", 70 | "name": "python", 71 | "nbconvert_exporter": "python", 72 | "pygments_lexer": "ipython3", 73 | "version": "3.12.2" 74 | } 75 | }, 76 | "nbformat": 4, 77 | "nbformat_minor": 4 78 | } 79 | -------------------------------------------------------------------------------- /docs/maplibre/local_geojson.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/local_geojson.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/local_geojson.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**View local GeoJSON**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [View local GeoJSON](https://maplibre.org/maplibre-gl-js/docs/examples/local-geojson/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import os\n", 34 | "import leafmap.maplibregl as leafmap" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": null, 40 | "metadata": {}, 41 | "outputs": [], 42 | "source": [ 43 | "m = leafmap.Map(center=[-100, 40], zoom=3)\n", 44 | "m" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "m.open_geojson()" 54 | ] 55 | }, 56 | { 57 | "cell_type": "markdown", 58 | "metadata": {}, 59 | "source": [ 60 | "![](https://i.imgur.com/w3mbV2O.png)" 61 | ] 62 | } 63 | ], 64 | "metadata": { 65 | "kernelspec": { 66 | "display_name": "Python 3 (ipykernel)", 67 | "language": "python", 68 | "name": "python3" 69 | }, 70 | "language_info": { 71 | "codemirror_mode": { 72 | "name": "ipython", 73 | "version": 3 74 | }, 75 | "file_extension": ".py", 76 | "mimetype": "text/x-python", 77 | "name": "python", 78 | "nbconvert_exporter": "python", 79 | "pygments_lexer": "ipython3", 80 | "version": "3.11.9" 81 | } 82 | }, 83 | "nbformat": 4, 84 | "nbformat_minor": 4 85 | } 86 | -------------------------------------------------------------------------------- /docs/maplibre/locate_user.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/locate_user.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/locate_user.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Locate the user**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [Locate the user](https://maplibre.org/maplibre-gl-js/docs/examples/locate-user/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(center=[-96, 37.8], zoom=3, style=\"streets\", controls={})\n", 60 | "m.add_control(\"geolocate\", position=\"top-right\")\n", 61 | "m" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "![](https://i.imgur.com/nqYXzbN.png)" 69 | ] 70 | } 71 | ], 72 | "metadata": { 73 | "kernelspec": { 74 | "display_name": "Python 3 (ipykernel)", 75 | "language": "python", 76 | "name": "python3" 77 | }, 78 | "language_info": { 79 | "codemirror_mode": { 80 | "name": "ipython", 81 | "version": 3 82 | }, 83 | "file_extension": ".py", 84 | "mimetype": "text/x-python", 85 | "name": "python", 86 | "nbconvert_exporter": "python", 87 | "pygments_lexer": "ipython3", 88 | "version": "3.11.9" 89 | } 90 | }, 91 | "nbformat": 4, 92 | "nbformat_minor": 4 93 | } 94 | -------------------------------------------------------------------------------- /docs/maplibre/navigation.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/navigation.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/navigation.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**VDisplay map navigation controls**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(center=[-74.5, 40], zoom=9, style=\"streets\", controls={})\n", 60 | "m.add_control(\"navigation\", position=\"top-right\")\n", 61 | "m" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "![](https://i.imgur.com/0A2o0oI.png)" 69 | ] 70 | } 71 | ], 72 | "metadata": { 73 | "kernelspec": { 74 | "display_name": "Python 3 (ipykernel)", 75 | "language": "python", 76 | "name": "python3" 77 | }, 78 | "language_info": { 79 | "codemirror_mode": { 80 | "name": "ipython", 81 | "version": 3 82 | }, 83 | "file_extension": ".py", 84 | "mimetype": "text/x-python", 85 | "name": "python", 86 | "nbconvert_exporter": "python", 87 | "pygments_lexer": "ipython3", 88 | "version": "3.11.9" 89 | } 90 | }, 91 | "nbformat": 4, 92 | "nbformat_minor": 4 93 | } 94 | -------------------------------------------------------------------------------- /docs/maplibre/ocean_bathymetry.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/ocean_bathymetry.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/ocean_bathymetry.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Ocean bathymetry 3D**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapTiler SDK JS example - [Ocean bathymetry 3D](https://docs.maptiler.com/sdk-js/examples/ocean-bathymetry).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(style=\"3d-ocean\", exaggeration=1.5, hillshade=True)\n", 60 | "m.add_layer_control(bg_layers=True)\n", 61 | "m" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "![](https://i.imgur.com/m6NwSWG.png)" 69 | ] 70 | } 71 | ], 72 | "metadata": { 73 | "kernelspec": { 74 | "display_name": "Python 3 (ipykernel)", 75 | "language": "python", 76 | "name": "python3" 77 | }, 78 | "language_info": { 79 | "codemirror_mode": { 80 | "name": "ipython", 81 | "version": 3 82 | }, 83 | "file_extension": ".py", 84 | "mimetype": "text/x-python", 85 | "name": "python", 86 | "nbconvert_exporter": "python", 87 | "pygments_lexer": "ipython3", 88 | "version": "3.11.9" 89 | } 90 | }, 91 | "nbformat": 4, 92 | "nbformat_minor": 4 93 | } 94 | -------------------------------------------------------------------------------- /docs/maplibre/openfreemap.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/openfreemap.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/openfreemap.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Using OpenFreeMap Vector Tiles**\n", 12 | "\n", 13 | "[OpenFreeMap](https://github.com/hyperknot/openfreemap) lets you display custom maps on your website and apps for free. It provides several vector tilesets for free, including:\n", 14 | "\n", 15 | "- liberty: https://tiles.openfreemap.org/styles/liberty\n", 16 | "- positron: https://tiles.openfreemap.org/styles/positron\n", 17 | "- bright: https://tiles.openfreemap.org/styles/bright\n", 18 | "\n", 19 | "For more information, please visit https://openfreemap.org/quick_start.\n", 20 | "\n", 21 | "\n", 22 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "metadata": {}, 29 | "outputs": [], 30 | "source": [ 31 | "# %pip install \"leafmap[maplibre]\"" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "import leafmap.maplibregl as leafmap" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "m = leafmap.Map(style=\"liberty\")\n", 50 | "m" 51 | ] 52 | }, 53 | { 54 | "cell_type": "markdown", 55 | "metadata": {}, 56 | "source": [ 57 | "![image](https://github.com/user-attachments/assets/0a9c8cb8-2b7e-4ca5-ba7b-183b8b3f54a6)" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": null, 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [ 66 | "m = leafmap.Map(style=\"bright\")\n", 67 | "m" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": null, 73 | "metadata": {}, 74 | "outputs": [], 75 | "source": [ 76 | "m = leafmap.Map(style=\"positron2\")\n", 77 | "m" 78 | ] 79 | } 80 | ], 81 | "metadata": { 82 | "kernelspec": { 83 | "display_name": "Python 3 (ipykernel)", 84 | "language": "python", 85 | "name": "python3" 86 | }, 87 | "language_info": { 88 | "codemirror_mode": { 89 | "name": "ipython", 90 | "version": 3 91 | }, 92 | "file_extension": ".py", 93 | "mimetype": "text/x-python", 94 | "name": "python", 95 | "nbconvert_exporter": "python", 96 | "pygments_lexer": "ipython3", 97 | "version": "3.11.9" 98 | } 99 | }, 100 | "nbformat": 4, 101 | "nbformat_minor": 4 102 | } 103 | -------------------------------------------------------------------------------- /docs/maplibre/openstreetmap.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/openstreetmap.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/openstreetmap.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Use OpenStreetMap vector tiles**\n", 12 | "\n", 13 | "The [openstreetmap.json](https://maps.gishub.org/styles/openstreetmap.json) is adapted from the [colorful.json](https://pnorman.github.io/tilekiln-shortbread-demo/colorful.json) created by Paul Norman. For more information about the OpenStreetMap vector tiles, see this [thread](https://community.openstreetmap.org/t/vector-tiles-on-osmf-hardware/121501).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": null, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "style = \"https://maps.gishub.org/styles/openstreetmap.json\"" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": null, 48 | "metadata": {}, 49 | "outputs": [], 50 | "source": [ 51 | "m = leafmap.Map(style=style)\n", 52 | "m" 53 | ] 54 | }, 55 | { 56 | "cell_type": "markdown", 57 | "metadata": {}, 58 | "source": [ 59 | "![image](https://github.com/user-attachments/assets/af350646-d668-4eeb-a611-8ca270631d2d)" 60 | ] 61 | } 62 | ], 63 | "metadata": { 64 | "kernelspec": { 65 | "display_name": "Python 3 (ipykernel)", 66 | "language": "python", 67 | "name": "python3" 68 | }, 69 | "language_info": { 70 | "codemirror_mode": { 71 | "name": "ipython", 72 | "version": 3 73 | }, 74 | "file_extension": ".py", 75 | "mimetype": "text/x-python", 76 | "name": "python", 77 | "nbconvert_exporter": "python", 78 | "pygments_lexer": "ipython3", 79 | "version": "3.11.9" 80 | } 81 | }, 82 | "nbformat": 4, 83 | "nbformat_minor": 4 84 | } 85 | -------------------------------------------------------------------------------- /docs/maplibre/search_control.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/search_control.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/search_control.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Add a search control to the map**\n", 12 | "\n", 13 | "Use MapTiler Geocoding API to add a search control to the map.\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(center=[-100, 40], zoom=3, style=\"streets\")\n", 60 | "m.add_search_control()\n", 61 | "m" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "![image](https://github.com/user-attachments/assets/219b101a-8757-48a2-98c1-2467f78b4d04)" 69 | ] 70 | } 71 | ], 72 | "metadata": { 73 | "kernelspec": { 74 | "display_name": "geo", 75 | "language": "python", 76 | "name": "python3" 77 | }, 78 | "language_info": { 79 | "codemirror_mode": { 80 | "name": "ipython", 81 | "version": 3 82 | }, 83 | "file_extension": ".py", 84 | "mimetype": "text/x-python", 85 | "name": "python", 86 | "nbconvert_exporter": "python", 87 | "pygments_lexer": "ipython3", 88 | "version": "3.12.2" 89 | } 90 | }, 91 | "nbformat": 4, 92 | "nbformat_minor": 4 93 | } 94 | -------------------------------------------------------------------------------- /docs/maplibre/set_pitch_bearing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/set_pitch_bearning.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/set_pitch_bearning.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Set pitch and bearing**\n", 12 | "\n", 13 | "This source code of this example is adapted from the MapLibre GL JS example - [Set pitch and bearing](https://maplibre.org/maplibre-gl-js/docs/examples/set-perspective/).\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "To run this notebook, you will need an [API key](https://docs.maptiler.com/cloud/api/authentication-key/) from [MapTiler](https://www.maptiler.com/cloud/). Once you have the API key, you can uncomment the following code block and replace `YOUR_API_KEY` with your actual API key. Then, run the code block code to set the API key as an environment variable." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "# import os\n", 50 | "# os.environ[\"MAPTILER_KEY\"] = \"YOUR_API_KEY\"" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "m = leafmap.Map(\n", 60 | " center=[-73.5804, 45.53483], zoom=10, pitch=60, bearing=-60, style=\"streets\"\n", 61 | ")\n", 62 | "m" 63 | ] 64 | }, 65 | { 66 | "cell_type": "markdown", 67 | "metadata": {}, 68 | "source": [ 69 | "![](https://i.imgur.com/onKRYXz.png)" 70 | ] 71 | } 72 | ], 73 | "metadata": { 74 | "kernelspec": { 75 | "display_name": "Python 3 (ipykernel)", 76 | "language": "python", 77 | "name": "python3" 78 | }, 79 | "language_info": { 80 | "codemirror_mode": { 81 | "name": "ipython", 82 | "version": 3 83 | }, 84 | "file_extension": ".py", 85 | "mimetype": "text/x-python", 86 | "name": "python", 87 | "nbconvert_exporter": "python", 88 | "pygments_lexer": "ipython3", 89 | "version": "3.11.9" 90 | } 91 | }, 92 | "nbformat": 4, 93 | "nbformat_minor": 4 94 | } 95 | -------------------------------------------------------------------------------- /docs/maplibre/sidebar.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/sidebar.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/sidebar.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Add a sidebar widget**\n", 12 | "\n", 13 | "Create a sidebar widget to display the layer manager and custom widgets.\n", 14 | "\n", 15 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install \"leafmap[maplibre]\"" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "import leafmap.maplibregl as leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": null, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "m = leafmap.Map(style=\"3d-terrain\", projection=\"globe\", height=\"700px\")\n", 43 | "\n", 44 | "m.add_ee_layer(asset_id=\"ESA/WorldCover/v200\", opacity=0.5)\n", 45 | "m.add_overture_3d_buildings()\n", 46 | "container = m.create_container()\n", 47 | "\n", 48 | "m.add_legend_to_sidebar(\n", 49 | " builtin_legend=\"ESA_WorldCover\", title=\"Land Cover Type\", shape_type=\"rectangle\"\n", 50 | ")\n", 51 | "m.add_colorbar_to_sidebar(cmap=\"terrain\", label=\"Elevation\")\n", 52 | "\n", 53 | "image = \"https://i.imgur.com/KeiAsTv.gif\"\n", 54 | "m.add_image_to_sidebar(image=image, expanded=False)\n", 55 | "\n", 56 | "video = \"https://static-assets.mapbox.com/mapbox-gl-js/drone.mp4\"\n", 57 | "m.add_video_to_sidebar(video, expanded=False)\n", 58 | "m.set_sidebar_width(680)\n", 59 | "m" 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "metadata": {}, 65 | "source": [ 66 | "![image](https://github.com/user-attachments/assets/50250de3-fb3c-49d9-921c-b80c8f32ccb5)" 67 | ] 68 | } 69 | ], 70 | "metadata": { 71 | "kernelspec": { 72 | "display_name": "Python 3 (ipykernel)", 73 | "language": "python", 74 | "name": "python3" 75 | }, 76 | "language_info": { 77 | "codemirror_mode": { 78 | "name": "ipython", 79 | "version": 3 80 | }, 81 | "file_extension": ".py", 82 | "mimetype": "text/x-python", 83 | "name": "python", 84 | "nbconvert_exporter": "python", 85 | "pygments_lexer": "ipython3", 86 | "version": "3.1.-1" 87 | } 88 | }, 89 | "nbformat": 4, 90 | "nbformat_minor": 4 91 | } 92 | -------------------------------------------------------------------------------- /docs/maplibregl.md: -------------------------------------------------------------------------------- 1 | # maplibregl module 2 | 3 | ::: leafmap.maplibregl 4 | -------------------------------------------------------------------------------- /docs/maps.md: -------------------------------------------------------------------------------- 1 | # Interactive maps 2 | 3 | This page demonstrates some interactive maps created using the [kepler.gl](https://kepler.gl/) plotting backend. 4 | 5 | ## Create an interactive map 6 | 7 | You can specify various parameters to initialize the map, such as `center`, `zoom`, `height`, and `widescreen`. 8 | 9 | ```python 10 | import leafmap.kepler as leafmap 11 | m = leafmap.Map(center=[40, -100], zoom=2, height=600, widescreen=False) 12 | m 13 | ``` 14 | 15 | 16 | 17 | ## Add a CSV 18 | 19 | ```python 20 | m = leafmap.Map(center=[37.7621, -122.4143], zoom=12) 21 | in_csv = 'https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/hex_data.csv' 22 | config = 'https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/hex_config.json' 23 | m.add_csv(in_csv, layer_name="hex_data", config=config) 24 | m 25 | ``` 26 | 27 | 28 | 29 | ## Add a GeoJSON 30 | 31 | ```python 32 | m = leafmap.Map(center=[20, 0], zoom=1) 33 | lines = 'https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cable_geo.geojson' 34 | m.add_geojson(lines, layer_name="Cable lines") 35 | m 36 | ``` 37 | 38 | 39 | 40 | Add a GeoJSON with US state boundaries to the map. 41 | 42 | ```python 43 | m = leafmap.Map(center=[50, -110], zoom=2) 44 | polygons = 'https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_states.json' 45 | m.add_geojson(polygons, layer_name="Countries") 46 | m 47 | ``` 48 | 49 | 50 | 51 | ## Add a shapefile 52 | 53 | ```python 54 | m = leafmap.Map(center=[20, 0], zoom=1) 55 | in_shp = "https://github.com/opengeos/leafmap/raw/master/examples/data/countries.zip" 56 | m.add_shp(in_shp, "Countries") 57 | m 58 | ``` 59 | 60 | 61 | 62 | ## Add a GeoDataFrame 63 | 64 | ```python 65 | import geopandas as gpd 66 | gdf = gpd.read_file("https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.geojson") 67 | m = leafmap.Map(center=[20, 0], zoom=1) 68 | m.add_gdf(gdf, "World cities") 69 | m 70 | ``` 71 | 72 | 73 | -------------------------------------------------------------------------------- /docs/notebooks/100_nlcd.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/100_nlcd.ipynb)\n", 8 | "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/100_nlcd.ipynb)\n", 9 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 10 | "\n", 11 | "**Visualizing National Land Cover Database (NLCD) data products**" 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "metadata": {}, 17 | "source": [ 18 | "Uncomment the following line to install the `leafmap` package." 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "# %pip install -U leafmap" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": null, 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "import leafmap" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": null, 42 | "metadata": {}, 43 | "outputs": [], 44 | "source": [ 45 | "m = leafmap.Map(center=[40, -100], zoom=4)\n", 46 | "m.add_basemap(\"SATELLITE\")\n", 47 | "m.add_nlcd(years=[1985, 2023])\n", 48 | "m" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": null, 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "m = leafmap.Map(center=[40, -100], zoom=4)\n", 58 | "m.add_basemap(\"SATELLITE\")\n", 59 | "m.clear_controls()\n", 60 | "m.add_nlcd_ts(left_year=2000)\n", 61 | "m" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": null, 67 | "metadata": {}, 68 | "outputs": [], 69 | "source": [ 70 | "# leafmap.download_nlcd(years=[1985, 2023])" 71 | ] 72 | } 73 | ], 74 | "metadata": { 75 | "kernelspec": { 76 | "display_name": "geo", 77 | "language": "python", 78 | "name": "python3" 79 | }, 80 | "language_info": { 81 | "codemirror_mode": { 82 | "name": "ipython", 83 | "version": 3 84 | }, 85 | "file_extension": ".py", 86 | "mimetype": "text/x-python", 87 | "name": "python", 88 | "nbconvert_exporter": "python", 89 | "pygments_lexer": "ipython3", 90 | "version": "3.12.2" 91 | } 92 | }, 93 | "nbformat": 4, 94 | "nbformat_minor": 2 95 | } 96 | -------------------------------------------------------------------------------- /docs/notebooks/18_point_layer.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/18_point_layer.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "**Adding a point layer with popup attributes to the map**\n", 13 | "\n", 14 | "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", 15 | "\n", 16 | "\n", 17 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": null, 23 | "id": "1", 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "# !pip install leafmap" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": null, 33 | "id": "2", 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [ 37 | "from leafmap import leafmap" 38 | ] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "id": "3", 43 | "metadata": {}, 44 | "source": [ 45 | "Use the toolbar GUI to open a point-type vector dataset." 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": null, 51 | "id": "4", 52 | "metadata": {}, 53 | "outputs": [], 54 | "source": [ 55 | "m = leafmap.Map()\n", 56 | "m" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "id": "5", 62 | "metadata": {}, 63 | "source": [ 64 | "Display a single popup attribute." 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "execution_count": null, 70 | "id": "6", 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [ 74 | "m = leafmap.Map()\n", 75 | "m.add_point_layer(\"../data/us_cities.geojson\", popup=\"name\", layer_name=\"US Cities\")\n", 76 | "m" 77 | ] 78 | }, 79 | { 80 | "cell_type": "markdown", 81 | "id": "7", 82 | "metadata": {}, 83 | "source": [ 84 | "Display multiple popup attributes." 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": null, 90 | "id": "8", 91 | "metadata": {}, 92 | "outputs": [], 93 | "source": [ 94 | "m = leafmap.Map()\n", 95 | "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.geojson\"\n", 96 | "m.add_point_layer(url, popup=[\"name\", \"pop_max\"], layer_name=\"US Cities\")\n", 97 | "m" 98 | ] 99 | }, 100 | { 101 | "cell_type": "markdown", 102 | "id": "9", 103 | "metadata": {}, 104 | "source": [ 105 | "![](https://i.imgur.com/1QVEtlN.gif)" 106 | ] 107 | } 108 | ], 109 | "metadata": { 110 | "kernelspec": { 111 | "display_name": "Python 3", 112 | "language": "python", 113 | "name": "python3" 114 | } 115 | }, 116 | "nbformat": 4, 117 | "nbformat_minor": 5 118 | } 119 | -------------------------------------------------------------------------------- /docs/notebooks/19_map_to_html.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![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", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "**Saving maps as a html file**\n", 13 | "\n", 14 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": null, 20 | "id": "1", 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# !pip install leafmap" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "id": "2", 31 | "metadata": {}, 32 | "outputs": [], 33 | "source": [ 34 | "import leafmap.foliumap as leafmap" 35 | ] 36 | }, 37 | { 38 | "cell_type": "markdown", 39 | "id": "3", 40 | "metadata": {}, 41 | "source": [ 42 | "Create an interactive map." 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": null, 48 | "id": "4", 49 | "metadata": {}, 50 | "outputs": [], 51 | "source": [ 52 | "m = leafmap.Map()\n", 53 | "m.add_basemap(\"HYBRID\")\n", 54 | "m" 55 | ] 56 | }, 57 | { 58 | "cell_type": "markdown", 59 | "id": "5", 60 | "metadata": {}, 61 | "source": [ 62 | "Specify the output HTML file name to save the map as a web page." 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": null, 68 | "id": "6", 69 | "metadata": {}, 70 | "outputs": [], 71 | "source": [ 72 | "m.to_html(\"mymap.html\")" 73 | ] 74 | }, 75 | { 76 | "cell_type": "markdown", 77 | "id": "7", 78 | "metadata": {}, 79 | "source": [ 80 | "If the output HTML file name is not provided, the function will return a string containing contain the source code of the HTML file." 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": null, 86 | "id": "8", 87 | "metadata": {}, 88 | "outputs": [], 89 | "source": [ 90 | "html = m.to_html()" 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": null, 96 | "id": "9", 97 | "metadata": {}, 98 | "outputs": [], 99 | "source": [ 100 | "# print(html)" 101 | ] 102 | } 103 | ], 104 | "metadata": { 105 | "kernelspec": { 106 | "display_name": "Python 3", 107 | "language": "python", 108 | "name": "python3" 109 | } 110 | }, 111 | "nbformat": 4, 112 | "nbformat_minor": 5 113 | } 114 | -------------------------------------------------------------------------------- /docs/notebooks/27_basemap_gallery.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/27_basemap_gallery.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "1", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# !pip install leafmap" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "id": "2", 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import leafmap.leafmap as leafmap" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "id": "3", 38 | "metadata": {}, 39 | "source": [ 40 | "Select 100 basemaps" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "id": "4", 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "layers = list(leafmap.basemaps.keys())[17:117]\n", 51 | "# layers" 52 | ] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "id": "5", 57 | "metadata": {}, 58 | "source": [ 59 | "Print out the labels" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": null, 65 | "id": "6", 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [ 69 | "print(layers[:10])" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "id": "7", 75 | "metadata": {}, 76 | "source": [ 77 | "Create linked maps of 100 basemaps" 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "execution_count": null, 83 | "id": "8", 84 | "metadata": {}, 85 | "outputs": [], 86 | "source": [ 87 | "leafmap.linked_maps(rows=20, cols=5, height=\"200px\", layers=layers, labels=layers)" 88 | ] 89 | } 90 | ], 91 | "metadata": { 92 | "kernelspec": { 93 | "display_name": "Python 3", 94 | "language": "python", 95 | "name": "python3" 96 | } 97 | }, 98 | "nbformat": 4, 99 | "nbformat_minor": 5 100 | } 101 | -------------------------------------------------------------------------------- /docs/notebooks/34_add_points_from_xy.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![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", 9 | "\"Open\n", 10 | "\n", 11 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": null, 17 | "id": "1", 18 | "metadata": {}, 19 | "outputs": [], 20 | "source": [ 21 | "# !pip install leafmap" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "id": "2", 28 | "metadata": {}, 29 | "outputs": [], 30 | "source": [ 31 | "import leafmap\n", 32 | "import pandas as pd" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": null, 38 | "id": "3", 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "# leafmap.update_package()" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "id": "4", 48 | "metadata": {}, 49 | "source": [ 50 | "Using a CSV file containing xy coordinates" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "id": "5", 57 | "metadata": {}, 58 | "outputs": [], 59 | "source": [ 60 | "m = leafmap.Map()\n", 61 | "data = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.csv\"\n", 62 | "m.add_points_from_xy(data, x=\"longitude\", y=\"latitude\")\n", 63 | "m" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "id": "6", 69 | "metadata": {}, 70 | "source": [ 71 | "Using a Pandas DataFrame containing xy coordinates." 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": null, 77 | "id": "7", 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "m = leafmap.Map()\n", 82 | "data = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.csv\"\n", 83 | "df = pd.read_csv(data)\n", 84 | "m.add_points_from_xy(df, x=\"longitude\", y=\"latitude\")\n", 85 | "m" 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": null, 91 | "id": "8", 92 | "metadata": {}, 93 | "outputs": [], 94 | "source": [] 95 | } 96 | ], 97 | "metadata": { 98 | "kernelspec": { 99 | "display_name": "Python 3", 100 | "language": "python", 101 | "name": "python3" 102 | } 103 | }, 104 | "nbformat": 4, 105 | "nbformat_minor": 5 106 | } 107 | -------------------------------------------------------------------------------- /docs/notebooks/35_circle_markers.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/35_circle_markers.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "1", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# !pip install leafmap" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "id": "2", 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import leafmap" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "id": "3", 38 | "metadata": {}, 39 | "source": [ 40 | "For a list of options for circle markers, see https://ipyleaflet.readthedocs.io/en/latest/api_reference/circle_marker.html" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "id": "4", 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "m = leafmap.Map(center=[40, -100], zoom=4)\n", 51 | "data = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.csv\"\n", 52 | "m.add_circle_markers_from_xy(\n", 53 | " data, x=\"longitude\", y=\"latitude\", radius=10, color=\"blue\", fill_color=\"black\"\n", 54 | ")\n", 55 | "m" 56 | ] 57 | } 58 | ], 59 | "metadata": { 60 | "kernelspec": { 61 | "display_name": "Python 3", 62 | "language": "python", 63 | "name": "python3" 64 | } 65 | }, 66 | "nbformat": 4, 67 | "nbformat_minor": 5 68 | } 69 | -------------------------------------------------------------------------------- /docs/notebooks/40_plotly_gui.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/40_plotly_gui.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "1", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# !pip install leafmap" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "id": "2", 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import leafmap.plotlymap as leafmap" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "id": "3", 38 | "metadata": {}, 39 | "source": [ 40 | "**Note:** For best experience, please use Jupyter notebook. The toolbar GUI is not working very well with JupyterLab at the moment." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "id": "4", 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "m = leafmap.Map()" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "id": "5", 57 | "metadata": {}, 58 | "outputs": [], 59 | "source": [ 60 | "m.add_basemap(\"Esri.WorldTopoMap\")" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": null, 66 | "id": "6", 67 | "metadata": {}, 68 | "outputs": [], 69 | "source": [ 70 | "m.add_heatmap_demo()" 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": null, 76 | "id": "7", 77 | "metadata": {}, 78 | "outputs": [], 79 | "source": [ 80 | "m.add_scatter_plot_demo()" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": null, 86 | "id": "8", 87 | "metadata": {}, 88 | "outputs": [], 89 | "source": [ 90 | "m.show()" 91 | ] 92 | }, 93 | { 94 | "cell_type": "markdown", 95 | "id": "9", 96 | "metadata": {}, 97 | "source": [ 98 | "![](https://i.imgur.com/BJZbi9U.gif)" 99 | ] 100 | } 101 | ], 102 | "metadata": { 103 | "kernelspec": { 104 | "display_name": "Python 3", 105 | "language": "python", 106 | "name": "python3" 107 | } 108 | }, 109 | "nbformat": 4, 110 | "nbformat_minor": 5 111 | } 112 | -------------------------------------------------------------------------------- /docs/notebooks/41_raster_gui.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/41_raster_gui.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "1", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# !pip install leafmap" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "id": "2", 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import leafmap" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": null, 38 | "id": "3", 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "m = leafmap.Map()\n", 43 | "m" 44 | ] 45 | }, 46 | { 47 | "cell_type": "markdown", 48 | "id": "4", 49 | "metadata": {}, 50 | "source": [ 51 | "![](https://i.imgur.com/NGbqMwE.gif)" 52 | ] 53 | } 54 | ], 55 | "metadata": { 56 | "kernelspec": { 57 | "display_name": "Python 3", 58 | "language": "python", 59 | "name": "python3" 60 | } 61 | }, 62 | "nbformat": 4, 63 | "nbformat_minor": 5 64 | } 65 | -------------------------------------------------------------------------------- /docs/notebooks/43_search_control.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/43_search_control.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "1", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# !pip install leafmap" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "id": "2", 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import leafmap" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "id": "3", 38 | "metadata": {}, 39 | "source": [ 40 | "Add a search control to the map. See the [Nominatim Usage Policy](https://operations.osmfoundation.org/policies/nominatim)." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "id": "4", 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "m = leafmap.Map(draw_control=False)\n", 51 | "url = \"https://nominatim.openstreetmap.org/search?format=json&q={s}\"\n", 52 | "m.add_search_control(url)\n", 53 | "m" 54 | ] 55 | }, 56 | { 57 | "cell_type": "markdown", 58 | "id": "5", 59 | "metadata": {}, 60 | "source": [ 61 | "Search for features in GeoJSON files or any GeoPandas supported vector data." 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": null, 67 | "id": "6", 68 | "metadata": {}, 69 | "outputs": [], 70 | "source": [ 71 | "m = leafmap.Map(draw_control=False, layers_control=True)\n", 72 | "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n", 73 | "m.add_geojson(\n", 74 | " url,\n", 75 | " layer_name=\"Countries\",\n", 76 | " fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"],\n", 77 | " info_mode=None,\n", 78 | ")\n", 79 | "m" 80 | ] 81 | }, 82 | { 83 | "cell_type": "markdown", 84 | "id": "7", 85 | "metadata": {}, 86 | "source": [ 87 | "![](https://i.imgur.com/LP0BElT.gif)" 88 | ] 89 | } 90 | ], 91 | "metadata": { 92 | "kernelspec": { 93 | "display_name": "Python 3", 94 | "language": "python", 95 | "name": "python3" 96 | } 97 | }, 98 | "nbformat": 4, 99 | "nbformat_minor": 5 100 | } 101 | -------------------------------------------------------------------------------- /docs/notebooks/44_attribute_table.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/44_attribute_table.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "1", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# !pip install leafmap" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "id": "2", 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import leafmap" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "id": "3", 38 | "metadata": {}, 39 | "source": [ 40 | "Add vector data to the map and use the GUI to open attribute table." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "id": "4", 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "m = leafmap.Map()\n", 51 | "\n", 52 | "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/countries.geojson\"\n", 53 | "m.add_geojson(\n", 54 | " url,\n", 55 | " layer_name=\"Countries\",\n", 56 | " fill_colors=[\"red\", \"yellow\", \"green\", \"orange\"],\n", 57 | " info_mode=False,\n", 58 | ")\n", 59 | "\n", 60 | "in_geojson = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cable_geo.geojson\"\n", 61 | "m.add_geojson(in_geojson, layer_name=\"Cable lines\", info_mode=False)\n", 62 | "\n", 63 | "m" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "id": "5", 69 | "metadata": {}, 70 | "source": [ 71 | "![](https://i.imgur.com/IIoLVSG.gif)" 72 | ] 73 | } 74 | ], 75 | "metadata": { 76 | "kernelspec": { 77 | "display_name": "Python 3", 78 | "language": "python", 79 | "name": "python3" 80 | } 81 | }, 82 | "nbformat": 4, 83 | "nbformat_minor": 5 84 | } 85 | -------------------------------------------------------------------------------- /docs/notebooks/45_create_vector.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/45_create_vector.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "1", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# !pip install leafmap" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "id": "2", 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import leafmap" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "id": "3", 38 | "metadata": {}, 39 | "source": [ 40 | "Create an interactive map and use the drawing tool to draw shapes on the map." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "id": "4", 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "m = leafmap.Map()\n", 51 | "m" 52 | ] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "id": "5", 57 | "metadata": {}, 58 | "source": [ 59 | "Save the draw features as GeoJSON, Shapefile, or GeoPackage." 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": null, 65 | "id": "6", 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [ 69 | "m.save_draw_features(\"data.geojson\")" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "id": "7", 75 | "metadata": {}, 76 | "source": [ 77 | "![](https://i.imgur.com/b9RbEqb.gif)" 78 | ] 79 | } 80 | ], 81 | "metadata": { 82 | "kernelspec": { 83 | "display_name": "Python 3", 84 | "language": "python", 85 | "name": "python3" 86 | } 87 | }, 88 | "nbformat": 4, 89 | "nbformat_minor": 5 90 | } 91 | -------------------------------------------------------------------------------- /docs/notebooks/46_edit_vector.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/46_edit_vector.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "1", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# !pip install leafmap" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "id": "2", 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "from leafmap import leafmap" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "id": "3", 38 | "metadata": {}, 39 | "source": [ 40 | "Create an interactive map." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "id": "4", 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "m = leafmap.Map(center=(37.712615, -122.386665), zoom=12)\n", 51 | "m.add_basemap(\"HYBRID\")\n", 52 | "m" 53 | ] 54 | }, 55 | { 56 | "cell_type": "markdown", 57 | "id": "5", 58 | "metadata": {}, 59 | "source": [ 60 | "Add existing vector data to the map." 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": null, 66 | "id": "6", 67 | "metadata": {}, 68 | "outputs": [], 69 | "source": [ 70 | "url = \"https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/training_samples.geojson\"\n", 71 | "m.edit_vector(url)" 72 | ] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "id": "7", 77 | "metadata": {}, 78 | "source": [ 79 | "Edit the existing vector data using the drawing tools and save the resulting vector data as GeoJSON, Shapefile, or GeoPackage." 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "id": "8", 86 | "metadata": {}, 87 | "outputs": [], 88 | "source": [ 89 | "m.save_draw_features(\"data.geojson\")" 90 | ] 91 | } 92 | ], 93 | "metadata": { 94 | "kernelspec": { 95 | "display_name": "Python 3", 96 | "language": "python", 97 | "name": "python3" 98 | } 99 | }, 100 | "nbformat": 4, 101 | "nbformat_minor": 5 102 | } 103 | -------------------------------------------------------------------------------- /docs/notebooks/54_plot_raster.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/54_plot_raster.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "1", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# !pip install leafmap" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "id": "2", 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import os\n", 33 | "import leafmap" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "id": "3", 39 | "metadata": {}, 40 | "source": [ 41 | "Download a sample dataset." 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": null, 47 | "id": "4", 48 | "metadata": {}, 49 | "outputs": [], 50 | "source": [ 51 | "url = \"https://opengeos.org/data/raster/srtm90.tif\"" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": null, 57 | "id": "5", 58 | "metadata": {}, 59 | "outputs": [], 60 | "source": [ 61 | "image = \"srtm90.tif\"\n", 62 | "if not os.path.exists(image):\n", 63 | " leafmap.download_file(url, image)" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "id": "6", 69 | "metadata": {}, 70 | "source": [ 71 | "Plot the raster image in 2D." 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": null, 77 | "id": "7", 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "leafmap.plot_raster(image, cmap=\"terrain\", figsize=(15, 10))" 82 | ] 83 | }, 84 | { 85 | "cell_type": "markdown", 86 | "id": "8", 87 | "metadata": {}, 88 | "source": [ 89 | "![](https://i.imgur.com/oDoivba.png)" 90 | ] 91 | }, 92 | { 93 | "cell_type": "markdown", 94 | "id": "9", 95 | "metadata": {}, 96 | "source": [ 97 | "Plot the raster image in 3D." 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": null, 103 | "id": "10", 104 | "metadata": {}, 105 | "outputs": [], 106 | "source": [ 107 | "leafmap.plot_raster_3d(\"srtm90.tif\", factor=2, cmap=\"terrain\", background=\"gray\")" 108 | ] 109 | }, 110 | { 111 | "cell_type": "markdown", 112 | "id": "11", 113 | "metadata": {}, 114 | "source": [ 115 | "![](https://i.imgur.com/UQDbV2G.gif)" 116 | ] 117 | } 118 | ], 119 | "metadata": { 120 | "kernelspec": { 121 | "display_name": "Python 3", 122 | "language": "python", 123 | "name": "python3" 124 | } 125 | }, 126 | "nbformat": 4, 127 | "nbformat_minor": 5 128 | } 129 | -------------------------------------------------------------------------------- /docs/notebooks/63_arcgis.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/63_arcgis.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "1", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# !pip install -U leafmap" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "id": "2", 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import leafmap" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "id": "3", 38 | "metadata": {}, 39 | "source": [ 40 | "Add basemap." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "id": "4", 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "m = leafmap.Map()\n", 51 | "m.add_basemap(\"TERRAIN\")\n", 52 | "m" 53 | ] 54 | }, 55 | { 56 | "cell_type": "markdown", 57 | "id": "5", 58 | "metadata": {}, 59 | "source": [ 60 | "Add COG layer." 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": null, 66 | "id": "6", 67 | "metadata": {}, 68 | "outputs": [], 69 | "source": [ 70 | "url = \"https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif\"" 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": null, 76 | "id": "7", 77 | "metadata": {}, 78 | "outputs": [], 79 | "source": [ 80 | "m.add_cog_layer(url, name=\"COG\")" 81 | ] 82 | }, 83 | { 84 | "cell_type": "markdown", 85 | "id": "8", 86 | "metadata": {}, 87 | "source": [ 88 | "Add STAC layer." 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": null, 94 | "id": "9", 95 | "metadata": {}, 96 | "outputs": [], 97 | "source": [ 98 | "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\"" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": null, 104 | "id": "10", 105 | "metadata": {}, 106 | "outputs": [], 107 | "source": [ 108 | "m.add_stac_layer(url, bands=[\"B3\", \"B2\", \"B1\"], name=\"STAC\")" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "id": "11", 114 | "metadata": {}, 115 | "source": [ 116 | "![](https://i.imgur.com/GbVx3vV.png)" 117 | ] 118 | } 119 | ], 120 | "metadata": { 121 | "kernelspec": { 122 | "display_name": "Python 3", 123 | "language": "python", 124 | "name": "python3" 125 | } 126 | }, 127 | "nbformat": 4, 128 | "nbformat_minor": 5 129 | } 130 | -------------------------------------------------------------------------------- /docs/notebooks/76_image_comparison.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/76_image_comparison.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "**Comparing images with an interactive slider**\n", 13 | "\n", 14 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed.\n", 15 | "\n", 16 | "Note that the `image_comparison` will only work with Jupyter Notebook or JupyterLab. It seems not working with Visual Studio Code." 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": null, 22 | "id": "1", 23 | "metadata": {}, 24 | "outputs": [], 25 | "source": [ 26 | "# %pip install -U leafmap" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": null, 32 | "id": "2", 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "import leafmap" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": null, 42 | "id": "3", 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "img1 = \"https://opengeos.org/data/images/berkeley.jpg\"\n", 47 | "img2 = \"https://opengeos.org/data/images/berkeley_sam.jpg\"" 48 | ] 49 | }, 50 | { 51 | "cell_type": "markdown", 52 | "id": "4", 53 | "metadata": {}, 54 | "source": [ 55 | "The labels might not show up the first time. Try running the code block again to show the labels." 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": null, 61 | "id": "5", 62 | "metadata": {}, 63 | "outputs": [], 64 | "source": [ 65 | "leafmap.image_comparison(\n", 66 | " img1,\n", 67 | " img2,\n", 68 | " label1=\"Satellite Image\",\n", 69 | " label2=\"Image Segmentation\",\n", 70 | " starting_position=50,\n", 71 | " out_html=\"image_comparison.html\",\n", 72 | ")" 73 | ] 74 | }, 75 | { 76 | "cell_type": "markdown", 77 | "id": "6", 78 | "metadata": {}, 79 | "source": [ 80 | "![](https://i.imgur.com/Ega3y5d.gif)" 81 | ] 82 | } 83 | ], 84 | "metadata": { 85 | "kernelspec": { 86 | "display_name": "Python 3", 87 | "language": "python", 88 | "name": "python3" 89 | } 90 | }, 91 | "nbformat": 4, 92 | "nbformat_minor": 5 93 | } 94 | -------------------------------------------------------------------------------- /docs/notebooks/77_split_raster.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/77_split_raster.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "1", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# %pip install -U leafmap" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "id": "2", 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import leafmap" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "id": "3", 38 | "metadata": {}, 39 | "source": [ 40 | "Create an interactive map and add a raster layer to it." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "id": "4", 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "m = leafmap.Map()\n", 51 | "url = \"https://opengeos.org/data/raster/cog.tif\"\n", 52 | "m.add_cog_layer(url, name=\"COG\")\n", 53 | "m" 54 | ] 55 | }, 56 | { 57 | "cell_type": "markdown", 58 | "id": "5", 59 | "metadata": {}, 60 | "source": [ 61 | "Split the raster layer into multiple tiles." 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": null, 67 | "id": "6", 68 | "metadata": {}, 69 | "outputs": [], 70 | "source": [ 71 | "leafmap.split_raster(url, out_dir=\"tiles\", tile_size=(100, 100), overlap=0)" 72 | ] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "id": "7", 77 | "metadata": {}, 78 | "source": [ 79 | "Show the tiles." 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "id": "8", 86 | "metadata": {}, 87 | "outputs": [], 88 | "source": [ 89 | "leafmap.find_files(\"tiles\", ext=\".tif\")" 90 | ] 91 | }, 92 | { 93 | "cell_type": "markdown", 94 | "id": "9", 95 | "metadata": {}, 96 | "source": [ 97 | "Merge the tiles into a single raster dataset." 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": null, 103 | "id": "10", 104 | "metadata": {}, 105 | "outputs": [], 106 | "source": [ 107 | "leafmap.merge_rasters(\"tiles\", output=\"merged.tif\", input_pattern=\"*.tif\")" 108 | ] 109 | } 110 | ], 111 | "metadata": { 112 | "kernelspec": { 113 | "display_name": "Python 3", 114 | "language": "python", 115 | "name": "python3" 116 | } 117 | }, 118 | "nbformat": 4, 119 | "nbformat_minor": 5 120 | } 121 | -------------------------------------------------------------------------------- /docs/notebooks/79_timeseries.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/79_timeseries.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "**Visualizing time series images interactively with a time slider**\n", 13 | "\n", 14 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": null, 20 | "id": "1", 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# %pip install -U leafmap" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "id": "2", 31 | "metadata": {}, 32 | "outputs": [], 33 | "source": [ 34 | "from leafmap import leafmap" 35 | ] 36 | }, 37 | { 38 | "cell_type": "markdown", 39 | "id": "3", 40 | "metadata": {}, 41 | "source": [ 42 | "Download sample data [here](https://opengeos.org/data/landsat/timeseries.zip)." 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": null, 48 | "id": "4", 49 | "metadata": {}, 50 | "outputs": [], 51 | "source": [ 52 | "url = \"https://opengeos.org/data/landsat/timeseries.zip\"\n", 53 | "leafmap.download_file(url)" 54 | ] 55 | }, 56 | { 57 | "cell_type": "markdown", 58 | "id": "5", 59 | "metadata": {}, 60 | "source": [ 61 | "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." 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": null, 67 | "id": "6", 68 | "metadata": {}, 69 | "outputs": [], 70 | "source": [ 71 | "m = leafmap.Map()\n", 72 | "images = \"landsat\"\n", 73 | "m.add_time_slider(\n", 74 | " images,\n", 75 | " time_interval=0.5,\n", 76 | " position=\"bottomright\",\n", 77 | " band=[1, 2, 3],\n", 78 | " zoom_to_layer=True,\n", 79 | ")\n", 80 | "m" 81 | ] 82 | }, 83 | { 84 | "cell_type": "markdown", 85 | "id": "7", 86 | "metadata": {}, 87 | "source": [ 88 | "![](https://i.imgur.com/mufTpVD.gif)" 89 | ] 90 | } 91 | ], 92 | "metadata": { 93 | "kernelspec": { 94 | "display_name": "Python 3", 95 | "language": "python", 96 | "name": "python3" 97 | } 98 | }, 99 | "nbformat": 4, 100 | "nbformat_minor": 5 101 | } 102 | -------------------------------------------------------------------------------- /docs/notebooks/zz_notebook_template.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "0", 6 | "metadata": {}, 7 | "source": [ 8 | "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/zz_notebook_template.ipynb)\n", 9 | "[![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", 10 | "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n", 11 | "\n", 12 | "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "1", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# %pip install -U leafmap" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "id": "2", 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import leafmap" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "id": "3", 38 | "metadata": {}, 39 | "source": [ 40 | "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." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "id": "4", 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "# leafmap.update_package()" 51 | ] 52 | }, 53 | { 54 | "cell_type": "markdown", 55 | "id": "5", 56 | "metadata": {}, 57 | "source": [ 58 | "Create an interactive map." 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": null, 64 | "id": "6", 65 | "metadata": {}, 66 | "outputs": [], 67 | "source": [ 68 | "m = leafmap.Map()\n", 69 | "m" 70 | ] 71 | } 72 | ], 73 | "metadata": { 74 | "kernelspec": { 75 | "display_name": "Python 3", 76 | "language": "python", 77 | "name": "python3" 78 | } 79 | }, 80 | "nbformat": 4, 81 | "nbformat_minor": 5 82 | } 83 | -------------------------------------------------------------------------------- /docs/osm.md: -------------------------------------------------------------------------------- 1 | # osm module 2 | 3 | ::: leafmap.osm 4 | -------------------------------------------------------------------------------- /docs/overrides/main.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 | {% if page.nb_url %} 5 | 6 | {% include ".icons/material/download.svg" %} 7 | 8 | {% endif %} 9 | 10 | {{ super() }} 11 | {% endblock content %} 12 | -------------------------------------------------------------------------------- /docs/pc.md: -------------------------------------------------------------------------------- 1 | # pc module 2 | 3 | ::: leafmap.pc 4 | -------------------------------------------------------------------------------- /docs/plot.md: -------------------------------------------------------------------------------- 1 | # plot module 2 | 3 | ::: leafmap.plot 4 | -------------------------------------------------------------------------------- /docs/plotlymap.md: -------------------------------------------------------------------------------- 1 | # plotlymap module 2 | 3 | ::: leafmap.plotlymap 4 | -------------------------------------------------------------------------------- /docs/search_bk.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Search 5 | 6 | 7 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /docs/search_docs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Search 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/stac.md: -------------------------------------------------------------------------------- 1 | # stac module 2 | 3 | ::: leafmap.stac 4 | -------------------------------------------------------------------------------- /docs/toolbar.md: -------------------------------------------------------------------------------- 1 | # toolbar module 2 | 3 | ::: leafmap.toolbar 4 | -------------------------------------------------------------------------------- /docs/usage.md: -------------------------------------------------------------------------------- 1 | # Usage 2 | 3 | You can try out leafmap by using Goolge Colab ([![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master)) or Binder ([![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)) without having to install anything on your computer. 4 | 5 | ## Launch Jupyter notebook 6 | 7 | ```bash 8 | conda activate geo 9 | jupyter notebook 10 | ``` 11 | 12 | ## Use ipyleaflet plotting backend 13 | 14 | ```python 15 | import leafmap 16 | ``` 17 | 18 | ## Use folium plotting backend 19 | 20 | ```python 21 | import leafmap.foliumap as leafmap 22 | ``` 23 | 24 | ## Create an interactive map 25 | 26 | ```python 27 | m = leafmap.Map(center=(40, -100), zoom=4) 28 | m 29 | ``` 30 | 31 | ## Customize map height 32 | 33 | ```python 34 | m = leafmap.Map(height="450px") 35 | m 36 | ``` 37 | 38 | ## Set control visibility 39 | 40 | ```python 41 | m = leafmap.Map(draw_control=False, measure_control=False, fullscreen_control=False, attribution_control=True) 42 | m 43 | ``` 44 | 45 | ## Change basemaps 46 | 47 | ```python 48 | m = leafmap.Map(google_map="TERRAIN") 49 | m.add_basemap("HYBRID") 50 | m 51 | ``` 52 | 53 | ## Add XYZ tile layer 54 | 55 | ```python 56 | m = leafmap.Map() 57 | m.add_tile_layer(url="https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}", name="Google Satellite", attribution="Google") 58 | m 59 | ``` 60 | 61 | ## Add WMS tile layer 62 | 63 | ```python 64 | m = leafmap.Map() 65 | naip_url = 'https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?' 66 | m.add_wms_layer(url=naip_url, layers='0', name='NAIP Imagery', format='image/png', shown=True) 67 | m 68 | ``` 69 | 70 | ## Use HERE Map Widget for Jupyter plotting backend 71 | 72 | ### Prerequisites 73 | 74 | - A HERE developer account, free and available under [HERE Developer Portal](https://developer.here.com) 75 | - 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) 76 | - Export API key into environment variable `HEREMAPS_API_KEY` 77 | 78 | ```bash 79 | export HEREMAPS_API_KEY=YOUR-ACTUAL-API-KEY 80 | ``` 81 | 82 | ```python 83 | import leafmap.heremap as leafmap 84 | ``` 85 | 86 | ### Create an interactive map 87 | 88 | ```python 89 | import os 90 | api_key = os.environ.get("HEREMAPS_API_KEY") # read api_key from environment variable. 91 | m = leafmap.Map(api_key=api_key, center=(40, -100), zoom=4) 92 | m 93 | ``` 94 | -------------------------------------------------------------------------------- /environment.yml: -------------------------------------------------------------------------------- 1 | name: geo-env 2 | channels: 3 | - conda-forge 4 | dependencies: 5 | - bokeh 6 | - cartopy 7 | - datapane 8 | - flask>=2.0.0 9 | - flask-caching 10 | - gdal 11 | - geemap>=0.11.1 12 | - geopandas 13 | - h5netcdf 14 | - h5py 15 | - imageio 16 | - ipyvtklink 17 | - jupyter_bokeh 18 | - keplergl 19 | - laspy 20 | - leafmap>=0.11.3 21 | - localtileserver>=0.10.0 22 | - opera-utils 23 | - osmnx 24 | - pip 25 | - pydeck 26 | - pyntcloud 27 | - python>=3.9 28 | - pyvista 29 | - requests 30 | - rioxarray 31 | - rio-cogeo 32 | - tifffile 33 | - xarray_leaflet 34 | # - pip: 35 | # - git+https://github.com/opengeos/leafmap 36 | # - git+https://github.com/opengeos/geemap 37 | -------------------------------------------------------------------------------- /examples/check_colab.py: -------------------------------------------------------------------------------- 1 | import glob 2 | import os 3 | import shutil 4 | 5 | in_dir = os.path.dirname(os.path.abspath(__file__)) 6 | print(in_dir) 7 | notebook_dir = os.path.abspath(os.path.join(in_dir, "notebooks")) 8 | workshop_dir = os.path.abspath(os.path.join(in_dir, "workshops")) 9 | 10 | os.chdir(notebook_dir) 11 | cmd = "jupytext --to myst *.ipynb" 12 | os.system(cmd) 13 | 14 | os.chdir(workshop_dir) 15 | cmd = "jupytext --to myst *.ipynb" 16 | os.system(cmd) 17 | 18 | os.chdir(in_dir) 19 | 20 | 21 | notebooks = glob.glob(in_dir + "/notebooks/*.md") 22 | workshops = glob.glob(in_dir + "/workshops/*.md") 23 | 24 | files = notebooks + workshops 25 | 26 | for file in files: 27 | with open(file, "r") as f: 28 | lines = f.readlines() 29 | 30 | has_colab = False 31 | for line in lines: 32 | if "colab-badge.svg" in line: 33 | has_colab = True 34 | break 35 | if not has_colab: 36 | print(f"No Colab badge found in {file}") 37 | -------------------------------------------------------------------------------- /examples/data/README.md: -------------------------------------------------------------------------------- 1 | ## Data Sources 2 | 3 | Some datasets contained in the repository were downloaded from various sources. Credits to the original owners of the datasets. 4 | 5 | The following datasets are downloaded from https://github.com/keplergl/kepler.gl/tree/master/bindings/kepler.gl-jupyter/notebooks 6 | 7 | - hex_data.csv 8 | - hex_config.json 9 | - sf_zip_geo.json 10 | -------------------------------------------------------------------------------- /examples/data/cog.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/cog.tif -------------------------------------------------------------------------------- /examples/data/countries.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /examples/data/countries.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/countries.dbf -------------------------------------------------------------------------------- /examples/data/countries.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/countries.gpkg -------------------------------------------------------------------------------- /examples/data/countries.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] -------------------------------------------------------------------------------- /examples/data/countries.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/countries.shp -------------------------------------------------------------------------------- /examples/data/countries.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/countries.shx -------------------------------------------------------------------------------- /examples/data/countries.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/countries.zip -------------------------------------------------------------------------------- /examples/data/mask.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { 5 | "type": "Feature", 6 | "properties": {}, 7 | "geometry": { 8 | "type": "Polygon", 9 | "coordinates": [ 10 | [ 11 | [ 12 | -119.679565, 13 | 37.256566 14 | ], 15 | [ 16 | -119.679565, 17 | 38.061067 18 | ], 19 | [ 20 | -118.24585, 21 | 38.061067 22 | ], 23 | [ 24 | -118.24585, 25 | 37.256566 26 | ], 27 | [ 28 | -119.679565, 29 | 37.256566 30 | ] 31 | ] 32 | ] 33 | } 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /examples/data/states.csv: -------------------------------------------------------------------------------- 1 | system:index,id,name 2 | 0,AL,Alabama 3 | 1,AK,Alaska 4 | 2,AZ,Arizona 5 | 3,AR,Arkansas 6 | 4,CA,California 7 | 5,CO,Colorado 8 | 6,CT,Connecticut 9 | 7,DE,Delaware 10 | 8,FL,Florida 11 | 9,GA,Georgia 12 | 10,HI,Hawaii 13 | 11,ID,Idaho 14 | 12,IL,Illinois 15 | 13,IN,Indiana 16 | 14,IA,Iowa 17 | 15,KS,Kansas 18 | 16,KY,Kentucky 19 | 17,LA,Louisiana 20 | 18,ME,Maine 21 | 19,MD,Maryland 22 | 20,MA,Massachusetts 23 | 21,MI,Michigan 24 | 22,MN,Minnesota 25 | 23,MS,Mississippi 26 | 24,MO,Missouri 27 | 25,MT,Montana 28 | 26,NE,Nebraska 29 | 27,NV,Nevada 30 | 28,NH,New Hampshire 31 | 29,NJ,New Jersey 32 | 30,NM,New Mexico 33 | 31,NY,New York 34 | 32,NC,North Carolina 35 | 33,ND,North Dakota 36 | 34,OH,Ohio 37 | 35,OK,Oklahoma 38 | 36,OR,Oregon 39 | 37,PA,Pennsylvania 40 | 38,RI,Rhode Island 41 | 39,SC,South Carolina 42 | 40,SD,South Dakota 43 | 41,TN,Tennessee 44 | 42,TX,Texas 45 | 43,UT,Utah 46 | 44,VT,Vermont 47 | 45,VA,Virginia 48 | 46,WA,Washington 49 | 47,WV,West Virginia 50 | 48,WI,Wisconsin 51 | 49,WY,Wyoming 52 | -------------------------------------------------------------------------------- /examples/data/states.kmz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/states.kmz -------------------------------------------------------------------------------- /examples/data/us_cities.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /examples/data/us_cities.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/us_cities.dbf -------------------------------------------------------------------------------- /examples/data/us_cities.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] -------------------------------------------------------------------------------- /examples/data/us_cities.qmd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | dataset 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 0 17 | 0 18 | 19 | 20 | 21 | 22 | false 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/data/us_cities.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/us_cities.shp -------------------------------------------------------------------------------- /examples/data/us_cities.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/us_cities.shx -------------------------------------------------------------------------------- /examples/data/us_states.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /examples/data/us_states.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/us_states.dbf -------------------------------------------------------------------------------- /examples/data/us_states.kmz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/us_states.kmz -------------------------------------------------------------------------------- /examples/data/us_states.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /examples/data/us_states.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/us_states.shp -------------------------------------------------------------------------------- /examples/data/us_states.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/us_states.shx -------------------------------------------------------------------------------- /examples/data/world_cities.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /examples/data/world_cities.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/world_cities.dbf -------------------------------------------------------------------------------- /examples/data/world_cities.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] -------------------------------------------------------------------------------- /examples/data/world_cities.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/world_cities.shp -------------------------------------------------------------------------------- /examples/data/world_cities.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/examples/data/world_cities.shx -------------------------------------------------------------------------------- /leafmap/data/fonts/arial.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/leafmap/data/fonts/arial.ttf -------------------------------------------------------------------------------- /leafmap/data/template/legend.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
Legend
5 |
6 |
    7 |
  • One
  • 8 |
  • Two
  • 9 |
  • Three
  • 10 |
  • Four
  • 11 |
  • etc
  • 12 |
13 |
14 |
15 | 16 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /leafmap/data/template/legend.txt: -------------------------------------------------------------------------------- 1 | """ 2 | {% macro html(this, kwargs) %} 3 | 4 | 5 | 6 | 7 | 8 | 9 | jQuery UI Draggable - Default functionality 10 | 11 | 12 | 13 | 14 | 15 | 29 | 30 | 31 | 32 | 33 |
36 | 37 |
Legend
38 |
39 |
    40 |
  • Big
  • 41 |
  • Medium
  • 42 |
  • Small
  • 43 |
44 |
45 |
46 | 47 | 48 | 49 | 50 | 89 | {% endmacro %}""" 90 | -------------------------------------------------------------------------------- /leafmap/data/template/legend_style.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
20 |
Legend
21 |
22 |
    23 |
  • 24 | Big 25 |
  • 26 |
  • 27 | Medium 29 |
  • 30 |
  • 31 | Small 33 |
  • 34 |
35 |
36 |
37 | 38 | 39 | 40 | 79 | -------------------------------------------------------------------------------- /leafmap/examples/__init__.py: -------------------------------------------------------------------------------- 1 | import box 2 | import os 3 | import importlib.resources 4 | 5 | _pkg_dir = os.path.dirname(importlib.resources.files("leafmap") / "leafmap.py") 6 | _datasets_path = os.path.join(_pkg_dir, "examples/datasets.txt") 7 | _baseurl = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/" 8 | 9 | with open(_datasets_path) as f: 10 | _names = [line.strip() for line in f.readlines()] 11 | 12 | _links = [f"{_baseurl}{_name}" for _name in _names] 13 | datasets = box.Box(dict(zip(_names, _links)), frozen_box=True) 14 | 15 | 16 | def get_path(name): 17 | """Get the HTTP URL to an example dataset. 18 | 19 | Args: 20 | name (str): The name of the dataset. 21 | 22 | Raises: 23 | ValueError: If the dataset name is not found. 24 | 25 | Returns: 26 | str: The HTTP URL to the dataset. 27 | """ 28 | if name in datasets: 29 | return datasets[name] 30 | else: 31 | raise ValueError( 32 | f"{name} not found in example datasets. It must be one of {list(datasets.keys())}" 33 | ) 34 | 35 | 36 | def get_names(): 37 | """Get a list of names of the example datasets. 38 | 39 | Returns: 40 | list: A list of names of the example datasets. 41 | """ 42 | 43 | return list(datasets.keys()) 44 | 45 | 46 | def get_links(): 47 | """Get a list of HTTP URLs to the example datasets. 48 | 49 | Returns: 50 | list: A list of HTTP URLs to the example datasets. 51 | """ 52 | 53 | return list(datasets.values()) 54 | -------------------------------------------------------------------------------- /leafmap/examples/datasets.txt: -------------------------------------------------------------------------------- 1 | cable_geo.geojson 2 | cog_files.txt 3 | cog_post_event.txt 4 | cog_pre_event.txt 5 | cog.tif 6 | countries.cpg 7 | countries.dbf 8 | countries.geojson 9 | countries.prj 10 | countries.shp 11 | countries.shx 12 | countries.zip 13 | datasets.txt 14 | hex_config.json 15 | hex_data.csv 16 | mask.geojson 17 | README.md 18 | sf_zip_geo.json 19 | states.csv 20 | training_samples.geojson 21 | us_cities.cpg 22 | us_cities.csv 23 | us_cities.dbf 24 | us_cities.geojson 25 | us_cities.prj 26 | us_cities.qmd 27 | us_cities.shp 28 | us_cities.shx 29 | us_regions.geojson 30 | us_states.cpg 31 | us_states.dbf 32 | us_states.json 33 | us_states.kml 34 | us_states.kmz 35 | us_states.prj 36 | us_states.shp 37 | us_states.shx 38 | wind_global.nc 39 | world_cities.cpg 40 | world_cities.csv 41 | world_cities.dbf 42 | world_cities.geojson 43 | world_cities.prj 44 | world_cities.shp 45 | world_cities.shx -------------------------------------------------------------------------------- /leafmap/javascript/mapbox.js: -------------------------------------------------------------------------------- 1 | import mapboxgl from "https://esm.sh/mapbox-gl@3.5.2"; 2 | 3 | function render({ model, el }) { 4 | // Header 5 | let center = model.get("center"); 6 | let zoom = model.get("zoom"); 7 | let width = model.get("width"); 8 | let height = model.get("height"); 9 | let style = model.get("style"); 10 | 11 | const div = document.createElement("div"); 12 | div.style.width = width; 13 | div.style.height = height; 14 | 15 | let token = model.get("token"); 16 | mapboxgl.accessToken = token; 17 | 18 | // Map content 19 | 20 | const map = new mapboxgl.Map({ 21 | container: div, 22 | style: style, 23 | center: center, 24 | zoom: zoom, 25 | }); 26 | 27 | map.on("click", function (e) { 28 | model.set("clicked_lnglat", [e.lngLat.lng, e.lngLat.lat]); 29 | model.save_changes(); 30 | }); 31 | 32 | map.on("moveend", function (e) { 33 | model.set("center", [map.getCenter().lng, map.getCenter().lat]); 34 | let bbox = map.getBounds(); 35 | let bounds = [bbox._sw.lng, bbox._sw.lat, bbox._ne.lng, bbox._ne.lat]; 36 | model.set("bounds", bounds); 37 | model.save_changes(); 38 | }); 39 | 40 | map.on("zoomend", function (e) { 41 | model.set("center", [map.getCenter().lng, map.getCenter().lat]); 42 | model.set("zoom", map.getZoom()); 43 | let bbox = map.getBounds(); 44 | let bounds = [bbox._sw.lng, bbox._sw.lat, bbox._ne.lng, bbox._ne.lat]; 45 | model.set("bounds", bounds); 46 | model.save_changes(); 47 | }); 48 | 49 | // model.on("change:center", function () { 50 | // let center = model.get("center"); 51 | // center.reverse(); 52 | // map.setCenter(center); 53 | // }); 54 | 55 | // model.on("change:zoom", function () { 56 | // let zoom = model.get("zoom"); 57 | // map.setZoom(zoom); 58 | // }); 59 | 60 | // Footer 61 | el.appendChild(div); 62 | } 63 | export default { render }; -------------------------------------------------------------------------------- /leafmap/report.py: -------------------------------------------------------------------------------- 1 | import scooby 2 | 3 | 4 | class Report(scooby.Report): 5 | def __init__(self, additional=None, ncol=3, text_width=80, sort=False): 6 | """Initiate a scooby.Report instance.""" 7 | core = [ 8 | "leafmap", 9 | "ipyleaflet", 10 | "folium", 11 | "jupyterlab", 12 | "notebook", 13 | "ipyevents", 14 | "matplotlib", 15 | ] 16 | optional = ["geopandas", "localtileserver"] 17 | 18 | scooby.Report.__init__( 19 | self, 20 | additional=additional, 21 | core=core, 22 | optional=optional, 23 | ncol=ncol, 24 | text_width=text_width, 25 | sort=sort, 26 | ) 27 | -------------------------------------------------------------------------------- /leafmap/styles/mapbox.css: -------------------------------------------------------------------------------- 1 | @import url("https://api.mapbox.com/mapbox-gl-js/v3.5.2/mapbox-gl.css"); 2 | -------------------------------------------------------------------------------- /paper/SIGSPATIAL_Workshop.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opengeos/leafmap/44108f71258407d3e1f235c06680b057549fa1e1/paper/SIGSPATIAL_Workshop.pdf -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=64", "setuptools_scm>=8"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "leafmap" 7 | version = "0.48.3" 8 | dynamic = [ 9 | "dependencies", 10 | ] 11 | description = "A Python package for geospatial analysis and interactive mapping in a Jupyter environment." 12 | readme = "README.md" 13 | requires-python = ">=3.9" 14 | license = {text = "MIT license"} 15 | keywords = ["leafmap"] 16 | classifiers = [ 17 | "Development Status :: 2 - Pre-Alpha", 18 | "Intended Audience :: Developers", 19 | "License :: OSI Approved :: MIT License", 20 | "Natural Language :: English", 21 | "Programming Language :: Python :: 3", 22 | "Programming Language :: Python :: 3.9", 23 | "Programming Language :: Python :: 3.10", 24 | "Programming Language :: Python :: 3.11", 25 | "Programming Language :: Python :: 3.12", 26 | "Programming Language :: Python :: 3.13", 27 | ] 28 | authors = [{name = "Qiusheng Wu", email = "giswqs@gmail.com"}] 29 | 30 | [project.optional-dependencies] 31 | backends = ["bokeh", "keplergl", "maplibre", "pydeck", "plotly"] 32 | lidar = ["geopandas","ipygany", "ipyvtklink", "laspy", "panel", "pyntcloud[LAS]", "pyvista[all]"] 33 | raster = ["localtileserver>=0.10.6", "jupyter-server-proxy", "rio-cogeo", "rioxarray", "netcdf4", "d2spy", "h5netcdf", "h5py", "opera-utils", "rioxarray", "psutil"] 34 | usgs = ["pynhd", "py3dep"] 35 | sql = ["psycopg2", "sqlalchemy"] 36 | apps = ["streamlit-folium", "voila", "solara"] 37 | vector = ["geopandas", "osmnx", "pmtiles", "flask", "flask-cors", "lonboard", "mapclassify"] 38 | pmtiles = ["pmtiles", "flask", "flask-cors"] 39 | ai = ["geopandas", "osmnx", "localtileserver>=0.10.4", "rastervision", "pytorch-lightning", "torchgeo"] 40 | maplibre = ["anywidget", "geopandas", "fiona", "h3", "ipyvuetify", "localtileserver", "mapclassify", "maplibre>=0.3.1", "pmtiles", "rioxarray", "xarray"] 41 | gdal = ["gdal", "pyproj"] 42 | 43 | [tool] 44 | [tool.setuptools.packages.find] 45 | include = ["leafmap*"] 46 | exclude = ["docs*"] 47 | 48 | 49 | [tool.setuptools.dynamic] 50 | dependencies = {file = ["requirements.txt"]} 51 | 52 | [tool.distutils.bdist_wheel] 53 | universal = true 54 | 55 | [tool.bumpversion] 56 | current_version = "0.48.3" 57 | commit = true 58 | tag = true 59 | 60 | [[tool.bumpversion.files]] 61 | filename = "pyproject.toml" 62 | search = 'version = "{current_version}"' 63 | replace = 'version = "{new_version}"' 64 | 65 | [[tool.bumpversion.files]] 66 | filename = "leafmap/__init__.py" 67 | search = '__version__ = "{current_version}"' 68 | replace = '__version__ = "{new_version}"' 69 | 70 | [tool.flake8] 71 | exclude = [ 72 | "docs", 73 | ] 74 | max-line-length = 88 75 | 76 | [tool.setuptools_scm] 77 | 78 | [tool.uv] 79 | find-links = ["https://girder.github.io/large_image_wheels"] 80 | 81 | [project.urls] 82 | Homepage = "https://github.com/opengeos/leafmap" -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | anywidget 2 | bqplot 3 | duckdb 4 | folium 5 | gdown 6 | geojson 7 | geopandas 8 | ipyevents 9 | ipyfilechooser 10 | ipyleaflet 11 | ipyvuetify 12 | ipywidgets 13 | maplibre 14 | matplotlib 15 | numpy 16 | pandas 17 | plotly 18 | pystac-client 19 | python-box 20 | scooby 21 | whiteboxgui 22 | xyzservices 23 | -------------------------------------------------------------------------------- /requirements_dev.txt: -------------------------------------------------------------------------------- 1 | bokeh 2 | boto3 3 | cogeo-mosaic 4 | d2spy 5 | earthaccess 6 | ffmpeg-python 7 | fiona 8 | geopandas>=1.0.0 9 | gradio 10 | h3 11 | h5netcdf 12 | h5py 13 | # ipysheet 14 | # jupyter_bokeh 15 | keplergl 16 | laspy 17 | localtileserver>=0.10.6 18 | lonboard 19 | mapclassify>=2.4.0 20 | mss 21 | netcdf4 22 | opera-utils 23 | osmnx 24 | overturemaps 25 | owslib 26 | palettable 27 | pmtiles 28 | psutil 29 | # psycopg2 30 | pycrs 31 | pydeck 32 | pyntcloud[LAS] 33 | pyvista-xarray 34 | rasterio 35 | rasterstats 36 | rio-cogeo 37 | rioxarray 38 | # sqlalchemy 39 | # streamlit-folium 40 | -------------------------------------------------------------------------------- /requirements_docs.txt: -------------------------------------------------------------------------------- 1 | black 2 | black[jupyter] 3 | bump2version 4 | coverage 5 | flake8 6 | grip 7 | ipykernel 8 | livereload 9 | mkdocs 10 | mkdocs-git-revision-date-localized-plugin 11 | mkdocs-git-revision-date-plugin 12 | mkdocs-jupyter>=0.24.0 13 | mkdocs-material>=9.1.3 14 | mkdocs-pdf-export-plugin 15 | mkdocstrings 16 | mkdocstrings-crystal 17 | mkdocstrings-python 18 | nbconvert 19 | nbformat 20 | pip 21 | pre-commit 22 | pygments 23 | pymdown-extensions 24 | PyYAML 25 | sphinx 26 | tox 27 | twine 28 | watchdog 29 | wheel 30 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | """Unit test package for leafmap.""" 2 | -------------------------------------------------------------------------------- /tests/test_osm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Tests for `leafmap` package.""" 4 | 5 | import os 6 | import unittest 7 | import geopandas 8 | from leafmap.osm import * 9 | 10 | 11 | class TestOsm(unittest.TestCase): 12 | """Tests for `common` module.""" 13 | 14 | def setUp(self): 15 | """Set up test fixtures, if any.""" 16 | 17 | def tearDown(self): 18 | """Tear down test fixtures, if any.""" 19 | 20 | # def test_osm_gdf_from_geocode(self): 21 | 22 | # self.assertIsInstance( 23 | # osm_gdf_from_geocode("New York City"), geopandas.GeoDataFrame 24 | # ) 25 | 26 | # def test_osm_gdf_from_place(self): 27 | 28 | # place = "Bunker Hill, Los Angeles, California" 29 | # tags = {"building": True} 30 | # self.assertIsInstance(osm_gdf_from_place(place, tags), geopandas.GeoDataFrame) 31 | 32 | # def test_osm_gdf_from_address(self): 33 | 34 | # address = "New York City" 35 | # tags = {"amenity": "bar"} 36 | # dist = 1500 37 | # self.assertIsInstance( 38 | # osm_gdf_from_address(address, tags, dist), geopandas.GeoDataFrame 39 | # ) 40 | 41 | # def test_osm_gdf_from_point(self): 42 | 43 | # self.assertIsInstance( 44 | # osm_gdf_from_point( 45 | # center_point=(46.7808, -96.0156), 46 | # tags={"natural": "water"}, 47 | # dist=10000, 48 | # ), 49 | # geopandas.GeoDataFrame, 50 | # ) 51 | 52 | 53 | if __name__ == "__main__": 54 | unittest.main() 55 | -------------------------------------------------------------------------------- /tests/test_toolbar.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Tests for `toolbar` module.""" 4 | 5 | import unittest 6 | from leafmap import leafmap 7 | from leafmap.toolbar import * 8 | 9 | 10 | class TestToolbar(unittest.TestCase): 11 | """Tests for `leafmap` module.""" 12 | 13 | def setUp(self): 14 | """Set up test fixtures, if any.""" 15 | 16 | def tearDown(self): 17 | """Tear down test fixtures, if any.""" 18 | 19 | def test_change_basemap(self): 20 | """Check basemaps""" 21 | m = leafmap.Map() 22 | change_basemap(m) 23 | out_str = m.to_html() 24 | assert "OpenStreetMap" in out_str 25 | assert "FWS NWI Wetlands" in out_str 26 | assert "NLCD 2016 CONUS Land Cover" in out_str 27 | 28 | def test_main_toolbar(self): 29 | """Check main toolbar""" 30 | m = leafmap.Map() 31 | main_toolbar(m) 32 | out_str = m.to_html() 33 | assert "Change basemap" in out_str 34 | assert "Split-panel map" in out_str 35 | assert "Planet imagery" in out_str 36 | assert "Open local vector" in out_str 37 | assert "WhiteboxTools" in out_str 38 | assert "time slider" in out_str 39 | 40 | def test_open_data_widget(self): 41 | """Check open data widget""" 42 | m = leafmap.Map() 43 | open_data_widget(m) 44 | out_str = m.to_html() 45 | assert "Shapefile" in out_str 46 | assert "GeoJSON" in out_str 47 | assert "CSV" in out_str 48 | assert "Vector" in out_str 49 | assert "Raster" in out_str 50 | 51 | def test_save_map(self): 52 | """Check save map widget""" 53 | m = leafmap.Map() 54 | save_map(m) 55 | out_str = m.to_html() 56 | assert "HTML" in out_str 57 | assert "JPG" in out_str 58 | assert "PNG" in out_str 59 | 60 | # def test_time_slider(self): 61 | # """Check time slider widget""" 62 | # m = leafmap.Map() 63 | # time_slider(m) 64 | # out_str = m.to_html() 65 | # assert "Play the time slider" in out_str 66 | # assert "Pause the time slider" in out_str 67 | # assert "Close the time slider" in out_str 68 | 69 | def test_tool_template(self): 70 | """Check tool template widget""" 71 | m = leafmap.Map() 72 | tool_template(m) 73 | out_str = m.to_html() 74 | assert "Toolbar" in out_str 75 | assert "Checkbox" in out_str 76 | assert "Dropdown" in out_str 77 | assert "Int Slide" in out_str 78 | assert "Float Slider" in out_str 79 | assert "Color" in out_str 80 | assert "Textbox" in out_str 81 | --------------------------------------------------------------------------------