[GRASS5] Question on resolution

Glynn Clements glynn at gclements.plus.com
Tue Nov 2 00:10:09 EST 2004


Sharyn Namnath wrote:

> I have a question on the ewres & nsres values. I'm not clear on what they
> represent

They determine the resolution at which raster processing operations
are performed.

Unless a program explicitly sets a different resolution, any raster
maps which it creates will have the extent and resolution (and hence
the row/column dimensions) of the current region, and any maps which
it reads will be automatically resampled to the region's resolution,
and will be automatically cropped and/or padded with nulls to match
the region's extent.

> and if they correspond to the dpi of the created PNG file.

Yes and no.

When d.rast reads the map, it will automatically be resampled
according to the current region settings. The data will be supplied as
a 2-dimensional array, one row at a time. The dimensions (number of
rows and columns) will match the rows: and cols: values displayed by
"g.region -p". Those values are obtained by dividing the region's
extent (north - south and east - west) by the nsres and ewres values
so, if you reduce the resolution, the array will have more rows and
columns

The preceding paragraph is true for most raster (r.*) programs, except
for a few which explicitly set the region to something else (e.g. the
extent and resolution of the input map).

In addition to the automatic resampling, d.rast itself resamples the
data according to the dimensions of the monitor, so that the current
region exactly fits within the monitor, but preserving the aspect
ratio of the cells. If the aspect ratio of the current region doesn't
match that of the monitor, you will get blank bands on either the left
and right or the top and bottom of the monitor.

Consequently, the overall resolution is limited by the resolution of
the original raster, the resolution of the current region, and by the
size of the monitor. If the resolution of the current region is equal
to or better (i.e. smaller cell size) than that of the original
raster, then and the size of the monitor (in pixels) is greater than
the size of the original raster, then the no loss of resolution will
occur.

> I'm
> creating a 1024 x 512 file for display, but I am trying to figure out the
> optimum nsres & ewres values to set my region with (using g.region) so that
> the rasterization (d.rast) is as fast as possible.  I'm pretty new at this
> so I'm still muddling about..

The resolution of the current region won't have any effect upon
*efficiency*, as neither the core raster input code nor d.rast handle
special cases (e.g. 1:1 or integral scale factors) differently.

In terms of overall performance, fewer cells will result in faster
rendering, but worse performance. I suspect that the best balance
between performance and quality will be obtained by setting the
region's resolution to match either the dimensions of the monitor or
the resolution of the raster.

Using a resolution which is higher than either of these will result in
an increase in processor/memory/disk overhead without any increase in
quality. OTOH, setting a lower resolution will reduce the overhead but
will also reduce the quality (in general, this is the main reason for
being able to choose the resolution, i.e. so that calculations don't
take forever and maps don't fill up the hard disk).

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list