Skip to main content

Interface for predicting and mapping benthic habitat (substrates) from any side-scan sonar mosaic.

Project description

1FAA8_color RockMapper

🚧UNDER CONSTRUCTION-GUI Forthcoming🚧

PyPI - Version GitHub last commit GitHub commit activity GitHub

Interface for predicting and mapping benthic habitat (substrates) from any side-scan sonar mosaic.

Overview

RockMapper is an open-source Python interface for automatically predicting and mapping rock from any side-scan sonar mosaic(s). RockMapper leverages SegFormer pre-trained models fine-tuned with Segmentation Gym to automatically classify "rocky" substrate- defined as any hard particle greater than 2 mm in size. RockMapper uses the Udden-Wentworth grain size scale when classifying substrate into four classes: other (fines <2mm), gravel (2mm - 64mm), boulder/cobble (>64mm ), and bedrock (unfractured hard substrates) (Wentworth 1922).

Published Documentation

Journal Article

Wolfenkoehler, W. A., Bodine, C. S., & Long, J. M. (forthcoming). Evaluating RockMapper: A software to automatically map aquatic substrate from sonar images.

In this study RockMapper was evaluated by comparing output maps to those made by manual methods, allowing future substrate delineators to better understand the potential strengths or limitations of each approach. RockMapper mapping resulted in similar accuracy to manual methods, which ranged between 61-98%, while also saving ~ 11 minutes per hectare of manual delineation time. Additionally, RockMapper appeared to generalize well to new rivers, indicating reproducibility to unseen datasets.

Model Training Data

Wolfenkoehler, W., and Long, J., 2026, Substrate classifications of three rivers in eastern Oklahoma: U.S. Geological Survey data release, https://doi.org/10.5066/P1CZGXSF

Installation

  1. Install Miniforge.
  2. Open the Miniforge prompt.
  3. Install PINGInstaller:
    pip install --force-reinstall pinginstaller
    
  4. Install RockMapper.
    python -m pinginstaller rockmapper
    

Usage

  1. Copy the following script to some location on your computer and name it "RockMapper.py":
'''
Copyright (c) 2025 Cameron S. Bodine
'''

#########
# Imports
import os, sys
import time, datetime

start_time = time.time()

# Set ROCKMAPPER utils dir
USER_DIR = os.path.expanduser('~')
GV_UTILS_DIR = os.path.join(USER_DIR, '.rockmapper')
if not os.path.exists(GV_UTILS_DIR):
    os.makedirs(GV_UTILS_DIR)

def gui():
    '''
    '''

    #################
    # NEED TO ADD GUI


    # FOR DEVELOPMENT
    #############################
    # Update Parameters
    seg_model = 'RockMapper_20251117_v2'
    inDir = r'Z:\scratch\202506_BrushyDeepKiamichi_Substrate\mosaics' #location of the sonar mosaic you wish to process
    mosaicFileType = '.tif'
    outDirTop = r'Z:\scratch' #output folder where you wish to place the RockMapper substrate shapefile
    projName = 'RockMapperTest'
    mapRast = False #do you want a raster output?
    mapShp = True #do you want a shapefile output? 

    epsg = 32615 # change to desired cooordinate system

    windowSize_m = (18, 18)
    window_stride = 6
    minArea_percent = 0.75
    threadCnt = 0.75

    predBatchSize = 30

    minPatchSize_m2 = 5 # Minimum patch size to keep in final shapefile, in square meters
    smoothShp = True # Smooth final shapefile polygons
    smoothTol_m = 0.3 # Smoothing tolerance in meters, higher = more smoothing

    deleteIntData = True



    ################
    # Run HabiMapper

    modelDir = os.path.join(GV_UTILS_DIR, 'models')

    # RockMapper
    if seg_model in ['RockMapper_20250628_v1', 'RockMapper_20251117_v2']:
        from rockmapper.rock_mapper import do_work

        modelDir = os.path.join(modelDir, seg_model)


        print('\n\nMapping habitat with ROCKMAPPER model...\n\n')
        do_work(
        inDir = inDir,
        outDirTop = outDirTop,
        projName = projName,
        mapRast = mapRast,
        mapShp = mapShp,
        epsg = epsg,
        windowSize_m = windowSize_m,
        window_stride = window_stride,
        minArea_percent = minArea_percent,
        threadCnt = threadCnt,
        mosaicFileType=mosaicFileType, 
        modelDir=modelDir,
        predBatchSize=predBatchSize,
        deleteIntData=deleteIntData,
        minPatchSize = minPatchSize_m2,
        smoothShp = smoothShp,
        smoothTol_m = smoothTol_m,
        )





    print("\n\nGrand Total Processing Time: ", datetime.timedelta(seconds = round(time.time() - start_time, ndigits=0)))
    return

if __name__ == "__main__":
    gui()
  1. Open the file with Visual Studio Code.
  2. Update the Parameters as necessary:
#############################
# Update Parameters
seg_model = 'RockMapper_20251117_v2' 
inDir = r'Z:\scratch\202506_BrushyDeepKiamichi_Substrate\mosaics' #location of the sonar mosaic you wish to process
mosaicFileType = '.tif'
outDirTop = r'Z:\scratch' #output folder where you wish to place the RockMapper substrate shapefile
projName = 'RockMapperTest'
mapRast = False #do you want a raster output?
mapShp = True #do you want a shapefile output? 

epsg = 32615 # change to desired cooordinate system

windowSize_m = (18, 18)
window_stride = 6
minArea_percent = 0.75
threadCnt = 0.75

predBatchSize = 30

minPatchSize_m2 = 5 # Minimum patch size to keep in final shapefile, in square meters
smoothShp = True # Smooth final shapefile polygons
smoothTol_m = 0.3 # Smoothing tolerance in meters, higher = more smoothing

deleteIntData = True
  1. Open Mini Forge Prompt
  2. type "conda activate rockmapper"
  3. change the directory to the folder where the python script is located
  4. Run the script by typing "python RockMapper.py"

Project details


Download files

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

Source Distribution

rockmapper-1.0.0a10.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rockmapper-1.0.0a10-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file rockmapper-1.0.0a10.tar.gz.

File metadata

  • Download URL: rockmapper-1.0.0a10.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for rockmapper-1.0.0a10.tar.gz
Algorithm Hash digest
SHA256 af160a6523b9b87cc68eec2c13c6a98f983834fcdd4e75bc846d274d42139e5f
MD5 2d6ff1b16c8e69f635d5dbe5f9ca5bda
BLAKE2b-256 8564cd944b559f321850645fc343fa7b91c6be3e79b7b49522769f0b0a25a2f0

See more details on using hashes here.

File details

Details for the file rockmapper-1.0.0a10-py3-none-any.whl.

File metadata

  • Download URL: rockmapper-1.0.0a10-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for rockmapper-1.0.0a10-py3-none-any.whl
Algorithm Hash digest
SHA256 0a292f200d35f209393bcc66cc4af4ce4f625ba785909340d178a472381fb462
MD5 6de269cc104755033826c48af97a483c
BLAKE2b-256 b72642328d16d8f5a81aceeb773dd1f9b1fad73c6390a0abf48fee0fd7899ebf

See more details on using hashes here.

Supported by

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