[GRASS-dev] [GRASS GIS] #3598: v.rast.stats: limit region extent to that of vector

#3598: v.rast.stats: limit region extent to that of vector
---------------------------------+-------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: normal | Milestone: 7.6.0
Component: Vector | Version: unspecified
Keywords: v.rast.stats region | CPU: Unspecified
Platform: Unspecified |
---------------------------------+-------------------------
Currently, v.rast.stats follows general GRASS GIS procedure and respects
the current computational region. This means that it rasterizes the vector
map and creates a raster map of the size of that region. If the vector map
only covers a very small portion of the current region, this means a lot
of wasted computing resources and time.

v.rast.stats already slightly changes the current region by aligning it to
the raster. By also limiting the extent to the vector (see attached
patch), computational time can potentially be significantly reduced.

Two questions before I apply:

* As the expected behavior of v.rast.stats is to get stats for the
features in the vector map, limiting the region extent to that of the
vector does not change anything in the results and rather is in line with
expected behavior. Any objection ?

* Is there a risk that by using the vector extent, but aligning to the
raster, we lose some edge parts of the vector features ? Or does aligning
always extend the region to beyond the request extent ?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3598&gt;
GRASS GIS <https://grass.osgeo.org>

#3598: v.rast.stats: limit region extent to that of vector
--------------------------+---------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.6.0
Component: Vector | Version: unspecified
Resolution: | Keywords: v.rast.stats region
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------
Changes (by mlennert):

* Attachment "v_rast_stats_vectorregion.diff" added.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3598&gt;
GRASS GIS <https://grass.osgeo.org>

#3598: v.rast.stats: limit region extent to that of vector
--------------------------+---------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.6.0
Component: Vector | Version: unspecified
Resolution: | Keywords: v.rast.stats region
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by SBL):

See also: https://trac.osgeo.org/grass/ticket/3523#comment:4

Personally, I would prefer if v.rast.stats would not change the
computational region at all (like majority of the other modules).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3598#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#3598: v.rast.stats: limit region extent to that of vector
--------------------------+---------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.6.0
Component: Vector | Version: unspecified
Resolution: | Keywords: v.rast.stats region
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by mlennert):

Replying to [comment:1 SBL]:
> See also: https://trac.osgeo.org/grass/ticket/3523#comment:4
>
> Personally, I would prefer if v.rast.stats would not change the
computational region at all (like majority of the other modules).

So that means you prefer option 1 in ticket:3523#comment:4. But you also
provide option 3 which uses the vector extent.

If we just tell people in the man page that they have to take that
responsibility, this kind of defeats the purpose of your proposals in
#3523 in the case they would like to calculate statistics on a series of
rasters which are not aligned with each other.

I also have not made experiments to see how much of a difference the
change of alignment actually makes.

Intuitively, I would go for your option 3.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3598#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#3598: v.rast.stats: limit region extent to that of vector
--------------------------+---------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.6.0
Component: Vector | Version: unspecified
Resolution: | Keywords: v.rast.stats region
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by mmetz):

Replying to [ticket:3598 mlennert]:
>
> * Is there a risk that by using the vector extent, but aligning to the
raster, we lose some edge parts of the vector features ? Or does aligning
always extend the region to beyond the request extent ?

No, aligning to raster map either leaves the extents untouched, or grows
the region.

v.rast.stats could use a temporary region to get statistics. In this
particular case I think it is ok if the current region is not used.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3598#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>