[GRASS5] Raster files suggestion: new directory layout

Hi,

another proposal: Let's simplify the raster file directory layout
and have all files related to a raster map staying in a single
directory (such as the 5.7 vector files). We already have discussed
it some time ago.

Advantages:
- clean and understandable file structure
- cleanup of raster API which is hard to understand at time
- user can easily copy a map into another machine
  (say, for backup reasons or whatever)
- more?

Disadvantages:
- a script to migrate raster databases is needed
  (as we once did for LZW elimination)

When to implement it:
- I suggest to do it asap in GRASS 5.7. While at migrating
  their vector databases the users can also migrate the raster
  databases (which is simply a 'mv' of the files).

It could be implemented in two phases:
- first read old raster file directory layout, but write new
  layout
- in a later version remove support for reading old layout

Markus

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I strongly support the idea. Perhaps this could give us a chance to improve
the data format as well? I think a limitation of rasters is that they are
always 8 bitpp, whereas in many cases (black&white maps) it would be more
appropriate to stick to 1bpp (far smaller files!).
But if this is complicated, of course it will be better to change the
directory layout ASAP.
All the best.
pc

At 14:43, lunedì 05 luglio 2004, Markus Neteler has probably written:

Hi,

another proposal: Let's simplify the raster file directory layout
and have all files related to a raster map staying in a single
directory (such as the 5.7 vector files). We already have discussed
it some time ago.

Advantages:
- clean and understandable file structure
- cleanup of raster API which is hard to understand at time
- user can easily copy a map into another machine
  (say, for backup reasons or whatever)
- more?

Disadvantages:
- a script to migrate raster databases is needed
  (as we once did for LZW elimination)

When to implement it:
- I suggest to do it asap in GRASS 5.7. While at migrating
  their vector databases the users can also migrate the raster
  databases (which is simply a 'mv' of the files).

It could be implemented in two phases:
- first read old raster file directory layout, but write new
  layout
- in a later version remove support for reading old layout

Markus

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

- --
Paolo Cavallini
cavallini@faunalia.it www.faunalia.it
Piazza Garibaldi 5 - 56025 Pontedera (PI), Italy Tel: (+39)348-3801953
GPG key @: www.faunalia.it/Public_key_Paolo.asc
Only free software: www.gnu.org / www.linux.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA6VOz/NedwLUzIr4RAuwbAKC6w2YFRXV6m+dGIWEHmREniBwyVACdE0dZ
oNXo3U11DUQY4CLDd307LdU=
=6jwF
-----END PGP SIGNATURE-----

Any changes in raster directory structure should be done
only with other necessary changes in GRASS raster format,
which will break data compatibility, IMHO.
I think that to force users to convert (gigabytes) of data
for nothing is not the best idea.

On Monday 05 July 2004 15:12, Paolo Cavallini wrote:

I strongly support the idea. Perhaps this could give us a chance to improve
the data format as well?

Improvements in data format can give a chance to change also directory structure,
vice versa it does not make much sense I think.

I think a limitation of rasters is that they are
always 8 bitpp, whereas in many cases (black&white maps) it would be more
appropriate to stick to 1bpp (far smaller files!).
But if this is complicated, of course it will be better to change the
directory layout ASAP.
All the best.
pc

At 14:43, lunedì 05 luglio 2004, Markus Neteler has probably written:
> Hi,
>
> another proposal: Let's simplify the raster file directory layout
> and have all files related to a raster map staying in a single
> directory (such as the 5.7 vector files). We already have discussed
> it some time ago.
>
> Advantages:
> - clean and understandable file structure

I think that the structure is understandable.

> - cleanup of raster API which is hard to understand at time

Is it realy because of directory structure?

> - user can easily copy a map into another machine
> (say, for backup reasons or whatever)

Yes, that's true, but GRASS is designed so that users should not
access GISDBASE directly, only through GRASS modules.
For backup I would suggest r/v.pack/unpack

> - more?
>
> Disadvantages:
> - a script to migrate raster databases is needed
> (as we once did for LZW elimination)

The script is not the problem, the prolem is that the data
compatibility is broken.

> When to implement it:
> - I suggest to do it asap in GRASS 5.7. While at migrating
> their vector databases the users can also migrate the raster
> databases (which is simply a 'mv' of the files).

