[GRASSLIST:6193] Re: Clip a Raster

Glynn Clements glynn.clements at virgin.net
Wed May 7 05:57:52 EDT 2003


Laurent BESSON wrote:

> > > I am new user to Grass and GIS. I would like to clip(crop) a raster so that I 
> > > can extract a smaller map from a larger area where I want to focus the 
> > > analysis. I highly appreciate anyone directing me ragarding the command that 
> > > can be used to do that.
> > 
> > Almost all raster commands do this automatically. GRASS raster
> > commands normally operate upon the current region, which can be set
> > and queried using g.region.
> > 
> > Any maps which are created have their bounds and resolution determined
> > by the current region; any maps which are read are automatically
> > cropped, padded (with nulls) and/or resampled according to the current
> > region settings.
> 
> However, if you want only a raster map on the current region, after doing 
> a g.region, you do a: r.mapcalc "new_map=old_map"
> 
> This will crop old_map to the region and store it into new_map

You can also use r.resample, which is intended for this purpose. 
Although, when the expression is a single map, r.mapcalc now does most
of what r.resample does; i.e. it will copy the categories, colour
table and history. However, unlike r.mapcalc, r.resample will "crop"
the category list and colour table to include only those categories
which actually occur in the output map.

However, just because you can produce a cropped map, it doesn't follow
that you should (the original poster may have been assuming that it
was necessary to generate a new map, when usually it isn't). Where
possible, you should just modify the region settings and use the
original map.

Whenever you generate a new map, you may lose information and/or
accuracy, but you will never gain them. In particular, if you resample
a map which was generated by resampling another map, the end result
will be less accurate than if you were to resample the original map.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-user mailing list