[Qgis-developer] Problem with GRASS Region Extent and Region Cellsize on Processing

Pedro VenĂ¢ncio pedrongvenancio at gmail.com
Fri Mar 11 15:13:30 PST 2016


Hi Martin,

Thank you very much for the hint.

So, runing an operation and aligning the result to a raster with a smaller
extent:

g.proj -c proj4="+proj=tmerc +lat_0=39.66825833333333
+lon_0=-8.133108333333334 +k=1 +x_0=0 +y_0=0 +ellps=GRS80
+towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
r.external input="/home/pedro/SIG/MDT_JAG/dem_80m.tif" band=1
output=tmp1457733840723 --overwrite -o
g.region -a n=137550.0 s=112250.0 e=100125.0 w=74200.0 res=25
r.relief input=tmp1457733840723 altitude="30" azimuth="270" zscale="1"
scale="1" output=outputcb4f43647d7f428091f6b2971f87b214 --overwrite
g.region raster=outputcb4f43647d7f428091f6b2971f87b214
r.out.gdal --overwrite -c createopt="TFW=YES,COMPRESS=LZW"
input=outputcb4f43647d7f428091f6b2971f87b214
output="/tmp/processing72b78383106b4767bf4af0e1b207fc0a/fd0523aeda4f47ef87e79b1ea6afe0ae/output.tif"

and the result is ok.

Running the same operation, but aligning to a raster with a greater extent,
and a lower resolution:

g.proj -c proj4="+proj=tmerc +lat_0=39.66825833333333
+lon_0=-8.133108333333334 +k=1 +x_0=0 +y_0=0 +ellps=GRS80
+towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
r.external input="/home/pedro/SIG/MDT_JAG/raster_1.tif" band=1
output=tmp1457734497734 --overwrite -o
g.region -a n=154440.0 s=92680.0 e=114680.0 w=64040.0 res=80
r.relief input=tmp1457734497734 altitude="30" azimuth="270" zscale="1"
scale="1" output=outpute2696cc0c7194a6f80fb2494dd0a97ff --overwrite
g.region raster=outpute2696cc0c7194a6f80fb2494dd0a97ff
r.out.gdal --overwrite -c createopt="TFW=YES,COMPRESS=LZW"
input=outpute2696cc0c7194a6f80fb2494dd0a97ff
output="/tmp/processing72b78383106b4767bf4af0e1b207fc0a/02a931bb96124de49723ceacb4e18c46/output.tif"

the extent of the result raster is: w=64000.0 e=114720.0 s=92640.0
n=154480.0
The difference is 40 (half size of the original raster resolution).


So I suspected of the -a flag of g.region

"""
-a: Align region to resolution (default = align to bounds, works only for
2D resolution)

After all updates have been applied, the current region's southern and
western boundaries are (silently) adjusted so that the north/south distance
is a multiple of the north/south resolution and that the east/west distance
is a multiple of the east/west resolution.
With the -a flag all four boundaries are adjusted to be even multiples of
the resolution, aligning the region to the resolution supplied by the user.
The default is to align the region resolution to match the region
boundaries.
"""
from https://grass.osgeo.org/grass70/manuals/g.region.html

I removed GRASS_REGION_ALIGN_TO_RESOLUTION (-a) from
../python/plugins/processing/algs/grass7/Grass7Algorithm.py and the result
was correct

g.proj -c proj4="+proj=tmerc +lat_0=39.66825833333333
+lon_0=-8.133108333333334 +k=1 +x_0=0 +y_0=0 +ellps=GRS80
+towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
r.external input="/home/pedro/SIG/MDT_JAG/raster_1.tif" band=1
output=tmp1457735611533 --overwrite -o
g.region n=154440.0 s=92680.0 e=114680.0 w=64040.0 res=80
r.relief input=tmp1457735611533 altitude="30" azimuth="270" zscale="1"
scale="1" output=output4b1c7211268b4cf79133e876ba2cb133 --overwrite
g.region raster=output4b1c7211268b4cf79133e876ba2cb133
r.out.gdal -c createopt="TFW=YES,COMPRESS=LZW"
input=output4b1c7211268b4cf79133e876ba2cb133
output="/tmp/processingeb0423f9b07f4ef899d08e44b22d61bc/4acf63406c634f7297db9e65f4beebeb/output.tif"
--overwrite

The extent of the result raster was: w=64040.0 e=114680.0 s=92680.0
n=154440.0

Is there any reason to use the -a flag in Processing g.region?

Thanks!

Best regards,
Pedro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160311/229cc66f/attachment.html>


More information about the Qgis-developer mailing list