5.7.0 was already released, I was waiting with 5.7.0 until
format was stabilised.

> It could be implemented in two phases:
> - first read old raster file directory layout, but write new
> layout
> - in a later version remove support for reading old layout

Is anybody going to implement it in near future?

Radim

Markus Neteler wrote:

another proposal: Let's simplify the raster file directory layout
and have all files related to a raster map staying in a single
directory (such as the 5.7 vector files). We already have discussed
it some time ago.

Agreed. But I would suggest doing much more than simply moving the
files around. Off the top of my head, reasonable (IMHO) possibilities
include:

- Write raw C int/float/double rather than using XDR (FP) and
  home-grown (integer) encodings.

[Makes portability slightly harder; we would need to be able to handle
both big- and little-endian files, and possibly provide IEEE FP
encoding/decoding for architectures which don't use IEEE natively. But
it might provide a big performance boost if the typical-case I/O path
is to simply call read() or write(); or even just mmap().]

- Use zlib for compressing both integer and FP maps.

- Support 1/2/4 bits-per-cell formats.

- Embed nulls rather than using a separate null file.

- Support fixed-point format; i.e. the raw data is integers, but the
  header contains FP slope and offset values with which the data is
  transformed, so it appears as FP to the application. This would
  effectively provide 1/2/4/8/16 bits-per-cell FP maps.

- Support "rescale" maps; a cross between fixed-point maps and reclass
  maps. Like a reclass map but the transformation consists of
  slope and offset coefficients rather than a list of discrete
  categories. Unlike reclass maps, this would work for FP maps (and
  integer maps with many categories).

- Incorporate rowio and/or segment functionality directly. Possibly
  generalise map format to rectangular tiles (a traditional row-by-row
  map would just have tiles which are one row high and as wide as the
  map).

[Ideally, I would like the ability to write GET(map_fd, row, col) and
PUT(map_fd, row, col, value), and have it work efficiently, and not
have to bother with {get,put}_row() operations at all.]

- Incorporate g3d functionality directly (a 2D map would just be one
  "slice" deep).

Advantages:
- clean and understandable file structure
- cleanup of raster API which is hard to understand at time

I don't think that the existing API is particularly difficult
(although there is a lot of redundancy). The *implementation*, OTOH,
can be extremely hard to understand.

When to implement it:
- I suggest to do it asap in GRASS 5.7. While at migrating
  their vector databases the users can also migrate the raster
  databases (which is simply a 'mv' of the files).

I suggest spending some time thinking about it first. The raster I/O
code constitutes the foundation for half of GRASS (vectors being the
other half). It would help to get it right at the outset.

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

another proposal: Let's simplify the raster file directory layout
and have all files related to a raster map staying in a single
directory (such as the 5.7 vector files). We already have discussed
it some time ago.

...

- clean and understandable file structure

.. following the 5.7 vector/ directoy pattern:

$MAPSET/raster/$MAPNAME/colr
$MAPSET/raster/$MAPNAME/cats
$MAPSET/raster/$MAPNAME/cell
$MAPSET/raster/$MAPNAME/hist

etc..
?

- user can easily copy a map into another machine
  (say, for backup reasons or whatever)

Tip:
For a quick way of copying maps now try: r.out.mat, copy the map file
to a new machine, then use r.in.mat. I guess you could do GeoTIFF or
something else as well, but this is quick and easy. Things like the
cats/, colr/, and hist/ files don't get included (yet). I've found it
to be useful; matlab is not required.

  (as we once did for LZW elimination)

Unisys patent now gone?

Hamish

Hamish wrote:

> (as we once did for LZW elimination)

Unisys patent now gone?

Apparently, IBM's patent (on LZW) still has a couple of years left to
run.

In any case, GRASS has long since stopped supporting LZW compression.
I can't see any reason to bring it back.

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

On Fri, Jul 09, 2004 at 04:51:59PM +1200, Hamish wrote:

> another proposal: Let's simplify the raster file directory layout
> and have all files related to a raster map staying in a single
> directory (such as the 5.7 vector files). We already have discussed
> it some time ago.
>
...

- clean and understandable file structure

