[GRASS-user] r.region for intersection with vector map?

   I've used v.overlay for its set intersection ability to save features only
within the boundary of another vector map. Can I use r.region to do the same
operation on raster maps?

   Specifically, I have two huge (about 51G each) DEM maps and I need only
the region within the project's analytical boundary. The analytical boundary
is a vector polygon map.

   If I run

   r.region map=dem_east vect=analytical_boundary

the raster map's region is that of the vector map. But, I don't believe that
this removes all cells beyond that region.

   Advice on how to eliminate the extraneous cells (and clip the raster to
the nearest cell boundaries of the vector map) is greatly appreciated.

TIA,

Rich

> Advice on how to eliminate the extraneous cells (and clip the raster to

the nearest cell boundaries of the vector map) is greatly appreciated.

see http://grass.osgeo.org/grass64/manuals/html64_user/g.region.html

align=name
    Adjust region cells to cleanly align with this raster map

vect=name[,name,...]
    Set region to match this vector map

to set the region boundary to your analytical vector: i.e.

g.region -a rast=dem_east vect=analytical_boundary align=dem_east

then r.mapcalc "dem_east_vect_analytical_boundary = dem_east"

?
Helmut

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/r-region-for-intersection-with-vector-map-tp4567643p4567694.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On 11/03/2012 17:35, Rich Shepard wrote:

If I run

r.region map=dem_east vect=analytical_boundary

Try: g.region vect=analytical_boundary

the raster map's region is that of the vector map. But, I don't believe
that this removes all cells beyond that region.

Advice on how to eliminate the extraneous cells (and clip the raster to
the nearest cell boundaries of the vector map) is greatly appreciated.

To be honest: until 5 minutes ago, I didn't even know that r.region existed. I thought you made a typo. As I don't understand what r.region is good for: I would use g.region as already said, then followed by:

r.mapcalc small_dem_east = dem_east

You could then remove dem_east, if you'd never need any DEM values outside analytical_boundary

Hermann

As I don't understand what r.region
is good for:

r.region sets the extent/boundary definition of the whole raster, but no
"clipping" to any region defined by g.region is done

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/r-region-for-intersection-with-vector-map-tp4567643p4567765.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Wouldn’t the simpledt be to convert the vector to a raster named MASK, then r.mapcalc analyticalrast=dem will give you a raster only in the analytical region
?


Micha Silver
052-366-5918

-----Original message-----

From: Rich Shepard rshepard@appl-ecosys.com
To: grass-users@lists.osgeo.org
Sent: Sun, 11 Mar 2012, 18:35:50 GMT+02:00
Subject: [GRASS-user] r.region for intersection with vector map?

I’ve used v.overlay for its set intersection ability to save features only
within the boundary of another vector map. Can I use r.region to do the same
operation on raster maps?

Specifically, I have two huge (about 51G each) DEM maps and I need only
the region within the project’s analytical boundary. The analytical boundary
is a vector polygon map.

If I run

r.region map=dem_east vect=analytical_boundary

the raster map’s region is that of the vector map. But, I don’t believe that
this removes all cells beyond that region.

Advice on how to eliminate the extraneous cells (and clip the raster to
the nearest cell boundaries of the vector map) is greatly appreciated.

TIA,

Rich


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

This mail was received via Mail-SeCure System.

On Sun, 11 Mar 2012, Helmut Kudrnovsky wrote:

align=name
   Adjust region cells to cleanly align with this raster map
to set the region boundary to your analytical vector: i.e.
g.region -a rast=dem_east vect=analytical_boundary align=dem_east

Helmut,

   I read about align on the man page but thought it required a raster map
different from the one being clipped. This is good to know!

then r.mapcalc "dem_east_vect_analytical_boundary = dem_east"

   Ah-ha! I wondered if r.mapcalc was the appropriate tool.

Thanks,

Rich

On Sun, 11 Mar 2012, Hermann Peifer wrote:

Try: g.region vect=analytical_boundary

To be honest: until 5 minutes ago, I didn't even know that r.region
existed. I thought you made a typo. As I don't understand what r.region
is good for: I would use g.region as already said, then followed by:

Hermann,

   I've not closely examined r.region to understand how it differs from
