[GRASS-user] GRASS GIS 7.8.5 r.water.outlet
Micha Silver
tsvibar at gmail.com
Wed May 19 12:20:11 PDT 2021
On 5/19/21 9:52 PM, Kelsey Wong wrote:
> Hi,
>
> I am trying to use the r.water.outlet function in a python script in GRASS. For the ‘coordinates’ parameter my x,y coordinate values are stored in two columns in the attribute table of another layer. Is there a way to access these values from the attribute table directly?
The grass.script command 'parse_command' returns the module output as a
python dict, so something like:
import grass.script as gscript
xy = gscript.parse_command('v.db.select', map_="another_table",
columns=['x_coord'_column, 'y_coord_column'], separator="comma")
will probably get you on the right track. If you have multiple points in
the "another_table", then you'll have to loop thru the list, and run
r.water.outlet on each pair separately.
The addon `r.streams.basins`, on the other hand, can deal with a list of
coordinate pairs. So if you convert the output of v.db.select into a
comma separated list like: x1,y1,x2,y2, x3,y3... then you can get all
basins in one go. What's more, this addon can accept a point vector of
drainage outlet points, and prepare basins for each. So if your
"another_table" is indeed a point vector, and the two columns in the
attribute table are the point coordinates, then no need to extract
coordinate from the attrib table. just feed the point vector to the
`points` parameter of `r.streams.basins`.
> Thanks,
>
> Kelsey
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918
More information about the grass-user
mailing list