Trying to address this SE question:
https://gis.stackexchange.com/questions/319319/how-to-apply-smoothing-filter-only-to-way-bigger-than-specified-number-of-nodes
I tried to apply v.generalize to a subset of area features, using a where clause, but it doesn’t seem to be working. All features are generlized, as if the where clause is being ignored. Here’s an example from the nc_basic_sm MAPSET:
micha@TP480:~$ v.extract geology output=my_geology --o where="GEO_NAME='Qp'"
WARNING: Vector map <my_geology> already exists and will be overwritten
.....
micha@TP480:~$ v.db.addcolumn my_geology column="area_sqkm DOUBLE"
micha@TP480:~$ v.to.db my_geology option=area column=area_sqkm unit=kilometer
WARNING: Values in column <area_sqkm> will be overwritten
.....
326 records updated/inserted (layer 1)
# Only 21 features are larger than 10 sq.km.:
micha@TP480:~$ v.db.select -c my_geology column=area_sqkm where="area_sqkm>10" | wc -l
21
micha@TP480:~$ v.generalize my_geology output=my_geology_smooth type=area method=douglas thresh=100 where="area_sqkm>10" --o
....
v.generalize complete. Number of vertices for selected features reduced
from 44238 to 7540 (17% remaining)
Now viewing both my_geology and my_geology_smooth shows that all features were smoothed. Including those island polygons that were much smaller than 10 sq.km.
Am I missing something?
···
--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918
On Sat, Apr 20, 2019 at 8:27 PM Micha Silver <tsvibar@gmail.com> wrote:
Trying to address this SE question:
https://gis.stackexchange.com/questions/319319/how-to-apply-smoothing-filter-only-to-way-bigger-than-specified-number-of-nodes
I tried to apply v.generalize to a subset of area features, using a where clause, but it doesn’t seem to be working. All features are generlized, as if the where clause is being ignored. Here’s an example from the nc_basic_sm MAPSET:
micha@TP480:~$ v.extract geology output=my_geology --o where=“GEO_NAME=‘Qp’”
WARNING: Vector map <my_geology> already exists and will be overwritten
…
micha@TP480:~$ v.db.addcolumn my_geology column=“area_sqkm DOUBLE”
micha@TP480:~$ v.to.db my_geology option=area column=area_sqkm unit=kilometer
WARNING: Values in column <area_sqkm> will be overwritten
…
326 records updated/inserted (layer 1)
Only 21 features are larger than 10 sq.km.:
micha@TP480:~$ v.db.select -c my_geology column=area_sqkm where=“area_sqkm>10” | wc -l
21
micha@TP480:~$ v.generalize my_geology output=my_geology_smooth type=area method=douglas thresh=100 where=“area_sqkm>10” --o
…
v.generalize complete. Number of vertices for selected features reduced
from 44238 to 7540 (17% remaining)
Now viewing both my_geology and my_geology_smooth shows that all features were smoothed. Including those island polygons that were much smaller than 10 sq.km.
Am I missing something?
Yes, the option layer defaults to -1 = all layers. If you use the cats or where option, you need to specify a layer, otherwise the warning
WARNING: No layer selected, ‘where’ and ‘cats’ options are ignored
is issued in trunk. I have backported this warning to relbr76 in r74409.
HTH,
Markus M
On Sun, Apr 21, 2019 at 11:16 AM Micha Silver <tsvibar@gmail.com> wrote:
On 21/04/2019 0:42, Markus Metz wrote:
Am I missing something?
Yes, the option layer defaults to -1 = all layers. If you use the cats or where option, you need to specify a layer, otherwise the warning
WARNING: No layer selected, ‘where’ and ‘cats’ options are ignored
Ah ha
Thanks,
Maybe an extra sentence in the manpage would be appropriate?
Under the “Description” section:
“If type=area is selected, boundaries of selected areas will be generalized, and the options cats, where, and layer will be used to select areas. However the cats and where options are used only if a layer is specified. If no layer is specified, those options are ignored.”
The cats, where, and layer options apply to areas as well as lines.
Therefore I have added
“The cats and where options are used only if a layer > 0 is specified, otherwise, those options are ignored. Be aware that the default is layer=-1, meaning that all layers are processed, ignoring the cats and where options.”
to the manual in trunk and relbr76.
Markus M
Best, Micha
is issued in trunk. I have backported this warning to relbr76 in r74409.
HTH,
Markus M
–
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918