samgeo

samgeo: A Python package for segmenting geospatial data with the Segment Anything Model (SAM) - Published in JOSS (2023)

https://github.com/opengeos/segment-geospatial

Science Score: 100.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 8 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
    1 of 22 committers (4.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

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

Keywords from Contributors

dataviz folium ipyleaflet geoparquet geospatial-analysis leafmap plotly solara whiteboxtools mesh

Scientific Fields

Earth and Environmental Sciences Physical Sciences - 80% confidence
Last synced: 4 months ago · JSON representation ·

Repository

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

Basic Info
  • Host: GitHub
  • Owner: opengeos
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage: https://samgeo.gishub.org
  • Size: 2.28 MB
Statistics
  • Stars: 3,395
  • Watchers: 60
  • Forks: 346
  • Open Issues: 33
  • Releases: 41
Topics
artificial-intelligence deep-learning geopython geospatial machine-learning segment-anything segmentation
Created over 2 years ago · Last pushed 4 months ago
Metadata Files
Readme Contributing Funding License Code of conduct Citation

README.md

segment-geospatial

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

logo

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

Introduction

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.

Citations

  • 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. https://doi.org/10.21105/joss.05663
  • 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. https://doi.org/10.1016/j.jag.2023.103540

Features

  • 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
  • Segment objects from timeseries remote sensing imagery

Installation

Install from PyPI

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

bash 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:

bash 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:

bash 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:

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

Examples

Demos

  • Automatic mask generator

  • Interactive segmentation with input prompts

  • Input prompts from existing files

  • Interactive segmentation with text prompts

Tutorials

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.

Contributing

Please refer to the contributing guidelines for more information.

Acknowledgements

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.

Owner

  • Name: Open Geospatial Solutions
  • Login: opengeos
  • Kind: organization
  • Email: opengeos@outlook.com

A collection of open-source software packages for the geospatial community

JOSS Publication

samgeo: A Python package for segmenting geospatial data with the Segment Anything Model (SAM)
Published
September 12, 2023
Volume 8, Issue 89, Page 5663
Authors
Qiusheng Wu ORCID
Department of Geography & Sustainability, University of Tennessee, Knoxville, TN 37996, United States
Lucas Prado Osco ORCID
Faculty of Engineering and Architecture and Urbanism, University of Western São Paulo, Rod. Raposo Tavares, km 572 - Limoeiro, Pres. Prudente 19067-175, SP, Brazil
Editor
Hugo Ledoux ORCID
Tags
geospatial segment anything deep learning satellite

Citation (CITATION.cff)

cff-version: "1.2.0"
authors:
    - family-names: Wu
      given-names: Qiusheng
      orcid: "https://orcid.org/0000-0001-5437-4073"
    - family-names: Osco
      given-names: Lucas Prado
      orcid: "https://orcid.org/0000-0002-0258-536X"
doi: 10.5281/zenodo.8338074
message: If you use this software, please cite our article in the
    Journal of Open Source Software.
preferred-citation:
    authors:
        - family-names: Wu
          given-names: Qiusheng
          orcid: "https://orcid.org/0000-0001-5437-4073"
        - family-names: Osco
          given-names: Lucas Prado
          orcid: "https://orcid.org/0000-0002-0258-536X"
    date-published: 2023-09-12
    doi: 10.21105/joss.05663
    issn: 2475-9066
    issue: 89
    journal: Journal of Open Source Software
    publisher:
        name: Open Journals
    start: 5663
    title: "samgeo: A Python package for segmenting geospatial data with
        the Segment Anything Model (SAM)"
    type: article
    url: "https://joss.theoj.org/papers/10.21105/joss.05663"
    volume: 8
title: "samgeo: A Python package for segmenting geospatial data with the
    Segment Anything Model (SAM)"

GitHub Events

Total
  • Create event: 22
  • Release event: 6
  • Issues event: 51
  • Watch event: 367
  • Delete event: 14
  • Issue comment event: 80
  • Push event: 69
  • Pull request review event: 3
  • Pull request review comment event: 2
  • Pull request event: 46
  • Fork event: 40
Last Year
  • Create event: 22
  • Release event: 6
  • Issues event: 51
  • Watch event: 368
  • Delete event: 14
  • Issue comment event: 80
  • Push event: 69
  • Pull request review event: 3
  • Pull request review comment event: 2
  • Pull request event: 46
  • Fork event: 40

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 240
  • Total Committers: 22
  • Avg Commits per committer: 10.909
  • Development Distribution Score (DDS): 0.175
Past Year
  • Commits: 61
  • Committers: 9
  • Avg Commits per committer: 6.778
  • Development Distribution Score (DDS): 0.246
Top Committers
Name Email Commits
Qiusheng Wu g****s@g****m 198
pre-commit-ci[bot] 6****] 9
p-vdp p****n@g****m 6
Brendan Collins b****n@m****m 4
Daniel McDonald 1****v 4
James Bourbeau j****u 2
Rohit Khati 5****1 2
John Solly j****y@p****m 1
Corey White s****i@g****m 1
Darren Wiens d****s@g****m 1
David Völgyes d****s@i****g 1
Janette Rounds j****s@g****m 1
Kurt McKee c****e@k****g 1
Lucas B. Ferreira l****0@h****m 1
Lucas Osco 6****o 1
Luke Steinbicker 1****r 1
Markus Neteler m****s@n****g 1
Shawn Taylor s****r 1
amrsalah944 a****r@s****m 1
atanas-balevsky 1****y 1
dependabot[bot] 4****] 1
forestbat k****0@1****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 159
  • Total pull requests: 157
  • Average time to close issues: 25 days
  • Average time to close pull requests: about 11 hours
  • Total issue authors: 113
  • Total pull request authors: 25
  • Average comments per issue: 2.35
  • Average comments per pull request: 1.08
  • Merged pull requests: 146
  • Bot issues: 0
  • Bot pull requests: 14
