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.
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
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
?
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.
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.
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.
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.
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.
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.
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.