Fork: 270 Star: 2679 (更新于 2024-05-23 04:41:45)

license: MIT

Language: Python .

A Python package for segmenting geospatial data with the Segment Anything Model (SAM)

最后发布版本: v0.10.6 ( 2024-05-09 21:41:53)

官方网址 GitHub网址


image image image image image Docker Pulls PyPI Downloads Conda Downloads DOI

A Python package for segmenting geospatial data with the Segment Anything Model (SAM)


The segment-geospatial package draws its inspiration from segment-anything-eo repository authored by Aliaksandr Hancharenka. To facilitate the use of the Segment Anything Model (SAM) for geospatial data, I have developed the segment-anything-py and segment-geospatial Python packages, which are now available on PyPI and conda-forge. My primary objective is to simplify the process of leveraging SAM for geospatial data analysis by enabling users to achieve this with minimal coding effort. I have adapted the source code of segment-geospatial from the segment-anything-eo repository, and credit for its original version goes to Aliaksandr Hancharenka.


  • Wu, Q., & Osco, L. (2023). samgeo: A Python package for segmenting geospatial data with the Segment Anything Model (SAM). Journal of Open Source Software, 8(89), 5663.
  • Osco, L. P., Wu, Q., de Lemos, E. L., Gonçalves, W. N., Ramos, A. P. M., Li, J., & Junior, J. M. (2023). The Segment Anything Model (SAM) for remote sensing applications: From zero to one shot. International Journal of Applied Earth Observation and Geoinformation, 124, 103540.


  • Download map tiles from Tile Map Service (TMS) servers and create GeoTIFF files
  • Segment GeoTIFF files using the Segment Anything Model (SAM) and HQ-SAM
  • Segment remote sensing imagery with text prompts
  • Create foreground and background markers interactively
  • Load existing markers from vector datasets
  • Save segmentation results as common vector formats (GeoPackage, Shapefile, GeoJSON)
  • Save input prompts as GeoJSON files
  • Visualize segmentation results on interactive maps


Install from PyPI

segment-geospatial is available on PyPI. To install segment-geospatial, run this command in your terminal:

pip install segment-geospatial

Install from conda-forge

segment-geospatial is also available on conda-forge. If you have Anaconda or Miniconda installed on your computer, you can install segment-geospatial using the following commands. It is recommended to create a fresh conda environment for segment-geospatial. The following commands will create a new conda environment named geo and install segment-geospatial and its dependencies:

conda create -n geo python
conda activate geo
conda install -c conda-forge mamba
mamba install -c conda-forge segment-geospatial

If your system has a GPU, but the above commands do not install the GPU version of pytorch, you can force the installation of the GPU version of pytorch using the following command:

mamba install -c conda-forge segment-geospatial "pytorch=*=cuda*"

Samgeo-geospatial has some optional dependencies that are not included in the default conda environment. To install these dependencies, run the following command:

mamba install -c conda-forge groundingdino-py segment-anything-fast



  • Automatic mask generator

  • Interactive segmentation with input prompts

  • Input prompts from existing files

  • Interactive segmentation with text prompts


Video tutorials are available on my YouTube Channel.

  • Automatic mask generation

Alt text

  • Using SAM with ArcGIS Pro

Alt text

  • Interactive segmentation with text prompts

Alt text

Using SAM with Desktop GIS

Computing Resources

The Segment Anything Model is computationally intensive, and a powerful GPU is recommended to process large datasets. It is recommended to have a GPU with at least 8 GB of GPU memory. You can utilize the free GPU resources provided by Google Colab. Alternatively, you can apply for AWS Cloud Credit for Research, which offers cloud credits to support academic research. If you are in the Greater China region, apply for the AWS Cloud Credit here.

Legal Notice

This repository and its content are provided for educational purposes only. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations. Users who intend to download a large number of image tiles from any basemap are advised to contact the basemap provider to obtain permission before doing so. Unauthorized use of the basemap or any of its components may be a violation of copyright laws or other applicable laws and regulations.


Please refer to the contributing guidelines for more information.


This project is based upon work partially supported by the National Aeronautics and Space Administration (NASA) under Grant No. 80NSSC22K1742 issued through the Open Source Tools, Frameworks, and Libraries 2020 Program.

This project is also supported by Amazon Web Services (AWS). In addition, this package was made possible by the following open source projects. Credit goes to the developers of these projects.

最近版本更新:(数据更新于 2024-05-23 04:41:29)

2024-05-09 21:41:53 v0.10.6

2024-04-23 23:48:56 v0.10.5

2024-03-30 11:33:31 v0.10.4

2024-03-29 20:52:08 v0.10.3

2023-11-08 10:50:45 v0.10.2

2023-09-02 10:15:38 v0.10.1

2023-08-25 00:23:26 v0.10.0

2023-08-15 11:46:27 v0.9.1

2023-08-07 03:28:15 v0.9.0

2023-07-20 02:19:06 v0.8.5


artificial-intelligence, deep-learning, geopython, geospatial, machine-learning, segment-anything, segmentation

opengeos/segment-geospatial同语言 Python最近更新仓库

2024-06-21 18:02:49 argilla-io/argilla

2024-06-18 16:26:58 hpcaitech/Open-Sora

2024-06-18 10:45:23 vanna-ai/vanna

2024-06-15 05:16:32 NVIDIA/warp

2024-06-14 10:42:40 1Panel-dev/MaxKB

2024-06-13 22:59:46 mikumifa/biliTickerBuy