[R-sig-Geo] Spatial nested grid in R

Michael Sumner md@umner @end|ng |rom gm@||@com
Fri Feb 10 23:37:50 CET 2023


Oh, with a COG you'd also want control over reading a particular level -
I'm not sure how well that's supported in the "R spatial" realm but I'll
include it in my example, you can always generate VRT to get exactly what
you want from terra and friends.

Cheers, Mike


On Sat, Feb 11, 2023 at 9:36 AM Michael Sumner <mdsumner using gmail.com> wrote:

> One way is to write it to a (COG) GeoTIFF with overviews ("pyramid", or
> zoom levels) - these are pre-calculated copies of the highest resolution
> data saved as lower resolution versions.
>
> Do you want this to generate a set of nested data, or is it more about
> working with the nested logic?
>
> I'm not sure what version of GDAL is required to write one directly with
> terra or raster, but i'll explore. In terms of the nesting logic , you can
> read a particular zoom level (or model it with an data-empty object) and
> determine cell index using the cells tools in terra (or raster). I think
> you would need to generate xyFromCell and use that to cellFromXY between
> layers (the arithmetic is not onerous but doesn't exist for reuse anywhere
> in R afaik).
>
> I'm interested in this generally for workflows I'm using so might come
> back with an example, happy to follow up related questions.
>
> At the command line with COG format you can do
> gdalinfo in.tif overviews.if -of COG -co OVERVIEW_COUNT=3  ## 3, for
> example
>
> or
>
> gdal_translate in.tif overviews.tif
> gdaladdo overviews.tif 2 4 8
>
> but, of course there are implications with tile pattern and potential
> overlap for a given size. You'd probably also want tiling enabled and
> choose a particular tile size (perhaps to match the next resolution down).
> And I'd definitely want to make sure my extent was clean whole numbers and
> choose sensible sized zoom and tile levels.
>
> Cheers, Mike
>
>
> On Fri, Feb 10, 2023 at 10:22 AM Manuel Spínola <mspinola10 using gmail.com>
> wrote:
>
>> Dear list members,
>>
>> Is it possible to generate a spatial nested grid in R?
>>
>> For example, a grid of several 8km x 8km tiles, and within that grid, I
>> want 4 tiles of 4km x 4km, and in each of those I want 4 tiles of 2km x
>> 2km, and in each of those I want 4 tiles of 1km x 1km.
>>
>> Manuel
>>
>> --
>> *Manuel Spínola, Ph.D.*
>> Instituto Internacional en Conservación y Manejo de Vida Silvestre
>> Universidad Nacional
>> Apartado 1350-3000
>> Heredia
>> COSTA RICA
>> mspinola using una.cr <mspinola using una.ac.cr>
>> mspinola10 using gmail.com
>> Teléfono: (506) 8706 - 4662
>> Institutional website: ICOMVIS
>> <http://www.icomvis.una.ac.cr/index.php/manuel>
>> Blog sobre Ciencia de Datos:
>> https://mspinola-ciencia-de-datos.netlify.app
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo using r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>
> --
> Michael Sumner
> Software and Database Engineer
> Australian Antarctic Division
> Hobart, Australia
> e-mail: mdsumner using gmail.com
>


-- 
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsumner using gmail.com

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list