LSDtopotools / lsdviztools

Vizualisation (or visualisation, depending on your country) tools for LSDTopoTools and lsdtopytools
MIT License
4 stars 3 forks source link

Basin selection during chi analysis #192

Closed BenjiDa closed 2 years ago

BenjiDa commented 2 years ago

Description

I am trying to run chi analysis on several basins and am trying to select certain basins based on a junction number. I selected the outlet junctions using the AllBasinsInfo in QGIS and put the numbers into a .txt file and ran the following code.

What I Did

First I ran the following code using a Junctions.txt with the junction numbers.

lsdtt_parameters = {
                    "print_chi_data_maps" : "true",
                    "BaselevelJunctions_file": "Junctions_maacama.txt",
                    "estimate_best_fit_movern_no_bootstrap": "true"
                   }

lsdtt_drive = lsdmw.lsdtt_driver(command_line_tool = "lsdtt-chi-mapping", #default is lsdtt-basic-metrics
                                 read_prefix = "Maacama_UTM",
                                 write_prefix= "Maacama_UTM",
                                 read_path = "./",
                                 write_path = "./",
                                 parameter_dictionary=lsdtt_parameters)
lsdtt_drive.print_parameters()

lsdtt_drive.run_lsdtt_command_line_tool()

This runs the analysis but does not remove any of the unwanted basins.

The channel head file is null. 
Getting sources from a threshold of 1000 pixels.
The number of sources is: 578
I am now going to extract some basins for you.
No baselevel junctions file found. I am going to use algorithms to extract basins.

I need to check your baselevel junctions file, to see if it is in the correct path. 
The string to check is: NULL
I am going to select basins for you using an algorithm.

So looking at the LSDTopoTools repo I found info on the BaselevelJunctions file method: "An old method. You should use get_basins_from_outlets: true and basin_outlet_csv instead."

So I reran using this, with the lat, lon positions and junction numbers saved in a csv (outlet.csv):

lsdtt_parameters = {
                    "print_chi_data_maps" : "true",
                    "get_basins_from_outlets":"true",
                    "basin_outlet_csv":"outlets.csv",
                    "estimate_best_fit_movern_no_bootstrap": "true"
                   }

lsdtt_drive = lsdmw.lsdtt_driver(command_line_tool = "lsdtt-chi-mapping", #default is lsdtt-basic-metrics
                                 read_prefix = "Maacama_UTM",
                                 write_prefix= "Maacama_UTM",
                                 read_path = "./",
                                 write_path = "./",
                                 parameter_dictionary=lsdtt_parameters)
lsdtt_drive.print_parameters()

lsdtt_drive.run_lsdtt_command_line_tool()

and this fails with:

To reiterate, there is no base level junction file. I am going to select basins for you using an algorithm. 
I am getting your basins from a list of nodes. 
The basin file is: ./outlets.csv
I am creating a csv object from a raster info object and a csv name.
I have opened the csv file.
This header is: outlet_latitude
This header is: outlet_longitude
This header is: outlet_junction

and

I did not find any valid basins from your outlet.
simon-m-mudd commented 2 years ago

In the csv file the column headers must include "latitude" and "longitude" (so no "outlet_"). Other tips: 1) in the DEM if there are no junctions below your selected point the basin extraction might fail. So make sure you are upstream of at least 1 junction 2) Any basins with pixels along an edge will be removed, so make sure you have complete basins 3) You can reduce the threshold contributing pixels so there are many junctions, this means your selected point will be close to the nearest junction. Let me know if this fixes the problem.

simon-m-mudd commented 2 years ago

I have updated the docker container with newer versions and have tested this notebook against it: https://github.com/LSDtopotools/lsdtt_notebooks/blob/master/lsdtopotools/basin_selection.ipynb

BenjiDa commented 2 years ago

Yes, thanks, that worked!