Package: segment-geospatial
segment-geospatialA Python package for segmenting geospatial data with the Segment Anything Model (SAM)IntroductionThesegment-geospatialpackage draws its inspiration fromsegment-anything-eorepository authored byAliaksandr Hancharenka. To facilitate the use of the Segment Anything Model (SAM) for geospatial data, I have developed thesegment-anything-pyandsegment-geospatialPython 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 thesegment-anything-eorepository, and credit for its original version goes to Aliaksandr Hancharenka.Free software: MIT licenseDocumentation:https://samgeo.gishub.orgCitationsWu, 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.05663FeaturesDownload map tiles from Tile Map Service (TMS) servers and create GeoTIFF filesSegment GeoTIFF files using the Segment Anything Model (SAM) andHQ-SAMSegment remote sensing imagery with text promptsCreate foreground and background markers interactivelyLoad existing markers from vector datasetsSave segmentation results as common vector formats (GeoPackage, Shapefile, GeoJSON)Save input prompts as GeoJSON filesVisualize segmentation results on interactive mapsInstallationInstall from PyPIsegment-geospatialis available onPyPI. To installsegment-geospatial, run this command in your terminal:pipinstallsegment-geospatialInstall from conda-forgesegment-geospatialis also available onconda-forge. If you haveAnacondaorMinicondainstalled on your computer, you can install segment-geospatial using the following commands. It is recommended to create a fresh conda environment forsegment-geospatial. The following commands will create a new conda environment namedgeoand installsegment-geospatialand its dependencies:condacreate-ngeopython
condaactivategeo
condainstall-cconda-forgemamba
mambainstall-cconda-forgesegment-geospatialSamgeo-geospatial has some optional dependencies that are not included in the default conda environment. To install these dependencies, run the following command:mambainstall-cconda-forgegroundingdino-pysegment-anything-fastAs of July 9th, 2023 Linux systems have also required thatlibgl1be installed for segment-geospatial to work. The following command will install that dependencyaptupdate;aptinstall-ylibgl1ExamplesSegmenting remote sensing imageryAutomatically generating object masksSegmenting remote sensing imagery with input promptsSegmenting remote sensing imagery with box promptsSegmenting remote sensing imagery with text promptsBatch segmentation with text promptsUsing segment-geospatial with ArcGIS ProSegmenting swimming pools with text promptsSegmenting satellite imagery from the Maxar Open Data ProgramDemosAutomatic mask generatorInteractive segmentation with input promptsInput prompts from existing filesInteractive segmentation with text promptsTutorialsVideo tutorials are available on myYouTube Channel.Automatic mask generationUsing SAM with ArcGIS ProInteractive segmentation with text promptsUsing SAM with Desktop GISQGIS: Check out theGeometric Attributes plugin for QGIS. Credit goes toBjorn Nyberg.ArcGIS: Check out theSegment Anything Model (SAM) Toolbox for ArcGISand theResources for Unlocking the Power of Deep Learning Applications Using ArcGIS. Credit goes toEsri.Computing ResourcesThe 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 forAWS 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 Credithere.Legal NoticeThis 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.ContributingPlease refer to thecontributing guidelinesfor more information.AcknowledgementsThis project is based upon work partially supported by the National Aeronautics and Space Administration (NASA) under Grant No. 80NSSC22K1742 issued through theOpen 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.segment-anythingsegment-anything-eotms2geotiffGroundingDINOlang-segment-anything