Opened 6 years ago
Last modified 5 years ago
#3694 new defect
WHERE statement in v.generalize do not work
Reported by: | BastienFR | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.8.3 |
Component: | Default | Version: | 7.4.1 |
Keywords: | v.generalize | Cc: | |
CPU: | x86-64 | Platform: | MSWindows |
Description
The WHERE
statement from v.generalize
do not seem to work anymore.
A good description of the problem was done at:
Another example:
The attached shape was produced in R with:
library(sf) library(dplyr) # preparing the shapefile nc <- st_read(system.file("gpkg/nc.gpkg", package="sf"), quiet = TRUE) %>% mutate(CNTY = as.numeric(CNTY_<median(CNTY_))) %>% select(CNTY) %>% st_transform(st_crs(2264)) %>% st_write("d:/temp/NC_test.shp")
Using QGIS to call v.generalize
(the same problem happens in grass directly, however I prefer working directly in QGIS):
C:\OSGEO4~1\bin>v.generalize input=vector_5beaccc5750337 type="line,boundary,area" where="CNTY<1" method="douglas" threshold=15000 look_ahead=7 reduction=50 slide=0.5 angle_thresh=3 degree_thresh=0 closeness_thresh=0 betweeness_thresh=0 alpha=1 beta=1 iterations=1 -l output=outputdc6669bcd1974052b171ef4c11d51846 error=errordc6669bcd1974052b171ef4c11d51846 --overwrite
I get generalization over all the territory and not just limited to the polygons where CNTY<1
(see image attached)
Attachments (5)
Change History (10)
by , 6 years ago
Attachment: | Capture.PNG added |
---|
follow-up: 2 comment:1 by , 6 years ago
Replying to BastienFR:
The
WHERE
statement fromv.generalize
do not seem to work anymore.
Looking at the manual G7:v.generalize:
layer=string
Layer number or name ('-1' for all layers)
A single vector map can be connected to multiple database tables. This number determines which table to use. When used with direct OGR access this is the layer name.
Default: -1
By default all layers are processed, in which case the cats and where options are ignored because they require a single layer to be selected.
Results are as expected when using v.generalize layer=1 where="CNTY<1" ...
.
Note that a boundary is generalized as soon as any of the areas it belongs to fulfils the where condition. In a topological vector model as in GRASS, the modification of a single boundary results in the modification of two areas.
comment:2 by , 6 years ago
Replying to mmetz:
Replying to BastienFR:
The
WHERE
statement fromv.generalize
do not seem to work anymore.Looking at the manual G7:v.generalize:
layer=string
Layer number or name ('-1' for all layers)
A single vector map can be connected to multiple database tables. This number determines which table to use. When used with direct OGR access this is the layer name.
Default: -1
By default all layers are processed, in which case the cats and where options are ignored because they require a single layer to be selected.
FWIW, I have added a warning in trunk r73673 if the cats and where options are ignored.
The QGIS interface description for v.generalize needs to be fixed to use layer=1
.
follow-up: 4 comment:3 by , 6 years ago
Thanks for your answer. I did try with the good option layer=1
directly in GRASS and it worked as expected. I'll update my question on StackExchange to give the answer (or if you want to do it, I'll accept your answer).
However, note that your tutorial do not state that properly (https://grasswiki.osgeo.org/wiki/V.generalize_tutorial#Gereneral_Parameters). There is no layer
option in the call given.
v.generalize -c input=roads output=roads_douglas_reduction2 method=douglas_reduction threshold=0 reduction=50 type=line where="cat<3"
The fact the the QGIS v.generalize tool do not allow to set the layer
option even if allowing setting the WHERE
statement, how or where should we document the problem so it's fix there?
comment:4 by , 6 years ago
Replying to BastienFR:
Thanks for your answer. I did try with the good option
layer=1
directly in GRASS and it worked as expected. I'll update my question on StackExchange to give the answer (or if you want to do it, I'll accept your answer).
You can update your question to give the answer, maybe with a link to the manual and the (by now updated) tutorial ;-)
However, note that your tutorial do not state that properly (https://grasswiki.osgeo.org/wiki/V.generalize_tutorial#Gereneral_Parameters). There is no
layer
option in the call given.v.generalize -c input=roads output=roads_douglas_reduction2 method=douglas_reduction threshold=0 reduction=50 type=line where="cat<3"
Thanks for pointing this out, now fixed.
The tutorial has been written for the initial version of v.generalize where the default answer for the layer option was 1. The default has been changed from 1 to -1 (all layers) in r39888 (9 years ago).
The fact the the QGIS v.generalize tool do not allow to set the
layer
option even if allowing setting theWHERE
statement, how or where should we document the problem so it's fix there?
The QGIS interface description for v.generalize needs to have layer=1 hard-coded (not a user-option).
comment:5 by , 5 years ago
Milestone: | → 7.8.3 |
---|
result_image