[GRASS-user] raster data to ascii

Hi,

I have another question regarding raster data.
I have some raster data on a 1000x1000 grid. I would like to export it with various gridspacings, for ex. 500x500 or 200x500.
I'm bit lost between r.statsm r.out.ascii, the interpolation methods and r.resample.
Either I don't get an ascii output, or I can't change the resolution..

Any help is welcome :-).

Thanks again,

Martina

Martina Schaefer wrote:

I have another question regarding raster data.
I have some raster data on a 1000x1000 grid. I would like to export it
with various gridspacings, for ex. 500x500 or 200x500.
I'm bit lost between r.statsm r.out.ascii, the interpolation methods and
r.resample.
Either I don't get an ascii output, or I can't change the resolution..

r.out.ascii exports the data after it has been resampled according to
the current region. IOW, the output will have as many rows and columns
as the current region.

If you wish the output data to be resampled by nearest-neighbour, you
can just change the region resolution with g.region then use
r.out.ascii.

If you want some other form of resampling, first change the region,
then explicitly resample the map with e.g. r.resamp.interp or
r.resamp.stats, then export the resampled map with r.out.ascii.

r.resample makes a direct copy of its input, resampled using GRASS'
built-in nearest-neighbour resampling, so r.resample only has limited
utility.

[AFAICT, it's primary use is to reduce disk space and/or CPU usage. If
you will be reading a map repeatedly at a significantly reduced
resolution, using a resampled copy may be faster than having GRASS
continually resample the higher resolution version.]

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

Glynn:

r.resample makes a direct copy of its input, resampled using GRASS'
built-in nearest-neighbour resampling, so r.resample only has limited
utility.

[AFAICT, it's primary use is to reduce disk space and/or CPU usage. If
you will be reading a map repeatedly at a significantly
reduced resolution, using a resampled copy may be faster than
having GRASS continually resample the higher resolution version.]

there is a question in the wiki about GRASS 7 development:
to remove r.resample (as redundant) or not?
thoughts?

Hamish

Hamish wrote:

> r.resample makes a direct copy of its input, resampled using GRASS'
> built-in nearest-neighbour resampling, so r.resample only has limited
> utility.
>
> [AFAICT, it's primary use is to reduce disk space and/or CPU usage. If
> you will be reading a map repeatedly at a significantly
> reduced resolution, using a resampled copy may be faster than
> having GRASS continually resample the higher resolution version.]

there is a question in the wiki about GRASS 7 development:
to remove r.resample (as redundant) or not?
thoughts?

It may as well stay. Although you can get exactly the same result
using "r.mapcalc newmap = oldmap", r.resample is potentially more
straightforward (it uses G_parser(), with explicit input= and output=
options), and it's useful as an example r.* module.

["r.resamp.interp method=nearest" could theoretically give slightly
different results due to differences in rounding errors. r.resample
has the advantage that it's guaranteed to act as an "identity"
operation.]

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

Hi,

thanks for your answer to my raster/ascii questions and sorry for the late replay, I had to move to something else for a moment (deadline for corrections to a paper) and then I was a bit playing around with the commands you showed me.

g.region followed by r.stats or r.out.ascii does indeed what I was looking for, but in my Map Display window is still written the old resolution and I think the map is also drawn with the old resolution. Is there a possibility to do these?
In fact, the simple resampling with the nearest-neighbour is probably not good enough, so I was trying r.surf.idw as I can't make your commands r.resamp work, and I would like to visualize my interpolation without each time exporting to ascii and visualizing with another program!

Is there also a possibility to save the data with the new resolution, so that I don't have to do it each time?

And, one last question, I have three sets of raster data of the same region (ice thickness, bedrock and surface elevation of a glacier). How can I get them into the same grass LOCATION? I would like to have access to them at the same time and also make some simple operations like for example the difference of two of the datasets!

Thanks again for your help!

Martina

If you wish the output data to be resampled by nearest-neighbour, you
can just change the region resolution with g.region then use
r.out.ascii.

If you want some other form of resampling, first change the region,
then explicitly resample the map with e.g. r.resamp.interp or
r.resamp.stats, then export the resampled map with r.out.ascii.

r.resample makes a direct copy of its input, resampled using GRASS'
built-in nearest-neighbour resampling, so r.resample only has limited
utility.

[AFAICT, it's primary use is to reduce disk space and/or CPU usage. If
you will be reading a map repeatedly at a significantly reduced
resolution, using a resampled copy may be faster than having GRASS
continually resample the higher resolution version.]

Martina Schaefer wrote:

thanks for your answer to my raster/ascii questions and sorry for the
late replay, I had to move to something else for a moment (deadline for
corrections to a paper) and then I was a bit playing around with the
commands you showed me.

g.region followed by r.stats or r.out.ascii does indeed what I was
looking for, but in my Map Display window is still written the old
resolution and I think the map is also drawn with the old resolution. Is
there a possibility to do these?

The GUI has its own set of region settings, so you need to change the
region from within the GUI to affect how a map is displayed within the
GUI.

Or you can explicitly resample the map with r.resamp, r.resamp.interp,
or r.resamp.stats, then display the resampled map in the GUI.

In fact, the simple resampling with the nearest-neighbour is probably
not good enough, so I was trying r.surf.idw as I can't make your
commands r.resamp work,

Which version of GRASS are you using? r.resamp.interp and
r.resamp.stats aren't present in 6.2.3, only in 6.3.x.

and I would like to visualize my interpolation
without each time exporting to ascii and visualizing with another program!

You can view the resampled maps in the GUI, or with d.rast.

Is there also a possibility to save the data with the new resolution, so
that I don't have to do it each time?

Explicitly resampling the data will create a new map.

And, one last question, I have three sets of raster data of the same
region (ice thickness, bedrock and surface elevation of a glacier). How
can I get them into the same grass LOCATION? I would like to have access
to them at the same time and also make some simple operations like for
example the difference of two of the datasets!

Data is normally imported into the current location, unless you
explicitly import into a new location with e.g. r.in.gdal's location=
option.

If the rasters have different projections, you will need to import
each one into a separate location, then switch to the target location
and re-project the data with r.proj.

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

Hi again and thanks for the answer!

The GUI has its own set of region settings, so you need to change the
region from within the GUI to affect how a map is displayed within the
GUI.

I changed this with GIS Manager -> Config -> Region -> Region, but I don't have the impression that this changes anything!

Or you can explicitly resample the map with r.resamp, r.resamp.interp,
or r.resamp.stats, then display the resampled map in the GUI.

Ok, that works, but then the display always stays with this resolution, even if I open other maps later!

Which version of GRASS are you using? r.resamp.interp and
r.resamp.stats aren't present in 6.2.3, only in 6.3.x.

It's only 6.2.2.

Data is normally imported into the current location, unless you
explicitly import into a new location with e.g. r.in.gdal's location=
option.
If the rasters have different projections, you will need to import
each one into a separate location, then switch to the target location
and re-project the data with r.proj.

No, these are the same projections, so it worked easy and I even could do my simple operations between the different raster maps.

Thanks again,

  Martina