Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.to.rast: Use verbose for no area message, not warning #2459

Merged

Conversation

wenzeslaus
Copy link
Member

When there are no areas in the vector map, v.to.rast would give warning, 'No areas selected'. However, no areas is a perfectly fine state when converting a vector map with points or lines only, so the warning is misleading.

To cover the case where a user may need to know about the number of areas, a verbose message is now added reporting the number replacing both the warning and a debug message with the number.

@metzm
Copy link
Contributor

metzm commented Jun 23, 2022

If there are areas in the vector map and areas have been requested to be rasterized with the type option, but no areas have been rasterized, I would still like to get a warning.

@wenzeslaus
Copy link
Member Author

This PR is trying to still address whatever was the motivation for the warning by giving a more detailed verbose message. If the user is wondering what is happening, --verbose will give the clear information about areas.

There is a series of issues with the current behavior:

1. False alarm

When you rasterize points or lines, you get a message WARNING: No areas selected from vector map <my_points_only_map> which is misleading. You didn't explicitly ask for areas, your data does not have any areas, and you don't expect any areas, yet you get a warning.

Without this PR:

$ v.to.rast input=bridges@PERMANENT output=bridges use=val            
WARNING: No areas selected from vector map <bridges@PERMANENT>
Pass 1 of 5:
Reading features...
...
v.to.rast complete.
(Thu Jun 23 15:44:47 2022) Command finished (4 sec) 

With the PR:

$ v.to.rast input=bridges@PERMANENT output=bridges use=val                        
Pass 1 of 5:
Reading features...
...
v.to.rast complete.

2. Inconsistency between types

The behavior is not consistent for areas-only map where you get no warning about no lines or points (or whatever else is accepted here for type). The module uses the areas without warnings WARNING: No points selected from vector map <my_areas> and WARNING: No lines selected from vector map <my_areas>.

$ v.to.rast input=nc_state@PERMANENT output=boundary use=val          
Pass 1 of 5:
Reading areas...
...
v.to.rast complete.

3. Inconsistency with other modules

The warning for no features of a given type is not consistent with other modules which take type and have default which contains multiple types. For example, v.extract has type with default point,line,boundary,centroid,area,face, but does not issue a warning when input misses one of those. Same for d.vect which is perhaps closer to v.to.rast than v.extract.

4. Empty selection is generally a valid result

Even when type option is explicitly set to a single type, v.extract does not give a warning, it is simply an empty selection like anything else. d.vect does not give any warning either for d.vect nc_state type=point or d.vect bridges type=area. This is consistent with d.vect bridges where="YEAR_BUILT > 2025" which results in an empty selection, but gives no warning.

@wenzeslaus wenzeslaus added this to the 8.4.0 milestone Jul 25, 2022
@wenzeslaus wenzeslaus added the enhancement New feature or request label Jul 26, 2022
@wenzeslaus wenzeslaus added the C Related code is in C label Jul 26, 2022
When there are no areas in the vector map, v.to.rast would give warning, 'No areas selected'. However, no areas is a perfectly fine state when converting a vector map with points or lines only, so the warning is misleading.

To cover the case where a user may need to know about the number of areas, a verbose message is now added reporting the number replacing both the warning and a debug message with the number.
@wenzeslaus wenzeslaus force-pushed the v.to.rast-no-area-warning-to-verbose branch from d92d765 to a2c0647 Compare August 5, 2022 03:03
@wenzeslaus wenzeslaus merged commit 87c9085 into OSGeo:main Aug 5, 2022
@wenzeslaus wenzeslaus deleted the v.to.rast-no-area-warning-to-verbose branch August 5, 2022 13:53
@wenzeslaus
Copy link
Member Author

Merged. This removes the false alarm, warning inconsistency in behavior between types, and warning inconsistency with other modules. Empty selection is generally a valid result, so here it also gives no warning.

The alternative of always giving warning when no features of a specific type are present, generates a lot of warnings (see #2498). Another alternative would be to completely rework of how the type option works, e.g., the default would be empty and warnings would be present if the type was explicit, but that still would be somewhat inconsistent with other modules and does not follow that an empty selection is generally a valid result.

ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
When there are no areas in the vector map, v.to.rast would give warning, 'No areas selected'. However, no areas is a perfectly fine state when converting a vector map with points or lines only, so the warning is misleading.

To cover the case where a user may need to know about the number of areas, a verbose message is now added reporting the number replacing both the warning and a debug message with the number.

This removes the false alarm, warning inconsistency in behavior between types, and warning inconsistency with other modules. Empty selection is generally a valid result, so here it also gives no warning.

The alternative of always giving warning when no features of a specific type are present, generates a lot of warnings. Another alternative would be to completely rework of how the type option works, e.g., the default would be empty and warnings would be present if the type was explicit, but that still would be somewhat inconsistent with other modules and does not follow that an empty selection is generally a valid result.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
When there are no areas in the vector map, v.to.rast would give warning, 'No areas selected'. However, no areas is a perfectly fine state when converting a vector map with points or lines only, so the warning is misleading.

To cover the case where a user may need to know about the number of areas, a verbose message is now added reporting the number replacing both the warning and a debug message with the number.

This removes the false alarm, warning inconsistency in behavior between types, and warning inconsistency with other modules. Empty selection is generally a valid result, so here it also gives no warning.

The alternative of always giving warning when no features of a specific type are present, generates a lot of warnings. Another alternative would be to completely rework of how the type option works, e.g., the default would be empty and warnings would be present if the type was explicit, but that still would be somewhat inconsistent with other modules and does not follow that an empty selection is generally a valid result.
neteler pushed a commit to nilason/grass that referenced this pull request Nov 7, 2023
When there are no areas in the vector map, v.to.rast would give warning, 'No areas selected'. However, no areas is a perfectly fine state when converting a vector map with points or lines only, so the warning is misleading.

To cover the case where a user may need to know about the number of areas, a verbose message is now added reporting the number replacing both the warning and a debug message with the number.

This removes the false alarm, warning inconsistency in behavior between types, and warning inconsistency with other modules. Empty selection is generally a valid result, so here it also gives no warning.

The alternative of always giving warning when no features of a specific type are present, generates a lot of warnings. Another alternative would be to completely rework of how the type option works, e.g., the default would be empty and warnings would be present if the type was explicit, but that still would be somewhat inconsistent with other modules and does not follow that an empty selection is generally a valid result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants