grass icon indicating copy to clipboard operation
grass copied to clipboard

[Feat] Unexpected behaviour / documentation of 3D parameters of g.region

Open lrntct opened this issue 5 months ago • 7 comments

Describe the bug

2D and 3D raster maps do no share the same resolution in the computational region, although they share other parameters. I find this behaviour unexpected with the current state of the documentation.

To reproduce

import grass_session  # noqa: F401
import grass.script as gs
from grass.script import array as garray

gs.run_command("g.region", b=0, t=100, tbres=20, rows=150, cols=135)
gs.run_command("g.region", flags="3p")

raster3d_name = "raster_3d_test"
gs.raster3d.mapcalc3d(exp=f"{raster3d_name}=rand(10,100)", seed=1, overwrite=True)
array3d = garray.array3d(mapname=raster3d_name)
array2d = garray.array(mapname="elev_srtm_30m")
print(f"{array3d.shape=}")  # Expected (5, 150, 135)
print(f"{array2d.shape=}")  # Expected (150, 135)
projection: 99 (Lambert Conformal Conic)
zone:       0
datum:      nad83
ellipsoid:  a=6378137 es=0.006694380022900787
north:      220750
south:      220000
west:       638300
east:       639000
top:        100.00000000
bottom:     0.00000000
nsres:      5
nsres3:     1
ewres:      5.18518519
ewres3:     1
tbres:      20
rows:       150
rows3:      750
cols:       135
cols3:      700
depths:     5
cells:      20250
cells3:     2625000
 100%
array3d.shape=(5, 750, 700)
array2d.shape=(150, 135)

Expected behavior

I would expect rows==rows3, cols==cols3, etc. Especially considering that the extent is shared between 2D and 3D rasters, and that there is no 3D equivalents for the cols and rows arguments in g.region.

Neither the current g.region nor the 3d raster documentation are explicit about the fact that although 2d and 3d maps share the region extent, they do not share its resolution.

Work items

  • [x] Make documentation clearer (#5817)
  • [x] Add parameters nsres3 and ewres3 to g.region (#5883)
  • [ ] Support of 3D parameters in pygrass.Region

lrntct avatar May 30 '25 23:05 lrntct