<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 24, 2017 at 11:16 AM, Luí­s Moreira de Sousa <span dir="ltr"><<a href="mailto:luis.de.sousa@protonmail.ch" target="_blank">luis.de.sousa@protonmail.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">- In theory, all raster modules can function in exactly the same way with both square and hexagons if all geometric and neighbourhood methods/properties/functions are abstracted correctly.<br><div><br></div><div>- The risk here is breaking the existing r. modules by implementing the raster abstraction. Perhaps some sort of transition may be devised to avoid it <br></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div></div><div class="gmail-m_7330063323575964687protonmail_signature_block"><div class="gmail-m_7330063323575964687protonmail_signature_block-user"><div><br></div><div>- On my side, the next step is to dive into the code and study how practical these ideas may be. But please put forward your ideas in any case.<br></div></div></div></blockquote></div><br></div><div class="gmail_extra">For start, I suggest implementing some prototypes from stretch rather than rewriting/adopting existing code. Probably a conversion or visualization module makes sense so that we can see the results. I'm sure you have much better about this than I since you already went through that before.<br><br>I suggest that the modules store the hexagon map (maybe a correct name in GRASS?) in raster map with some metadata on the side. I would ignore the problem that a raster map which (perhaps) does not make any sense (for raster modules) is created. The metadata may be stored in just in the current directory (in future, they would go to the GRASS database).<br><br></div><div class="gmail_extra">You would need to use functions to modify computational region inside the module to be able to store it properly (e.g. r.in.lidar modifies the computational region for itself when -e flag is used). Standard way of doing this is in C, but Python works as well and may be much simpler (either through PyGRASS or ctypes directly). Importantly, this can be done without changing the library or existing modules, so you can do any experiments you want (e.g. in GRASS Addons, GRASS Sandbox or on GitHub).<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Talking just about how this prototype could be implemented, here is an example of user interaction and the results (the names are not final, r.hex.to.rast would probably become h.to.rast in the future):<br></div><div class="gmail_extra"><br></div><div class="gmail_extra"></div><div class="gmail_extra">GRASS > g.list rast m=.<br></div><div class="gmail_extra">a_raster<br><br>GRASS > <a href="http://r.info">r.info</a> raster_1 -g<br>...<br></div><div class="gmail_extra">res=2<br></div><div class="gmail_extra">...<br><br>GRASS > g.region raster=raster_1<br></div><div class="gmail_extra"><br>GRASS > r.to.hex input=raster_1 output=hexagons<br></div><div class="gmail_extra"><br>GRASS > g.list rast m=.<br>raster_1</div><div class="gmail_extra">hexagons<br></div><div class="gmail_extra"><br>GRASS > <a href="http://r.info">r.info</a> hexagon<br></div><div class="gmail_extra">something very unexpected here for the user<br></div><div class="gmail_extra">number of cells and perhaps even extent does not fit<br><br></div><div class="gmail_extra">GRASS > <a href="http://r.hex.info">r.hex.info</a><br></div><div class="gmail_extra">raster hexagon processed as hexagons<br></div><div class="gmail_extra">output about hexagonal grid<br></div><div class="gmail_extra">(information from the raster and metadata on the side combined)<br></div><div class="gmail_extra"><br>GRASS > r.hex.waterflow input=hexagons output=hexagonal_flow<br><br><div class="gmail_extra">GRASS > g.list rast m=.<br>raster_1</div>hexagons<br>hexagonal_flow<br><br><div class="gmail_extra">GRASS > g.list.hex m=.<br></div>hexagons<br>hexagonal_flow<br><br>GRASS > g.region res=0.1  # note much lower resolution<br><br></div><div class="gmail_extra">GRASS > r.hex.to.rast input=hexagonal_flow output=raster_2<br><br></div><div class="gmail_extra">GRASS > d.rast raster_2<br></div><div class="gmail_extra">no we see the hexagons because we oversampled them<br></div><div class="gmail_extra"><br></div></div>