[GRASS-dev] Adding hexagonal rasters to GRASS

Sören Gebbert soerengebbert at googlemail.com
Mon Jul 24 12:24:28 PDT 2017


Dear Luí­s,
this sounds very interesting, especially the improvement for surface
flow algorithms using hexagonal grids and other mass conservation
approaches like groundwater flow, heat flow, ... .

I agree with Vaclav on this topic. I think hexagonal grids can be
stored using the compressed row based approach of GRASS GIS. In
addition the rotation of the hexagonal grid may be stored in the
metadata. The question is, do we need rotated hexagonal grids at all
or do horizontal hexagonal grids do the job? In case of "horizontal"
hexagonal grids the compressed row approach would be very fast for
horizontal access. Indexing can be easily mapped to row/column access
using the "odd-r" horizontal layout. The existing on the fly nearest
neighbor resampling algorithms will have an offset of half a cell for
odd row indices when interacting with normal raster layers in existing
modules, so they must be adjusted.
Neighborhood operations must be implemented on top of the existing
row/col approach of GRASS. All algorithms that make cell neighbor
computations must be modified. The existing r.mapcalc neighbor
operators r[x][y] can be reused in case of odd-r horizontal layout.
Conversion between regular grids and hexagonal grids must be
implemented. Resampling algorithms must be modified. Rendering of
hexagonal grids must be implemented in the display library.  Plenty of
work do do. :)

Best regards
Sören

2017-07-24 1:19 GMT+02:00 Vaclav Petras <wenzeslaus at gmail.com>:
> Dear Luís,
>
> On Sun, Jul 23, 2017 at 11:50 AM, Luí­s Moreira de Sousa
> <luis.de.sousa at protonmail.ch> wrote:
>>
>>
>> I presented hex-utils at the GISTAM conference in April, here is the
>> video:
>> https://www.youtube.com/watch?v=uLO4HDCVBp0
>>
>
> thank you, this is very informative and exiting!
>
>>
>>
>> But as Luca said during the Q/A, it is probably better to start outright
>> within GRASS. This will require the abstraction of the raster concept,
>> together with operations like neighbourhood, number of neighbours, distance
>> to neighbours, etc. With that done most of the raster modules would function
>> the same way for squared and hexagonal rasters. Still, this would require a
>> complete revision of all the raster modules.
>
>
> Sounds good. I think there is a way in GRASS GIS to make it revolutionary
> and at the same time keeping everything in place. See below.
>
>>
>>
>> For a programmer, the main difference between hexagonal and squared
>> rasters is the cell addressing system: with hexagons the axis are not
>> orthogonal.
>
>
> If there would be a way, like the abstraction you mentioned, which would,
> e.g. make the current rectangle-only code work with hexagonal data (e.g. by
> presenting converting hexagons as rectangles on the fly), that would be
> helpful, but on the other side, I don't think it is necessarily the first
> step if there is an other way how to connect with rectangular rasters (even
> if it involves converting back and forth or less precision).
>
>>
>> However, it is possible to store an hexagonal raster in a bi-dimensional
>> array like you would store a squared raster.
>
>
> That would help the implementation and hopefully also the integration and
> adoption, again see below.
>
>>
>> I wrote an article last year with full details on the HexASCII file format
>> and how to deal with hexagonal cell adressing, but it is still under review.
>> I can not send it to the list, please send me a personal message if you wish
>> to read it.
>
>
> If you can share it, I would like to see it.
>
>>
>>
>> It would be great if we can take this forward. I imagine it is a load of
>> work, but it will make GRASS an even more awesome system ;)
>>
>
> Load of work and resulting code to maintain should be part of the
> consideration. Using existing functionality (algorithms, formats) and
> integrating with it will be crucial for both users and developers alike.
>
> Can you implement it this as a layer on top of existing functionality in
> GRASS GIS? There is several examples and concepts in GRASS GIS of this. For
> example, the temporal (t.*) modules work with series of rasters and vectors
> registered as spatio-temporal datasets and the image processing (i.*)
> modules work with series of rasters registered as imagery groups and
> subgroups ("multiband image"). In both cases standard storage of rasters (or
> vectors) is used, so there is no new backend format in GRASS database except
> for the additional data (metadata) needed for these tools. What is important
> is that you can work with the existing tools on the data handled by temporal
> or imagery modules, i.e. you can use the existing tools to implement the new
> tools (e.g. average of spatio-temporal raster dataset can be implemented
> through a tool for average of multiple rasters) and if the imagery or
> temporal modules miss specific functionality you need, you can fallback to
> the standard modules (e.g. loop over members of imagery group).
>
> I was thinking that the hexagonal rasters can be implemented in GRASS GIS
> using two rasters which would be shifted against each other, but aligned
> with the hexagonal cells, i.e. two rectangular rasters making up one
> hexagonal raster/grid (but I didn't test that or examined that more). After
> seeing your video with slightly rotated hexagonal grid, I'm thinking if it
> is possible to fit only one raster but with different resolution to the
> hexagons. The idea is that 1) you don't need another storage format and 2)
> you can use the raw data without the hexagon-aware algorithms. Of course we
> can settle just with re-using the storage format (1).
>
> Another approach is to threat hexagonal rasters/grids as another basic data
> type next to raster maps, vector maps, and 3D raster maps (in GRASS GIS
> there are also the aforementioned spatio-temporal datasets and imagery
> groups). They would be connected to the rest where it makes sense. For
> example, (2D) rasters and 3D rasters are independent, but there is also
> several connections: there are modules for conversion in between the two
> types, a lot of code for handling colors is the same, and computational
> region applies to both and is handled from the same module.
>
> If I may ask, what would you need to create a prototype and what do you
> envision as a final goal?
>
> Best,
> Vaclav
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-dev


More information about the grass-dev mailing list