[GRASS-user] Setting region to add map to location

   I am trying to add additional DEM maps to the project location. There is
one DEM overlaid on a soil mapping unit map for the county in the attached
screenshot. My reading of the g.region manual page did not let me find the
answers I need.

   The computational region is set to the soil map. Attempting to re-project
the DEM to the immediate west of the existing one fails; grass7.5svn tells
me, "ERROR: Input raster map is outside current region." I don't understand
why this is since the soil map is much larger than the DEMs and I used
'g.region vect=soils' to set the size.

   Another question is how I can expand the region to add a DEM immediately
below the one on the attached map. The eastern edge of the DEM is beyond the
limit of the soil map.

   Learning more about manipulating regions while assembling project maps
will help me now and in the future. Pointers to more resources for me to
read will be very helpful.

Rich

(attachments)

screenshot.png

If I understand, you have DEM tiles in one projection (location) and you’re trying to use r.proj to transform the tiles into a different location.
If that’s the case, typically you would use the r.proj flag ‘-g’ to get the region settings in the target location from the raster extent in it’s source location. So you might do something like:
g.region -p r.proj -g loc= map= input=``

then run r.proj without the -g flag and you should get the reprojected raster.

Finally, once you have all the tiles reprojected, use
g.list raster pattern=<....> sep=comma
to get a list of all the tiles, then g.region -p rast=<list of tiles>
to set the computational region to cover all tiles.

One additional point: consider to patch all DEM tiles together in their native projection first then project the single patched DEM once to the target projection.

Regards,
Micha

···

On 07/06/2018 08:25 PM, Rich Shepard wrote:

I am trying to add additional DEM maps to the project location. There is
one DEM overlaid on a soil mapping unit map for the county in the attached
screenshot. My reading of the g.region manual page did not let me find the
answers I need.

The computational region is set to the soil map. Attempting to re-project
the DEM to the immediate west of the existing one fails; grass7.5svn tells
me, “ERROR: Input raster map is outside current region.” I don’t understand
why this is since the soil map is much larger than the DEMs and I used
‘g.region vect=soils’ to set the size.

Another question is how I can expand the region to add a DEM immediately
below the one on the attached map. The eastern edge of the DEM is beyond the
limit of the soil map.

Learning more about manipulating regions while assembling project maps
will help me now and in the future. Pointers to more resources for me to
read will be very helpful.

Rich