g.region. But, wanting a module to calculate the intersection ('AND') of a
raster map and a vector map, I looked in the raster command list. :slight_smile:

r.mapcalc small_dem_east = dem_east

You could then remove dem_east, if you'd never need any DEM values outside analytical_boundary

   I suppose that both r.region and g.region will work.

   I just bought a 3T Seagate external hard drive having USB3 capabilities.
As soon as the adapter cards arrive I'll back up both large DEM maps (about
102G of data) just so I don't need to download or reproject them in the
future if the project analytical area expands.

   Thanks much.

Rich

On Sun, 11 Mar 2012, Micha Silver wrote:

Wouldn't the simpled be to convert the vector to a raster named MASK, then r.mapcalc analyticalrast=dem will give you a raster only in the analytical region?

Micha,

   Could be. Not having need to do this clipping of a raster map prior to
this I was unfamiliar with the options for accomplishing the task.

Toda,

Rich

   I suppose that both r.region and g.region will work.

g.region and r.region are different tools:

g.region - Manages the boundary definitions for the geographic region.
(http://grass.osgeo.org/grass64/manuals/html64_user/g.region.html)

r.region - Sets the boundary definitions for a raster map.
(http://grass.osgeo.org/grass64/manuals/html64_user/r.region.html)

g.region sets the extent of the mapset (i.e. for raster calculations), but
r.region defines the extent of the whole raster map.

IMHO g.region is the choice ...

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/r-region-for-intersection-with-vector-map-tp4567643p4568495.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On 12/03/2012 00:16, Helmut Kudrnovsky wrote:

but r.region defines the extent of the whole raster map.

Why would one want to do this, compared to leaving the extent as detected during import?

Hermann

On 12/03/12 05:57, Hermann Peifer wrote:

On 12/03/2012 00:16, Helmut Kudrnovsky wrote:

but r.region defines the extent of the whole raster map.

Why would one want to do this, compared to leaving the extent as
detected during import?

Use cases might be:

- the file you import is not georeferenced, but you have elsewhere the information about where the corners should be

- your file was incorrectly georeferenced with a constant shift

And probably others...

Moritz

On 12/03/2012 10:13, Moritz Lennert wrote:

On 12/03/12 05:57, Hermann Peifer wrote:

On 12/03/2012 00:16, Helmut Kudrnovsky wrote:

but r.region defines the extent of the whole raster map.

Why would one want to do this, compared to leaving the extent as
detected during import?

Use cases might be:

- the file you import is not georeferenced, but you have elsewhere the
information about where the corners should be

- your file was incorrectly georeferenced with a constant shift

And probably others...

Aha. Thanks.

I usually fix this type of issues (if any) before importing, by gdal_translate'ing the source file int vrt format which has the correct corners, etc., then I import the vrt file.

Hermann

On Sun, 11 Mar 2012, Helmut Kudrnovsky wrote:

g.region sets the extent of the mapset (i.e. for raster calculations), but
r.region defines the extent of the whole raster map.

IMHO g.region is the choice ...

Helmut,

   Thanks for the clarification.

Rich

On Sun, 11 Mar 2012, Hermann Peifer wrote:

r.mapcalc small_dem_east = dem_east

Herman,

   The map names have changed, but the issue remains unresolved.

   After setting g.region with both the raster dem and vector basins map (the
drainage basins are the analytical area), I ran,

   r.mapcalc "dem_basin = dem"

yet the raster map display is not limited to the drainage basins, but to a
square area that just includes the basins. I assume the reason is that the
region is a square. What command could I pass to r.mapcalc that would clip
the raster map to the basins themselves (with some overlap so whole cells of
the raster map form the edge)? Screenshot attached.

Rich

(attachments)

screenshot.png

On 14/03/2012 19:02, Rich Shepard wrote:

I assume the reason is that the region is a square.

Indeed.

What command could I pass to r.mapcalc that would clip
the raster map to the basins themselves

Define a MASK before running r.mapcalc
http://grass.osgeo.org/grass64/manuals/html64_user/r.mask.html

Hermann

On Wed, 14 Mar 2012, Hermann Peifer wrote:

Define a MASK before running r.mapcalc
http://grass.osgeo.org/grass64/manuals/html64_user/r.mask.html

Hermann,

   Duh! Of course!

Thanks,

Rich