[GRASS-user] hexagon rasters

Hello List,

I'm interested in working with hexagonal rasters. I know I can make hexagon vectors with "v.mkgrid -h", but is there any way to then work with these in raster space? I'd like to use r.walk and r.cost to estimate costs to move around the hex grid.

Thanks,

  -k.

Hi Ken,

On Tue, Feb 8, 2022 at 4:44 AM Ken Mankoff <mankoff@gmail.com> wrote:

Hello List,

I'm interested in working with hexagonal rasters. I know I can make hexagon vectors with "v.mkgrid -h",
but is there any way to then work with these in raster space? I'd like to use r.walk and r.cost to estimate
costs to move around the hex grid.

I am sure you considered v.to.rast?

# North Carolina sample dataset
g.region raster=elevation res=5000 -pa

# create vector hexagons
v.mkgrid map=hexagons -h
v.info -c hexagons

# convert to raster model, requires the resolution to be increased
(example: 5000m -> 250m)
g.region res=250 -p
v.to.rast input=hexagons output=hexagons use=cat

# viz
d.rast hexagons
d.vect hexagons type=boundary

Now you may turn them into cost surfaces.

Best,
Markus

Hi Markus,

Yes - that works but requires downstream hacks because of the different resolutions. Still, it is a workable solution I didn't think of. Thank you!

  -k.

On 2022-02-09 at 12:52 -08, Markus Neteler <neteler@osgeo.org> wrote:

Hi Ken,

On Tue, Feb 8, 2022 at 4:44 AM Ken Mankoff <mankoff@gmail.com> wrote:

Hello List,

I'm interested in working with hexagonal rasters. I know I can make
hexagon vectors with "v.mkgrid -h", but is there any way to then work
with these in raster space? I'd like to use r.walk and r.cost to
estimate costs to move around the hex grid.

I am sure you considered v.to.rast?

# North Carolina sample dataset
g.region raster=elevation res=5000 -pa

# create vector hexagons
v.mkgrid map=hexagons -h
v.info -c hexagons

# convert to raster model, requires the resolution to be increased
(example: 5000m -> 250m)
g.region res=250 -p
v.to.rast input=hexagons output=hexagons use=cat

# viz
d.rast hexagons
d.vect hexagons type=boundary

Now you may turn them into cost surfaces.

Best,
Markus

Hi Ken,

On Thu, Feb 10, 2022 at 1:16 AM Ken Mankoff <mankoff@gmail.com> wrote:

Hi Markus,

Yes - that works but requires downstream hacks because of the different resolutions.

Of course those could be scripted as well using eval():

eval `g.region -g`
# or:
# eval $(g.region -g)
echo $n $w $e $s

Still, it is a workable solution I didn't think of. Thank you!

HTH,
Markus