Geography Reference
In-Depth Information
will have a value of 1. When we get to the final step, this will cause
every cell in our DRG outside the bounds of ancb8_itma to be set to
null, effectively stripping the collars.
We are now ready to actually do the clipping operation. First we set the
GRASS region to that or our ancb8_collars DRG:
g.region rast=ancb8_collars
We then use the ancb8_itma raster we created from our vector quadran-
gle boundary as a mask:
g.copy ancb8_itma,MASK
Now that the mask is set, we use a very simple bit of map algebra to
create the clipped DRG:
r.mapcalc ancb8=ancb8_collars
Notice the r.mapcalc operation looks like it just creates a new raster
from every cell in our original DRG. The magic is in the mask, which
controls which cells in the new raster are set to the same values as
those in the original. Cells outside the mask are set to null. The last
step is to remove the mask:
g.remove MASK
Repeating the process for the adjacent DRG (ANCB7) gives us two ras-
ters that we can now display seamlessly, as shown in Figure 10.7 , on
the next page. Comparing this to what we started with in Figure 10.6 ,
on page 167 , you can see that we have attained success. If we wanted
to, we could combine the DRGs into a single raster using r.patch , sim-
ilar to the method described in Section 10.5 , Merging Digital Elevation
Models, on page 164 .
To put it all together, the sequence of commands we used to get from
overlapping to seamless nirvana is shown here in the form of a bash
script:
# import the DRG
r. in .gdal input=i61149c6_albers.tif output=ancb8_collars
# Extract the quad boundary from the boundary map
v.extract input=itma output=ancb8 where="TILE_NAME='ANCB8'"
# Convert the extracted vector quad feature to a raster map
v.to.rast input=ancb8 output=ancb8_itma use=val
# Set the region to operate on to that of our DRG
g.region rast=ancb8_collars
# Set the mask for the operation to the raster created from the
# quad boundary vector
g.copy ancb8_itma,MASK
 
Search WWH ::




Custom Search