[GRASS5] New bash scripts for vector and raster processing

Hello,

I have written two scripts that are related to vector and raster maps.

The first, v.group, works similarly to v.reclass, but will reclassify on
multiple columns of types that aren't just int. It can, for example,
reclassify a land use map with a separate category for each feature to a
category for each combination of jurisdiction, owner, and manging agency:

v.group input=messylanduse output=landuse columns=jurisdiction,owner,manager

http://www.shockfamily.net/cedric/grass/v.group

There are a couple of issues with this; the type definitions of the columns
are not preserved (I wasn't sure how to get the type definitions from the old
table) and it does not alter the history of the output map to explain what
has been done (What is the correct way to do that?)

The second script produces tilings for relating one projection to raster
regions in another. This is useful when requesting data from WMS servers and
in other network data operations. The script only produces descriptions
(bounding box in source, rows, and columns) of the tiles, and only for those
tiles overlapping the current region. It uses the current region as the
bounds and desired resolution for the requested data.

r.tileset sourceproj="+init=epsg:4326"

http://www.shockfamily.net/cedric/grass/r.tileset

This script has a number of small issues:
* It doesn't know about meridians of projections. (I assume the C
implementations of bounding box code do unlike my little bash functions.
Would hopping languages solve this?)
* Does not generate optimal (smallest request) tilings. In degenerate cases
involving latitude longitude source data up to twice as much as necessary may
be requested; degenerate cases of other projections (poles of cylindricals
and opposing sides of conics diverge) can be worse. In the regions I've tried
it's about 1% unnecessary overhead. If you need optimal tilings ask; I can
add that feature.
* The aspect ratios of the tiles aren't tailored to the destination region.
Near the critical points of a projection the images can be quite strange. Not
a problem for grass, but some map servers don't like handing out images with
very different horizontal and vertical resolutions. "Solved" by optimal
tilings, assuming your chosen coordinate system is appropriate for the data
handled.
* It does not produce bounding box independent tilings. These are useful when
caching data so as to avoid requesting it again (like virtual globes do). I
don't imagine grass users wanting this. This is fairly easy to do, especially
once optimal tilings are in place. If you have a need for it ask. These
tilings usually add another column and row of tiles to requests.
* It does not produce resolution independent tilings. This is an orthogonal
problem, so it's not very important, and also quite easy to solve.
* It takes about a second per tile on my clunky machine, since it runs cs2cs
four times per tile.

--Cedric Shock

Hi Cedric,

On Monday 06 March 2006 08:08, Cedric Shock wrote:

Hello,

I have written two scripts that are related to vector and raster maps.

The second script produces tilings for relating one projection to raster
regions in another. This is useful when requesting data from WMS servers and
in other network data operations. The script only produces descriptions
(bounding box in source, rows, and columns) of the tiles, and only for those
tiles overlapping the current region. It uses the current region as the
bounds and desired resolution for the requested data.

r.tileset sourceproj="+init=epsg:4326"

http://www.shockfamily.net/cedric/grass/r.tileset

Many thanks for your work! This script is absolutely great for tiling support in r.in.onearth.
I have updated r.in.onearth, it uses your script for tile calculation now.
A tile support prototype of the script is available here (r.tileset must be in your path),
its good for testing r.tileset :wink:

http://www-pool.math.tu-berlin.de/~soeren/grass/modules/r.in.onearth

But i'm not sure if i use r.tileset correctly within r.in.onearth? The tiles i produce dont fit the region correctly.
Take a look at these screenshots:

http://www-pool.math.tu-berlin.de/~soeren/grass/modules/screenshots/r.in.onearth.tiles_1.png
http://www-pool.math.tu-berlin.de/~soeren/grass/modules/screenshots/r.in.onearth.tiles_2.png
http://www-pool.math.tu-berlin.de/~soeren/grass/modules/screenshots/r.in.onearth.tiles_3.png

This data was generated within the default spearfish60 region with different maxrows and maxcols settings:

samples:
g.region -d
r.in.onearth -l tmband=Red output=Test1 maxrows=200 maxcols=300
r.in.onearth -l tmband=Red output=Test2 maxrows=150 maxcols=300
r.in.onearth -l tmband=Red output=Test3 maxrows=1100 maxcols=110

If only one tile is calculated by r.tileset, the bounding box is correct. :slight_smile:
Can you give me a hint?

Best regards
Soeren aka huhabla

--Cedric Shock

_______________________________________________
grass5 mailing list
grass5@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass5

Sören,

The data you are patching with r.patch doesn't have null values for the cells
with no data; instead it is using zeros. r.patch will patch zeros instead of
nulls if you add the -z flag (line 232ish). You might also be able to change
gdalwarp so it produces output with nulls instead of zeros.

There's another problems with the tiling that I will address. It looks like
some cells end up with no data when patched because of lack of alignment of
the warped data. I'll add an extra=# option to r.tileset to add extra pixels
for overlap to the tiles and reply to the email when it's done.

On my monitor it doesn't look like the tiling covers the northern extent of
the region's bounding box, but it looked good on yours. That's almost
certainly because my cs2cs choked on +nadgrids=conus in the spearfish
projection and I had to shortcut it.

--Cedric Shock