Skip to main content

A Python package for geospatial analysis and interactive mapping in a Jupyter environment.

Project description

Welcome to leafmap

image image image image image Conda Recipe image Conda Downloads image image pre-commit.ci status image image status

logo

A Python package for geospatial analysis and interactive mapping in a Jupyter environment.

Join our Discord server 👇

Introduction

Leafmap is a Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment. It is a spin-off project of the geemap Python package, which was designed specifically to work with Google Earth Engine (GEE). However, not everyone in the geospatial community has access to the GEE cloud computing platform. Leafmap is designed to fill this gap for non-GEE users. It is a free and open-source Python package that enables users to analyze and visualize geospatial data with minimal coding in a Jupyter environment, such as Google Colab, Jupyter Notebook, JupyterLab, and marimo. Leafmap is built upon several open-source packages, such as folium and ipyleaflet (for creating interactive maps), WhiteboxTools and whiteboxgui (for analyzing geospatial data), and ipywidgets (for designing interactive graphical user interface [GUI]). Leafmap has a toolset with various interactive tools that allow users to load vector and raster data onto the map without coding. In addition, users can use the powerful analytical backend (i.e., WhiteboxTools) to perform geospatial analysis directly within the leafmap user interface without writing a single line of code. The WhiteboxTools library currently contains 500+ tools for advanced geospatial analysis, such as GIS Analysis, Geomorphometric Analysis, Hydrological Analysis, LiDAR Data Analysis, Mathematical and Statistical Analysis, and Stream Network Analysis.

Acknowledgments

This project is supported by Amazon Web Services (AWS).

Statement of Need

There is a plethora of Python packages for geospatial analysis, such as geopandas for vector data analysis and xarray for raster data analysis. As listed at pyviz.org, there are also many options for plotting data on a map in Python, ranging from libraries focused specifically on maps like ipyleaflet and folium to general-purpose plotting tools that also support geospatial data types, such as hvPlot, bokeh, and plotly. While these tools provide powerful capabilities, displaying geospatial data from different file formats on an interactive map and performing basic analyses can be challenging, especially for users with limited coding skills. Furthermore, many tools lack bi-directional communication between the frontend (browser) and the backend (Python), limiting their interactivity and usability for exploring map data.

Leafmap addresses these challenges by leveraging the bidirectional communication provided by ipyleaflet, enabling users to load and visualize geospatial datasets with just one line of code. Leafmap also provides an interactive graphical user interface (GUI) for loading geospatial datasets without any coding. It is designed for anyone who wants to analyze and visualize geospatial data interactively in a Jupyter environment, making it particularly accessible for novice users with limited programming skills. Advanced programmers can also benefit from leafmap for geospatial data analysis and building interactive web applications.

Usage

Launch the interactive notebook tutorial for the leafmap Python package with Google Colab, Binder, or Amazon Sagemaker Studio Lab now:

image image Open In Studio Lab

Check out this excellent article on Medium - Leafmap a new Python Package for Geospatial data science

To learn more about leafmap, check out the leafmap documentation website - https://leafmap.org

Key Features