.. following the 5.7 vector/ directoy pattern:

$MAPSET/raster/$MAPNAME/colr
$MAPSET/raster/$MAPNAME/cats
$MAPSET/raster/$MAPNAME/cell
$MAPSET/raster/$MAPNAME/hist

etc..
?

Yes.

> - user can easily copy a map into another machine
> (say, for backup reasons or whatever)

Tip:
For a quick way of copying maps now try: r.out.mat, copy the map file
to a new machine, then use r.in.mat. I guess you could do GeoTIFF or
something else as well, but this is quick and easy. Things like the
cats/, colr/, and hist/ files don't get included (yet).

This is exactly missing. When I have to backup or to copy the map
to a friend's computer, I need the full copy. Currently the only
way is to use 'find' or manual file selection.

I've found it to be useful; matlab is not required.

> (as we once did for LZW elimination)

Unisys patent now gone?

Yes, I think so.

Markus

Markus Neteler wrote:

On Fri, Jul 09, 2004 at 04:51:59PM +1200, Hamish wrote:

> > - user can easily copy a map into another machine
> > (say, for backup reasons or whatever)
>
> Tip:
> For a quick way of copying maps now try: r.out.mat, copy the map file
> to a new machine, then use r.in.mat. I guess you could do GeoTIFF or
> something else as well, but this is quick and easy. Things like the
> cats/, colr/, and hist/ files don't get included (yet).

This is exactly missing. When I have to backup or to copy the map
to a friend's computer, I need the full copy. Currently the only
way is to use 'find' or manual file selection.

Well writing an import/export module that included all the components of
the raster would be a lot less trouble than changing the file structure
IMHO... (and easier to explain to less experienced users how to use it).

Paul

> > > - user can easily copy a map into another machine
> > > (say, for backup reasons or whatever)
> >
> > For a quick way of copying maps now try: r.out.mat, copy the map file
> > to a new machine, then use r.in.mat. I guess you could do GeoTIFF or
> > something else as well, but this is quick and easy. Things like the
> > cats/, colr/, and hist/ files don't get included (yet).
>
> This is exactly missing. When I have to backup or to copy the map
> to a friend's computer, I need the full copy. Currently the only
> way is to use 'find' or manual file selection.

Well writing an import/export module that included all the components of
the raster would be a lot less trouble than changing the file structure
IMHO... (and easier to explain to less experienced users how to use it).

This probably needs a bit more debugging, but....

attached: [r.pack] [r.unpack]

Hamish

(attachments)

r.pack (1.56 KB)
r.unpack (2.15 KB)

Hello Hamish

Hamish wrote:

> > > > - user can easily copy a map into another machine
> > > > (say, for backup reasons or whatever)
> > >
> > > For a quick way of copying maps now try: r.out.mat, copy the map file
> > > to a new machine, then use r.in.mat. I guess you could do GeoTIFF or
> > > something else as well, but this is quick and easy. Things like the
> > > cats/, colr/, and hist/ files don't get included (yet).
> >
> > This is exactly missing. When I have to backup or to copy the map
> > to a friend's computer, I need the full copy. Currently the only
> > way is to use 'find' or manual file selection.
>
> Well writing an import/export module that included all the components of
> the raster would be a lot less trouble than changing the file structure
> IMHO... (and easier to explain to less experienced users how to use it).

This probably needs a bit more debugging, but....

This is just like what I had in mind also.

A suggestion:
Perhaps pipe tar output/input to/from gzip to allow for non-GNU tars:

tar cf - * | gzip -fc > "$OLD_DIR"/"$GIS_OPT_input".pack
etc. ...

Two locations may have the same projection but totally different
PROJ_INFOs (e.g. UTm can be described by proj=utm, zone=xx etc. or
proj=tmerc, k_0=0.9996 and other parameters etc. and I feel it is not
really feasible to compare two projections. G_compare_projections() in
src/libes/gis/make_loc.c makes a stab at it though (but I don't like
what it does :wink: )

Maybe the suffix for the pack file should have 3 letters to look
conventional? gpk for GRASS pack or something?

Also I have often wondered do we really need to say
exec $GISBASE/etc/bin/cmd/g.parser
and not just
exec g.parser
?

Paul