Past Year
  • Issues: 33
  • Pull requests: 54
  • Average time to close issues: 27 days
  • Average time to close pull requests: about 21 hours
  • Issue authors: 28
  • Pull request authors: 12
  • Average comments per issue: 1.3
  • Average comments per pull request: 1.17
  • Merged pull requests: 46
  • Bot issues: 0
  • Bot pull requests: 8
Top Authors
Issue Authors
  • giswqs (15)
  • oscarbau (5)
  • skylning (4)
  • aloboa (3)
  • LeoCerquera (3)
  • ravishbapna (3)
  • Ankit-Vohra (2)
  • PabloVD (2)
  • VoyagerXvoyagerx (2)
  • TimeScience (2)
  • tnmthai (2)
  • fvcamargo (2)
  • moshiour (2)
  • gabengcuinirenne (2)
  • austinmw (2)
Pull Request Authors
  • giswqs (128)
  • pre-commit-ci[bot] (20)
  • brendancol (8)
  • p-vdp (6)
  • djm93dev (4)
  • ro-hit81 (4)
  • dependabot[bot] (3)
  • jrbourbeau (3)
  • slowy07 (2)
  • amrsalah944 (2)
  • Pratik-Doshi-99 (2)
  • pherateriw (2)
  • cwhite911 (2)
  • jamescrowley (2)
  • neteler (2)
Top Labels
Issue Labels
bug (101) Feature request (12) help wanted (6)
Pull Request Labels
Feature request (9) dependencies (3) github_actions (1)

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 5,684 last-month
  • Total dependent packages: 3
    (may contain duplicates)
  • Total dependent repositories: 5
    (may contain duplicates)
  • Total versions: 85
  • Total maintainers: 2
pypi.org: segment-geospatial

Meta AI' Segment Anything Model (SAM) for Geospatial Data.

  • Versions: 42
  • Dependent Packages: 3
  • Dependent Repositories: 5
  • Downloads: 5,610 Last month
Rankings
Stargazers count: 1.5%
Dependent packages count: 2.4%
Downloads: 3.4%
Forks count: 3.4%
Average: 3.4%
Dependent repos count: 6.6%
Maintainers (1)
Last synced: 4 months ago
proxy.golang.org: github.com/opengeos/segment-geospatial
  • Versions: 41
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 4 months ago
pypi.org: segment-geospatial-uni

Meta AI' Segment Anything Model (SAM) for Geospatial Data.

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 74 Last month
Rankings
Dependent packages count: 8.9%
Average: 29.6%
Dependent repos count: 50.2%
Maintainers (1)
Last synced: 4 months ago

Dependencies

.github/workflows/docker-image.yml actions
  • actions/checkout v3 composite
.github/workflows/docker-publish.yml actions
  • actions/checkout v3 composite
  • docker/build-push-action v4 composite
  • docker/login-action v2 composite
  • docker/metadata-action v4 composite
.github/workflows/docs-build.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • nwtgck/actions-netlify v2.0 composite
.github/workflows/docs.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/draft-pdf.yml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v1 composite
  • openjournals/openjournals-draft-action master composite
.github/workflows/macos.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/pypi.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/ubuntu.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/windows.yml actions
  • actions/checkout v3 composite
  • conda-incubator/setup-miniconda v2 composite
Dockerfile docker
  • jupyter/base-notebook latest build
requirements.txt pypi
  • gdown *
  • geopandas *
  • huggingface_hub *
  • matplotlib *
  • opencv-python *
  • pycocotools *
  • pyproj *
  • rasterio *
  • segment-anything-py *
  • tqdm *
  • xyzservices *
requirements_dev.txt pypi
  • rio-cogeo * development
requirements_docs.txt pypi
  • black *
  • bump2version *
  • codespell *
  • coverage *
  • deadlink *
  • flake8 *
  • ipykernel *
  • livereload *
  • mkdocs *
  • mkdocs-git-revision-date-localized-plugin *
  • mkdocs-git-revision-date-plugin *
  • mkdocs-jupyter >=0.24.0
  • mkdocs-material >=9.1.3
  • mkdocs-pdf-export-plugin *
  • mkdocstrings *
  • mkdocstrings-crystal *
  • mkdocstrings-python-legacy *
  • nbconvert *
  • nbformat *
  • pip *
  • pygments *
  • pymdown-extensions *
  • sphinx *
  • tox *
  • twine *
  • watchdog *
  • wheel *
setup.py pypi
  • x.strip *