_______________________________________________
grass-user mailing list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[https://lists.osgeo.org/mailman/listinfo/grass-user](https://lists.osgeo.org/mailman/listinfo/grass-user)
-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918

On Sat, 7 Jul 2018, Micha Silver wrote:

If I understand, you have DEM tiles in one projection (location) and
you're trying to use r.proj to transform the tiles into a different
location. If that's the case, typically you would use the r.proj flag '-g'
to get the region settings in the target location from the raster extent
in it's source location. So you might do something like: g.region -p
`r.proj -g loc=<source location> map=<source mapset> input=<source dem>`

Micha,

   I have no problems using r.proj to transform the DEMs from one location to
another one. My question is why, when g.region is set to that of a
county-wide vector map I cannot load a newly re-projected DEM that is the
immediate neighbor of another DEM and both are within the county boundary
and, assumably, in the same region. I don't understand how a raster map's
region can change so drastically when reprojected from one location to
another one.

Finally, once you have all the tiles reprojected, use g.list raster
pattern=<....> sep=comma to get a list of all the tiles, then g.region -p
rast=<list of tiles> to set the computational region to cover all tiles.

   This assumes I can display the second tile. When I get that working I'll
do this, but the county vector map's region should certainly encompass both.

One additional point: consider to patch all DEM tiles together in their
native projection *first* then project the single patched DEM once to the
target projection.

   This would be a good idea, and I think I did this many years ago. But,
when I read the r.patch manual page I see that it uses file B to fill in
null cells in file A. What I want to do is join them by a common border,
like laying tiles on a floor. If there's a r.patch option for this I've not
recognized it, and I don't see another r.* module for assembling adjacent
raster maps into a single one.

Best regards,

Rich

On Sat, Jul 7, 2018 at 10:51 PM, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Sat, 7 Jul 2018, Micha Silver wrote:

...

One additional point: consider to patch all DEM tiles together in their
native projection *first* then project the single patched DEM once to the
target projection.

  This would be a good idea, and I think I did this many years ago. But,
when I read the r.patch manual page I see that it uses file B to fill in
null cells in file A. What I want to do is join them by a common border,
like laying tiles on a floor. If there's a r.patch option for this I've not
recognized it, and I don't see another r.* module for assembling adjacent
raster maps into a single one.

r.patch does exactly that, no flags needed.

g.region raster=map1,map2,... -p
r.patch input=map1,map2,... output=map_mosaic

HTH,
Markus

On Sun, 8 Jul 2018, Markus Neteler wrote:

r.patch does exactly that, no flags needed.

g.region raster=map1,map2,... -p
r.patch input=map1,map2,... output=map_mosaic

Markus,

   I _thought_ that r.patch would do the job yet did not get this from
reading the manual page. The description and example show cell-by-cell
combinations, not tiling two or more rasters. The keywords include
'mosaicking' but neither the blurb after the module name nor the description
include this ability. However, the first Note tells me, "Frequently, this
program is used to patch together adjacent map layers which have been
digitized separately. The program v.mkgrid can be used to make adjacent maps
align neatly." and I admit to not reading the notes before now, having not
seen mention of mosaicking in the module synopsis or description.

Many thanks for clarifying,

Rich

On Sun, 8 Jul 2018, Markus Neteler wrote:

r.patch does exactly that, no flags needed.

Markus,

   A related issue: when I want to reproject raster DEMs from their source
location to a common target location r.proj fails because the source's
region is outside the target's region. How this can be makes no sense as the
target's region is an entire state and the DEMs are 7.5' topographic quads.
But, that's what r.proj tells me.

   I've not found how to resolve this issue.

   Example: the target location's (OR) default region is:

g.region -l
north-west corner: long: 125:01:06.208515W lat: 46:54:29.991261N
north-east corner: long: 115:30:24.620534W lat: 46:53:20.948674N
south-east corner: long: 116:00:36.987691W lat: 40:41:04.56057N
south-west corner: long: 124:33:45.521802W lat: 40:42:06.559349N
center longitude: 120:16:28.077102W
center latitude: 43:53:09.60569N
rows: 691017
cols: 724617

g.region -p
projection: 99 (unnamed)
zone: 0
datum: ** unknown (default: WGS84) **
ellipsoid: grs80
north: 369907.96287773
south: -321108.56796525
west: 2155817.84893823
east: 2880434.93778086
nsres: 0.99999932
ewres: 1.00000012
rows: 691017
cols: 724617
cells: 500722665489

and a source's smaller region (Elwood) is:

g.region -l
north-west corner: long: 122:22:30.177355W lat: 45:14:59.998015N
north-east corner: long: 122:15:00.21557W lat: 45:15:07.129823N
south-east corner: long: 122:14:59.838614W lat: 45:14:54.839228N
south-west corner: long: 122:22:29.773496W lat: 45:14:47.707842N
center longitude: 122:18:45.005157W
center latitude: 45:14:57.48019N
rows: 415
cols: 10732

g.region -p
projection: 99 (unnamed)
zone: 0
datum: ** unknown (default: WGS84) **
ellipsoid: grs80
north: 582841.5
south: 581596.5
west: 7719262.5
east: 7751458.5
nsres: 3
ewres: 3
rows: 415
cols: 10732
cells: 4453780

   I need to understand why r.proj fails and how I can fix these situations.

Best regards,

Rich

On Sun, Jul 8, 2018 at 12:41 AM, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Sun, 8 Jul 2018, Markus Neteler wrote:

r.patch does exactly that, no flags needed.

g.region raster=map1,map2,... -p
r.patch input=map1,map2,... output=map_mosaic

Markus,

  I _thought_ that r.patch would do the job yet did not get this from
reading the manual page. The description and example show cell-by-cell
combinations, not tiling two or more rasters. The keywords include
'mosaicking' but neither the blurb after the module name nor the description
include this ability.

Now it does. I tweaked the intro a bit.

Markus

On Sun, 8 Jul 2018, Markus Neteler wrote:

Now it does. I tweaked the intro a bit.

Markus,

   Thanks once again.

Best regards,

Rich

On Sun, Jul 8, 2018 at 1:41 AM, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Sun, 8 Jul 2018, Markus Neteler wrote:

r.patch does exactly that, no flags needed.

Markus,

A related issue: when I want to reproject raster DEMs from their source
location to a common target location r.proj fails because the source’s

region is outside the target’s region.

The source’s region does not matter, what matters are the extents of the source raster map.

How this can be makes no sense as the
target’s region is an entire state and the DEMs are 7.5’ topographic quads.
But, that’s what r.proj tells me.

I’ve not found how to resolve this issue.

Apparently the input raster, when reprojected to the current region in the location/mapset, does not overlap with the current region.

You can check the reprojected extents of the input raster with r.proj -g.

Markus M

Example: the target location’s (OR) default region is:

g.region -l
north-west corner: long: 125:01:06.208515W lat: 46:54:29.991261N
north-east corner: long: 115:30:24.620534W lat: 46:53:20.948674N
south-east corner: long: 116:00:36.987691W lat: 40:41:04.56057N
south-west corner: long: 124:33:45.521802W lat: 40:42:06.559349N
center longitude: 120:16:28.077102W
center latitude: 43:53:09.60569N
rows: 691017
cols: 724617

g.region -p
projection: 99 (unnamed)
zone: 0
datum: ** unknown (default: WGS84) **
ellipsoid: grs80
north: 369907.96287773
south: -321108.56796525
west: 2155817.84893823
east: 2880434.93778086
nsres: 0.99999932
ewres: 1.00000012
rows: 691017
cols: 724617
cells: 500722665489

and a source’s smaller region (Elwood) is:

g.region -l
north-west corner: long: 122:22:30.177355W lat: 45:14:59.998015N
north-east corner: long: 122:15:00.21557W lat: 45:15:07.129823N
south-east corner: long: 122:14:59.838614W lat: 45:14:54.839228N
south-west corner: long: 122:22:29.773496W lat: 45:14:47.707842N
center longitude: 122:18:45.005157W
center latitude: 45:14:57.48019N
rows: 415
cols: 10732

g.region -p
projection: 99 (unnamed)
zone: 0
datum: ** unknown (default: WGS84) **
ellipsoid: grs80
north: 582841.5
south: 581596.5
west: 7719262.5
east: 7751458.5
nsres: 3
ewres: 3
rows: 415
cols: 10732
cells: 4453780

I need to understand why r.proj fails and how I can fix these situations.

Best regards,

Rich


grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

On Mon, 9 Jul 2018, Markus Metz wrote:

The source's region does not matter, what matters are the extents of the
source raster map.

Markus,

   I should have remembered that they're different.

Apparently the input raster, when reprojected to the current region in the
location/mapset, does not overlap with the current region.

You can check the reprojected extents of the input raster with r.proj -g.

   This I did:

r.proj loc=elwood map=PERMANENT in=elwood_dem2013 -g
WARNING: Input and output locations are the same
Input map <elwood_dem2013@PERMANENT> in location <elwood>:
n=1281118.49999997 s=1235035.49999995 w=828457.49999998 e=861685.49999999 rows=15361 cols=11076

   Then I followed the 'box' map method of setting the target region as shown
in the manual page's Notes, paragraph 4:

# In source location:

v.in.region -d out=elwood_region

# In target location:

v.proj in=elwood_region loc=elwood map=PERMANENT out=elwood_reproj

g.region -g
projection=99
zone=0
n=201663.78224162
s=137006.09426117
w=2314182.92402788
e=2388673.19838691
nsres=0.99999517
ewres=1.00000368
rows=64658
cols=74490
cells=4816374420

g.region vect=elwood_reproj res=1 -a

r.proj loc=elwood map=PERMANENT in=elwood_dem2013 res=1 method=lanczos
ERROR: Input raster map is outside current region

   Please point out what I missed or did incorrectly.

Best regards,

Rich

On Mon, Jul 9, 2018 at 6:11 PM, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Mon, 9 Jul 2018, Markus Metz wrote:

The source’s region does not matter, what matters are the extents of the
source raster map.

Markus,

I should have remembered that they’re different.

Apparently the input raster, when reprojected to the current region in the
location/mapset, does not overlap with the current region.

You can check the reprojected extents of the input raster with r.proj -g.

This I did:

r.proj loc=elwood map=PERMANENT in=elwood_dem2013 -g
WARNING: Input and output locations are the same
Input map elwood_dem2013@PERMANENT in location :
n=1281118.49999997 s=1235035.49999995 w=828457.49999998 e=861685.49999999 rows=15361 cols=11076

Then I followed the ‘box’ map method of setting the target region as shown
in the manual page’s Notes, paragraph 4:

In source location:

first set the region to match the raster:

g.region raster=elwood_dem2013

now proceed as before:

v.in.region -d out=elwood_region

In target location:

v.proj in=elwood_region loc=elwood map=PERMANENT out=elwood_reproj

g.region -g
projection=99
zone=0
n=201663.78224162
s=137006.09426117
w=2314182.92402788

e=2388673.19838691

this:

nsres=0.99999517

ewres=1.00000368

is probably not what you want, it is recommended to align the region to exactly 1 map unit:
g.region -p -a res=1
before reprojection

rows=64658
cols=74490
cells=4816374420

g.region vect=elwood_reproj res=1 -a

r.proj loc=elwood map=PERMANENT in=elwood_dem2013 res=1 method=lanczos
ERROR: Input raster map is outside current region

Please point out what I missed or did incorrectly.

You should notice a difference when using the suggested g.region calls.

Markus M

Best regards,

Rich


grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

On Mon, 9 Jul 2018, Markus Metz wrote:

first set the region to match the raster:
g.region raster=elwood_dem2013
now proceed as before:

Markus,

   Okay. I thought the vector box matched that of the raster. I'll make that
change.

this:

nsres=0.99999517
ewres=1.00000368

is probably not what you want, it is recommended to align the region to
exactly 1 map unit:
g.region -p -a res=1
before reprojection

   I think this is what I did:

g.region vect=elwood_reproj res=1 -a
r.proj loc=elwood map=PERMANENT in=elwood_dem2013 res=1 method=lanczos

You should notice a difference when using the suggested g.region calls.

   I'll set the source region to the raster map prior to creating the vector
box. Will post results.

Thanks,

Rich

On Mon, 9 Jul 2018, Rich Shepard wrote:

I'll set the source region to the raster map prior to creating the vector
box. Will post results.

   That made all the difference. Perhaps the example ("v.in.region method")
can have this added at the top so it reads,

# In the source location, use v.in.region to generate a bounding box around the
# region of interest:

g.region rast=<user1>
v.in.region -d output=bounds type=area

Thanks for pointing this out to me,

Rich