[GRASS-user] Area between drainage networks

Micha Silver tsvibar at gmail.com
Sat Dec 21 05:43:07 PST 2019


On 12/20/19 5:40 PM, Luis Moreira wrote:
> Hello everyone,
>
> I'd like to obtain the area between two drainage networks. The difference
> between them is due to different calculation methods.
>
> <http://osgeo-org.1560.x6.nabble.com/file/t385794/photo5181593200849168458.jpg>
> The image above illustrates the methodology of mesuring the "error" between
> two drainage networks.
>
> Each one of the drainage networks is in a shapefile, and I need the sum of
> all the areas between the segments of the drainage networks, so that I can
> mesure the difference between them.
>
> How could I do that with GRASS?


It seems that you want to get the area between two criss-crossing line 
vectors. To do this in GRASS, you can try the procedure below. (Note 
that there will always be some dangling line segments at the end that 
are not closed, unless the two line vectors end exactly at the same point)

Assuming I have two line vectors 'streams1' and 'streams2'...


# First patch the two lines together

micha at RMS tmp $ v.patch input=streams1,streams2 output=streams_patch --o
WARNING: Vector map <streams_patch> already exists and will be overwritten
Patching vector map <streams1>...
Patching vector map <streams2>...
Building topology for vector map <streams_patch at micha>...
Registering primitives...
Building topology for vector map <streams_patch at micha>...
Intersections at borders will have to be snapped
Lines common between files will have to be edited
The header information also may have to be edited
v.patch complete. 2 vector maps patched


# Use v.clean to break lines at each intersection
micha at RMS tmp $ v.clean streams_patch output=streams_clean 
tool=break,rmdangle --o
--------------------------------------------------
Tool: Threshold
Break: 0
Remove dangles: 0
--------------------------------------------------
WARNING: Vector map <streams_clean> already exists and will be overwritten
Copying features...
  100%
Rebuilding parts of topology...
Building topology for vector map <streams_clean at micha>...
Registering primitives...
--------------------------------------------------
Tool: Break lines at intersections
  100%
--------------------------------------------------
Building topology for vector map <streams_clean at micha>...
--------------------------------------------------
Tool: Remove dangles
  100%
--------------------------------------------------
Rebuilding topology for output vector map...
Building topology for vector map <streams_clean at micha>...
Registering primitives...


# Now change the line to a boundary. This creates enclosed polygon areas

micha at RMS tmp $ v.type input=streams_clean output=streams_boundary 
from=line to=boundary --o
WARNING: Vector map <streams_boundary> already exists and will be
          overwritten
Building topology for vector map <streams_boundary at micha>...
Registering primitives...
Building areas...
  100%
Attaching centroids...
  100%
WARNING: Number of incorrect boundaries: 24

# Run v.centroids to get individual areas each with a centroids

micha at RMS tmp $ v.centroids input=streams_boundary output=streams_areas --o
WARNING: Vector map <streams_areas> already exists and will be overwritten
Processing features...
10 new centroids placed in output map
Copying attribute table(s)...
Building topology for vector map <streams_areas at micha>...
Registering primitives...
Building areas...
  100%
Attaching centroids...
  100%
WARNING: Number of incorrect boundaries: 24
v.category complete. 10 features modified.

# Add an attribute table to hold the area of each polygon

micha at RMS tmp $ v.db.addtable streams_areas column="area_sqm REAL"
WARNING: Values in column <cat> will be overwritten
Reading features...
  100%
Updating database...
  100%
10 categories read from vector map (layer 1)
10 categories read from vector map don't exist in selection from table
10 records updated/inserted (layer 1)
micha at RMS tmp $ v.to.db streams_areas option=area unit=meters 
column=area_sqm
Reading areas...
  100%
Updating database...
  100%
10 categories read from vector map (layer 1)
10 records selected from table (layer 1)
10 categories read from vector map exist in selection from table
10 records updated/inserted (layer 1)


# Check results:

micha at RMS tmp $ v.db.select streams_areas
cat|area_sqm
1|483620.195889
2|320097.009754
3|440533.925655
4|330833.778807
5|472005.399364
6|80935.144153
7|130299.225048
8|275763.239
9|281143.425416
10|446053.906035


HTH, Micha


>
> Thanks in advance.
>
>
>
>
>
> --
> Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Users-f3884509.html
> _______________________________________________
> 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