Leafmap offers a wide range of features and capabilities that empower geospatial data scientists, researchers, and developers to unlock the potential of their data. Some of the key features include:

  • Creating an interactive map with just one line of code: Leafmap makes it easy to create an interactive map by providing a simple API that allows you to load and visualize geospatial datasets with minimal coding.

  • Switching between different mapping backends: Leafmap supports multiple mapping backends, including ipyleaflet, folium, kepler.gl, pydeck, and bokeh. You can switch between these backends to create maps with different visualization styles and capabilities.

  • Changing basemaps interactively: Leafmap allows you to change basemaps interactively, providing a variety of options such as OpenStreetMap, Stamen Terrain, CartoDB Positron, and many more.

  • Adding XYZ, WMS, and vector tile services: You can easily add XYZ, WMS, and vector tile services to your map, allowing you to overlay additional geospatial data from various sources.

  • Displaying vector data: Leafmap supports various vector data formats, including Shapefile, GeoJSON, GeoPackage, and any vector format supported by GeoPandas. You can load and display vector data on the map, enabling you to visualize and analyze spatial features.

  • Displaying raster data: Leafmap allows you to load and display raster data, such as GeoTIFFs, on the map. This feature is useful for visualizing satellite imagery, digital elevation models, and other gridded datasets.

  • Creating custom legends and colorbars: Leafmap provides tools for customizing legends and colorbars on the map, allowing you to represent data values with different colors and corresponding labels.

  • Creating split-panel maps and linked maps: With Leafmap, you can create split-panel maps to compare different datasets side by side. You can also create linked maps that synchronize interactions between multiple maps, providing a coordinated view of different spatial data.

  • Downloading and visualizing OpenStreetMap data: Leafmap allows you to download and visualize OpenStreetMap data, providing access to detailed street maps, buildings, and other points of interest.

  • Creating and editing vector data interactively: Leafmap includes tools for creating and editing vector data interactively on the map. You can draw points, lines, and polygons, and modify them as needed.

  • Searching for geospatial data: Leafmap provides functionality for searching and accessing geospatial data from sources such as SpatialTemporal Asset Catalogs (STAC), Microsoft Planetary Computer, AWS Open Data Registry, and OpenAerialMap.

  • Inspecting pixel values interactively: Leafmap allows you to interactively inspect pixel values in raster datasets, helping you analyze and understand the data at a more granular level.

  • Creating choropleth maps and heat maps: Leafmap supports the creation of choropleth maps, where colors represent different data values for specific geographic areas. You can also create heat maps to visualize data density.

  • Displaying data from a PostGIS database: Leafmap provides tools for connecting to a PostGIS database and displaying spatial data stored in the database on the map.

  • Creating time series animations: Leafmap enables the creation of time series animations from both vector and raster data, allowing you to visualize temporal changes in your geospatial datasets.

  • Analyzing geospatial data with whitebox: Leafmap integrates with WhiteboxTools and whiteboxgui, providing a suite of geospatial analyses, such as hydrological analysis, terrain analysis, and LiDAR processing.

  • Segmenting and classifying remote sensing imagery: Leafmap integrates the segment-geospatial package, which provides tools for segmenting and classifying remote sensing imagery using deep learning algorithms.

  • Building interactive web apps: Leafmap supports the development of interactive web applications using frameworks like Voila, Streamlit, and Solara. This allows you to share your geospatial analyses and visualizations with others in a user-friendly web interface.

These features and capabilities make leafmap a powerful tool for geospatial data exploration, analysis, and visualization. Whether you are a beginner or an experienced geospatial data scientist, leafmap provides an accessible and efficient way to work with geospatial data in Python.

Citations

If you find leafmap useful in your research, please consider citing the following paper to support my work. Thank you for your support.

  • Wu, Q. (2021). Leafmap: A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment. Journal of Open Source Software, 6(63), 3414. https://doi.org/10.21105/joss.03414

Demo

YouTube Channel

I have created a YouTube Channel for sharing geospatial tutorials. You can subscribe to my channel for regular updates. Check out the following videos for 3D mapping with MapLibre and Leafmap.

MapLibre tutorials

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leafmap-0.41.3.tar.gz (8.0 MB view details)

Uploaded Source

Built Distribution

leafmap-0.41.3-py2.py3-none-any.whl (504.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file leafmap-0.41.3.tar.gz.

File metadata

  • Download URL: leafmap-0.41.3.tar.gz
  • Upload date:
  • Size: 8.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for leafmap-0.41.3.tar.gz
Algorithm Hash digest
SHA256 a61b9da81aeea8621ed13590d461a59f4c27f94f64af896ccd483b8252a3bb10
MD5 5ee15cc46b1cc39bf2098ec3b86813f4
BLAKE2b-256 15a4b95c680bb6062cf88cd3641bcc84b8f0075628dc9c66984257b1b59c1053

See more details on using hashes here.

File details

Details for the file leafmap-0.41.3-py2.py3-none-any.whl.

File metadata

  • Download URL: leafmap-0.41.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 504.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for leafmap-0.41.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e178eb0bf65615b0c5fdf3f00c66253840d0f2c7bd1bc111ebd36779ee13965f
MD5 61e9d74b88d39df05c06a5d2ffb2f063
BLAKE2b-256 04a4f8422b4d4a238bc33338a62e70ee30b43fdc40f2d50d09e409bceb71b4ef

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page