[GRASS5] Tools for importing data from mapping servers

Good day,

I've written a new script for easing importing of tiled data from another
projection. It accepts a list of input files that gdalwarp can handle, as
well as a gdalwarp s_srs source projection and produces a single map in the
current database.

http://www.shockfamily.net/cedric/grass/r.in.gdalwarp

Usage example:
input=$HOME/Desktop/RedTile1.geotiff,$HOME/Desktop/RedTile2.geotiff,
$HOME/Desktop/RedTile3.geotiff output=RedTileset s_srs=EPSG:4326

Details: it projects the data in with gdalwarp, asking for a geotiff file with
alpha channel and nodata values marked in the alpha channel. It uses mapcalc
to mark nulls in the other channels where alpha is exactly 0. Finally it
patches all the various inputs together and cleans up the temporary maps.

Issues: Doesn't write history. Anyone want to tell me the right way to do
this?

Additionally I have made small changes to r.tileset, including an overlap
option to add extra cells to the right and top sides of the tiles:

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

--Cedric Shock

Issues: Doesn't write history. Anyone want to tell me the right way to
do this?

r.patch will write it's history (command line), but from a shell script
there isn't a good way (yet). Writing a line to the history should be a
command line option of r.support, but isn't yet.

Hamish

On Wed, Mar 08, 2006 at 11:03:33PM +1300, Hamish wrote:

> Issues: Doesn't write history. Anyone want to tell me the right way to
> do this?

r.patch will write it's history (command line), but from a shell script
there isn't a good way (yet). Writing a line to the history should be a
command line option of r.support, but isn't yet.

For myself, I have simply added text to the hist file,
something like this

meta="metadata bla bla bla"

HISTFILE=$LOCATION/hist/$RASTERMAP
#determine total length:
STRINGLENGTH=`echo $meta | wc -c | awk '{printf $1}'`

#maximal allowed string length for GRASS hist file 62 chars:
#(max 20 lines accepted, rest silently truncated by GRASS modules)
LINELENGTH=62

#insert linebreaks, if needed
i=1
while [ $i -le $STRINGLENGTH ]
do
NEXT=`expr $i + $LINELENGTH`
echo $meta | cut -b$i-$NEXT >> $HISTFILE
i=`expr $i + $LINELENGTH`
i=`expr $i + 1` # need one more
done

Of course it's highly desired to get this added to r.support.

Markus

HISTFILE=$LOCATION/hist/$RASTERMAP
#determine total length:
STRINGLENGTH=`echo $meta | wc -c | awk '{printf $1}'`

#maximal allowed string length for GRASS hist file 62 chars:
#(max 20 lines accepted, rest silently truncated by GRASS modules)
LINELENGTH=62

?
gis.h:
...
#define MAXEDLINES 50
#define RECORD_LEN 80
...
struct History
{
    char mapid[RECORD_LEN];
    char title[RECORD_LEN];
    char mapset[RECORD_LEN];
    char creator[RECORD_LEN];
    char maptype[RECORD_LEN];
    char datsrc_1[RECORD_LEN];
    char datsrc_2[RECORD_LEN];
    char keywrd[RECORD_LEN];
    int edlinecnt;
    char edhist[MAXEDLINES][RECORD_LEN];
};

so 50 rows x 80 cols.

62 may be the limit that r.info will show? 'r.info -h' should show all.

In G_command_history() I used 70. Seems ok.

Of course it's highly desired to get this added to r.support.

yes.

Hamish

On Thu, Mar 09, 2006 at 12:45:49PM +1300, Hamish wrote:

> HISTFILE=$LOCATION/hist/$RASTERMAP
> #determine total length:
> STRINGLENGTH=`echo $meta | wc -c | awk '{printf $1}'`
>
> #maximal allowed string length for GRASS hist file 62 chars:
> #(max 20 lines accepted, rest silently truncated by GRASS modules)
> LINELENGTH=62

?
gis.h:
...
#define MAXEDLINES 50
#define RECORD_LEN 80
...
struct History
{
    char mapid[RECORD_LEN];
    char title[RECORD_LEN];
    char mapset[RECORD_LEN];
    char creator[RECORD_LEN];
    char maptype[RECORD_LEN];
    char datsrc_1[RECORD_LEN];
    char datsrc_2[RECORD_LEN];
    char keywrd[RECORD_LEN];
    int edlinecnt;
    char edhist[MAXEDLINES][RECORD_LEN];
};

so 50 rows x 80 cols.

62 may be the limit that r.info will show? 'r.info -h' should show all.

In G_command_history() I used 70. Seems ok.

Ah, I forgot to mention that I wrote the script a few years
ago.

> Of course it's highly desired to get this added to r.support.

yes.

I will do sit and wait strategy :slight_smile:

Markus