[GRASS-user] v.select incredibly slow

Uwe Fischer gisfisch at t-online.de
Mon Mar 29 00:53:23 PDT 2021


Hi Moritz & hi list,

shame on me, I use 7.0.4. It has to do with some old clumsy scripts I produced and I never found the time to update (I'm not a GRASS professional or programmer, so things are quite hard for me). I am sure the v.select issue has to do with the old version. I will try soon with a newer one.

Furthermore, I changed the way the tubular buffers are prepared and now I have a much smaller and better fitting number of buffers. That helped a lot.

The trash output was produced by me myself because i did something wrong in preparing the data before they went into v.select. Problem is solved.

But it led me again to some kind of misunderstanding that I cannot figure out:

My data are imported from polygon shapefiles.

First question: using v.in.ogr, what does the "type=" parameter mean exactly? In the manual, it reads: "Optionally change default input type". But imho, the input is the input. You cannot change it. What can be changed is the output or the way you process the input. This question prevents me from really understanding what v.in.ogr does with my polygons.

Second question: I thought a GRASS map is able to hold areas and lines together in one map at the same time. How can I achieve such a mixed map using v.in.ogr from my polygon Shapes?

When I use it without "type=", it will produce polys only.
When I use it with "type=line", it will produce lines only, some of which are holding former area attributes (which makes no sense for lines)
When I use it with "type=line, boundary", it will also produce lines only.
Using "type=centroid, boundary" makes no sense because the input polygon shapefile has only polygons, but no centroids.

Maybe I have to go another way?

Thanks for help and best regards,

-----Ursprüngliche Nachricht-----
Von: Moritz Lennert [mailto:mlennert at club.worldonline.be] 
Gesendet: Sonntag, 28. März 2021 13:50
An: grass-user at lists.osgeo.org; Uwe Fischer <gisfisch at t-online.de>
Betreff: Re: [GRASS-user] v.select incredibly slow

Hi Uwe,

Am 27. März 2021 14:58:01 MEZ schrieb Uwe Fischer <gisfisch at t-online.de>:
>Hello list,
>
>I have trouble selecting line features using their location compared to 
>a polygon layer using v.select. The line features I want to select from 
>are parcel borders, and the polygon layer is made up of tubular-shaped 
>buffers around municipal borders. I need to find the parcel borders 
>which are inside this buffer.
>
>The command line in a Python script I use is:
>
>grass.run_command('v.select', ainput='temp5', atype='line', 
>binput='buff', blayer=1, btype='area', output='grenz', 
>operator='within', overwrite=True)
>
>The process starts, but it runs incredibly slow (> 15 min) and it 
>brings not the desired result (but trash data). When I start it in the 
>GRASS ui, it also works very very slow.
>
>I have only about 2000 parcel borders, so it cannot be a problem of too 
>much features. Furthermore, the exact same selection task is processed 
>in QGIS 3 in a second with perfect results.
>
>I used v.build on both maps before v.select, but it does not help.
>
>I would like to perform it in GRASS because it is part of a bigger data 
>preparation script which makes my work a lot easier. So I need to 
>integrate it here rather than selecting in QGIS manually.


First of all: which version of GRASS GIS are you using ?

I filed a bug about this same issue a few years ago [1] and Markus Metz reorganized the code at the time to speed things up. I don't remember which version was the first to include the fixes (7.6 ?). However, even though it was slow, results were ok which doesn't seem to be the case for you, so that is a bit worrying.

Can you reproduce the same issue with the example given in that bug report ? If not can you provide a reproducible example, including relevant data ? Ideally as a GitHub issue ?

As a workaround you could try either the alternative provided in the bug report, or you  could try to reduce the number of line candidates first using v.select operator=overlap and using operator=within only on those selected in the first call.

Moritz

[1] https://trac.osgeo.org/grass/ticket/3361



More information about the grass-user mailing list