SquidProjects / SonarMapper

Python scripts to process and visualize sonar data from Lowrance Fishfinders
GNU General Public License v3.0
10 stars 2 forks source link

SonarMapper

Python scripts to process and visualize sonar data from Lowrance Fishfinders

We like kayaking and always wondered what is underneath the hull. Combined with a general interest in mapping we got a fishfinder from Lowrance. However looking at recorded data on the device afterwards is not a pleasure and Lowrance doesn't deliver any free software to process the files on a PC in high resolution. Therefore we created these scripts to process and visualize the data from the fishfinder created sl2 files.

Currently supported functions:

The first part of reading the sl2 file is based on a library from KennethTM (https://github.com/KennethTM/sonaR). However this library is set in R which means that an installation of R is required.

Example output

If you need more information to get started check the videos:
Installation: https://www.youtube.com/watch?v=3kaIQv3jeYc
How To: https://www.youtube.com/watch?v=RMYd-Z57woo

Installation information for Windows

install R and Rtools
https://cran.r-project.org/bin/windows/base/
https://cran.r-project.org/bin/windows/Rtools/

open R and run in the R terminal
install.packages("remotes")
install.packages("glue")

library(remotes)
_remotes::installgithub('KennethTM/sonaR')

check Rscript path
in code/sonarMapperMain.py check the path to Rscript, since it depends on your installed version
pathToR='"C:/Program Files/R/R-4.2.1/bin/x64/Rscript.exe"'

install conda
https://www.anaconda.com/products/distribution

create environment in conda from yaml cd to the folder containing the yaml file

conda env create -f environment.yaml

activate the new environment conda activate sonar-env

Installation hint for Ubuntu

I added some changes to the code as comments that need to be applied for Ubuntu. However I didn't invest much time in it and had issues with the GDAL library, which effects the track plotting and georeference.

How to run it

activate the python enviroment
conda activate sonar-env

Create a folder for your trip files. (for example "Tag5") Now copy your .sl2 files to this folder. Adapt the config to your current project.

run it with the created config :-) (example path)
(sonar-env) C:\PATH\SonarMapper\code>python sonarMapperMain.py C:\PATH\Tag5\config.ini

Explanation image

the area for georeference can be selected for example via openstreetmap https://www.openstreetmap.org/export

Update to config

Add Ons

(1) Some of the processes take a lot of RAM. So try to make as much free as possible, depending on the size of your file.
(2) The georeferencing takes quite some time to process
(3) The georeferenced images can be loaded for example to QGIS to assemble them

Example for the usage of georeferenced images

Several images that are georeferenced can be put together on a map by for example using QGIS Georeferenced image

AI Segmentation

This feature does segment the images of down and primary scan in the following classes: ground, fish, vegetation big, vegetation small. This can not only be used for visualtization but as well for noise reduction. It is makes use of the segmentation model libary and was trained on a hand labled dataset. Is on an experimental level and therefore requires you to install some additional libaries:

pip install "tensorflow<2.11" 
pip install albumentations==1.3.0
pip install segmentation-models==1.0.1

If you want to make use of tensorflows GPU acceleration follow the tensorflow installation link

Read more about the sonarMapper segmentation here.