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

2023-02-10 Thread Manuel Spínola
Thank you very much Michael.

My idea is to create a spatial nested grid to conduct spatial surveys for a
monitoring protocol.

I am thinking to create an 8km, 4km, 2km and 1km nested grids so you can
use different tiles according to the desired resolution of species
occurrences, landscape metrics, or other metrics.

 See this
https://gis.stackexchange.com/questions/386664/creating-nested-grid-in-qgis

Manuel




El vie, 10 feb 2023 a las 16:38, Michael Sumner ()
escribió:

> 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 
> 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
>> mspin...@una.cr 
>> mspinol...@gmail.com
>> Teléfono: (506) 8706 - 4662
>> Institutional website: ICOMVIS
>> 
>> Blog sobre Ciencia de Datos:
>> https://mspinola-ciencia-de-datos.netlify.app
>>
>> [[alternative HTML version deleted]]
>>
>> ___
>> R-sig-Geo mailing list
>> R-sig-Geo@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: mdsum...@gmail.com
>


-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.cr 
mspinol...@gmail.com
Teléfono: (506) 8706 - 4662
Institutional website: ICOMVIS

Blog sobre Ciencia de Datos: https://mspinola-ciencia-de-datos.netlify.app

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


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

2023-02-10 Thread Michael Sumner
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  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 
> 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
>> mspin...@una.cr 
>> mspinol...@gmail.com
>> Teléfono: (506) 8706 - 4662
>> Institutional website: ICOMVIS
>> 
>> Blog sobre Ciencia de Datos:
>> https://mspinola-ciencia-de-datos.netlify.app
>>
>> [[alternative HTML version deleted]]
>>
>> ___
>> R-sig-Geo mailing list
>> R-sig-Geo@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: mdsum...@gmail.com
>


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

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


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

2023-02-10 Thread Michael Sumner
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 
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
> mspin...@una.cr 
> mspinol...@gmail.com
> Teléfono: (506) 8706 - 4662
> Institutional website: ICOMVIS
> 
> Blog sobre Ciencia de Datos: https://mspinola-ciencia-de-datos.netlify.app
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@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: mdsum...@gmail.com

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


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

2023-02-10 Thread Manuel Spínola
Thank you very much Marcelino.

Manuel

El vie, 10 feb 2023 a las 13:00, Marcelino de la Cruz Rot (<
marcelino.delac...@urjc.es>) escribió:

> El 10/02/2023 a las 15:13, Roger Bivand escribió:
> > On Fri, 10 Feb 2023, Marcelino de la Cruz Rot wrote:
> >
> >> It depends on what you mean by "overimpose".
> >>
> >> Maybe this way?
> >>
> >> # some spatial polygon
> >
> > Please, in the spirit of the evolving r-spatial package ecosystem
> > (maptools will retire during 2023):
> >
> > library(sf)
> > R <- st_as_sf(affine(letterR, mat=diag(c(20,20
> > plot(R, border="blue")
> >
> > See https://r-spatial.org/r/2022/12/14/evolution2.html, maybe
> > https://rsbivand.github.io/csds_jan23/bivand_csds_ssg_230117.pdf and
> >
> https://www.youtube.com/watch?v=TlpjIqTPMCA=PLzREt6r1NenmWEidssmLm-VO_YmAh4pq9=1
> >
> > Roger
>
> Thank you Roger!
>
> In the spirit of the evolving, I then suggest this to Manuel:
>
> # define this function (if it is not in your  version of sf)
>
> st_as_sf.tess <- sf:::st_as_sf.owin
>
> # transform tesselations in sf's
>
> Dsf <-  st_as_sf(D)
> Csf <-  st_as_sf(C)
> Bsf <- st_as_sf(B)
> Asf <- st_as_sf(A)
>
> # crop tesselations with spatial polygon
>
> RDsf <- Dsf[R,]
> RCsf <- Csf[R,]
> RBsf <- Bsf[R,]
> RAsf <- Asf[R,]
>
> #overimpose cropped grids
> plot(RAsf)
> plot(RDsf, border="green", add=T)
> plot(RCsf, border="blue", add=T)
> plot(RBsf, border="red", add=T)
> plot(RAsf, add=T)
>
> Cheers,
>
> Marcelino
>
>
>
>
>
>
>
> >
> >> library(maptools)
> >> R <- as(affine(letterR, mat=diag(c(20,20))), "SpatialPolygons")
> >> plot(R, border="blue")
> >>
> >> # "overimpose" grids A to C on R:
> >> plot(C, border="green", add=T)
> >> plot(B, border="red", add=T)
> >> plot(A, add=T)
> >>
> >> Cheers,
> >> Marcelino
> >>
> >>
> >>
> >> El 10/02/2023 a las 13:29, Manuel Spínola escribió:
> >>>  Thank you very much Marcelino.
> >>>
> >>>  And how can overimpose those grids to a spatial polygon?
> >>>
> >>>  Manuel
> >>>
> >>>  On Fri, 10 Feb 2023 at 03:09 Marcelino de la Cruz Rot
> >>>   wrote:
> >>>
> >>>  Dear Manuel,
> >>>  This is R. There is no "it is possible". Only "how" ;-).
> >>>
> >>>  For example, with spatstat.geom,
> >>>
> >>>  A <- tess(xgrid=seq(0,80, by=8),ygrid=seq(0,80, by=8))
> >>>  B <- tess(xgrid=seq(0,80, by=4),ygrid=seq(0,80, by=4))
> >>>  C <- tess(xgrid=seq(0,80, by=2),ygrid=seq(0,80, by=2))
> >>>  D <- tess(xgrid=seq(0,80, by=1),ygrid=seq(0,80, by=1))
> >>>
> >>>  Cheers,
> >>>  Marcelino
> >>>
> >>>
> >>>  El 10/02/2023 a las 0:21, Manuel Spínola escribió:
> >>> >  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
> >>> >
> >>>  --
> >>>  Marcelino de la Cruz Rot
> >>>  Coordinador funcional de Biología
> >>>  Depto. de Biología y Geología
> >>>  Física y Química Inorgánica
> >>>  Universidad Rey Juan Carlos
> >>>  Móstoles España
> >>>
> >>>  ___
> >>>  R-sig-Geo mailing list
> >>>  R-sig-Geo@r-project.org
> >>>
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo=05%7C01%7CRoger.Bivand%40nhh.no%7C0b29de36aca54242ddf008db0b6ade31%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C638116325854200214%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=Ngv4yEcnP6JM4zq5rpVgzcYgRHAFwPPS8JRFhMaRA58%3D=0
> >>>
> >>>  --
> >>>  *Manuel Spínola, Ph.D.*
> >>>  Instituto Internacional en Conservación y Manejo de Vida Silvestre
> >>>  Universidad Nacional
> >>>  Apartado 1350-3000
> >>>  Heredia
> >>>  COSTA RICA
> >>>  mspin...@una.cr 
> >>>  mspinol...@gmail.com
> >>>  Teléfono: (506) 8706 - 4662
> >>>  Institutional website: ICOMVIS
> >>>  <
> https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.icomvis.una.ac.cr%2Findex.php%2Fmanuel=05%7C01%7CRoger.Bivand%40nhh.no%7C0b29de36aca54242ddf008db0b6ade31%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C638116325854200214%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=fCKSKsYuj7JXD5CbsQDKFUkeAVpqekVl%2BbTYM2dpuzU%3D=0>
>
> >>>
> >>>  Blog sobre Ciencia de Datos:
> >>>
> 

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

2023-02-10 Thread Marcelino de la Cruz Rot

El 10/02/2023 a las 15:13, Roger Bivand escribió:

On Fri, 10 Feb 2023, Marcelino de la Cruz Rot wrote:


It depends on what you mean by "overimpose".

Maybe this way?

# some spatial polygon


Please, in the spirit of the evolving r-spatial package ecosystem 
(maptools will retire during 2023):


library(sf)
R <- st_as_sf(affine(letterR, mat=diag(c(20,20
plot(R, border="blue")

See https://r-spatial.org/r/2022/12/14/evolution2.html, maybe 
https://rsbivand.github.io/csds_jan23/bivand_csds_ssg_230117.pdf and 
https://www.youtube.com/watch?v=TlpjIqTPMCA=PLzREt6r1NenmWEidssmLm-VO_YmAh4pq9=1


Roger


Thank you Roger!

In the spirit of the evolving, I then suggest this to Manuel:

# define this function (if it is not in your  version of sf)

st_as_sf.tess <- sf:::st_as_sf.owin

# transform tesselations in sf's

Dsf <-  st_as_sf(D)
Csf <-  st_as_sf(C)
Bsf <- st_as_sf(B)
Asf <- st_as_sf(A)

# crop tesselations with spatial polygon

RDsf <- Dsf[R,]
RCsf <- Csf[R,]
RBsf <- Bsf[R,]
RAsf <- Asf[R,]

#overimpose cropped grids
plot(RAsf)
plot(RDsf, border="green", add=T)
plot(RCsf, border="blue", add=T)
plot(RBsf, border="red", add=T)
plot(RAsf, add=T)

Cheers,

Marcelino










library(maptools)
R <- as(affine(letterR, mat=diag(c(20,20))), "SpatialPolygons")
plot(R, border="blue")

# "overimpose" grids A to C on R:
plot(C, border="green", add=T)
plot(B, border="red", add=T)
plot(A, add=T)

Cheers,
Marcelino



El 10/02/2023 a las 13:29, Manuel Spínola escribió:

 Thank you very much Marcelino.

 And how can overimpose those grids to a spatial polygon?

 Manuel

 On Fri, 10 Feb 2023 at 03:09 Marcelino de la Cruz Rot
  wrote:

 Dear Manuel,
 This is R. There is no "it is possible". Only "how" ;-).

 For example, with spatstat.geom,

 A <- tess(xgrid=seq(0,80, by=8),ygrid=seq(0,80, by=8))
 B <- tess(xgrid=seq(0,80, by=4),ygrid=seq(0,80, by=4))
 C <- tess(xgrid=seq(0,80, by=2),ygrid=seq(0,80, by=2))
 D <- tess(xgrid=seq(0,80, by=1),ygrid=seq(0,80, by=1))

 Cheers,
 Marcelino


 El 10/02/2023 a las 0:21, Manuel Spínola escribió:
    >  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
    >
 --
 Marcelino de la Cruz Rot
 Coordinador funcional de Biología
 Depto. de Biología y Geología
 Física y Química Inorgánica
 Universidad Rey Juan Carlos
 Móstoles España

 ___
 R-sig-Geo mailing list
 R-sig-Geo@r-project.org
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo=05%7C01%7CRoger.Bivand%40nhh.no%7C0b29de36aca54242ddf008db0b6ade31%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C638116325854200214%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=Ngv4yEcnP6JM4zq5rpVgzcYgRHAFwPPS8JRFhMaRA58%3D=0

 --
 *Manuel Spínola, Ph.D.*
 Instituto Internacional en Conservación y Manejo de Vida Silvestre
 Universidad Nacional
 Apartado 1350-3000
 Heredia
 COSTA RICA
 mspin...@una.cr 
 mspinol...@gmail.com
 Teléfono: (506) 8706 - 4662
 Institutional website: ICOMVIS
  


 Blog sobre Ciencia de Datos:
 https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmspinola-ciencia-de-datos.netlify.app%2F=05%7C01%7CRoger.Bivand%40nhh.no%7C0b29de36aca54242ddf008db0b6ade31%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C638116325854200214%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=cVcjfP2hgnbfK%2BZCrCGFi4HhnQjGEWtx8zeJ%2BjBZDtE%3D=0 









--
Marcelino de la Cruz Rot
Coordinador funcional de Biología
Depto. de Biología y Geología
Física y Química Inorgánica
Universidad Rey Juan Carlos
Móstoles España

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


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

2023-02-10 Thread Manuel Spínola
Thank you very much Roger.

Manuel

El vie, 10 feb 2023 a las 8:13, Roger Bivand ()
escribió:

> On Fri, 10 Feb 2023, Marcelino de la Cruz Rot wrote:
>
> > It depends on what you mean by "overimpose".
> >
> > Maybe this way?
> >
> > # some spatial polygon
>
> Please, in the spirit of the evolving r-spatial package ecosystem
> (maptools will retire during 2023):
>
> library(sf)
> R <- st_as_sf(affine(letterR, mat=diag(c(20,20
> plot(R, border="blue")
>
> See https://r-spatial.org/r/2022/12/14/evolution2.html, maybe
> https://rsbivand.github.io/csds_jan23/bivand_csds_ssg_230117.pdf and
>
> https://www.youtube.com/watch?v=TlpjIqTPMCA=PLzREt6r1NenmWEidssmLm-VO_YmAh4pq9=1
>
> Roger
>
> > library(maptools)
> > R <- as(affine(letterR, mat=diag(c(20,20))), "SpatialPolygons")
> > plot(R, border="blue")
> >
> > # "overimpose" grids A to C on R:
> > plot(C, border="green", add=T)
> > plot(B, border="red", add=T)
> > plot(A, add=T)
> >
> > Cheers,
> > Marcelino
> >
> >
> >
> > El 10/02/2023 a las 13:29, Manuel Spínola escribió:
> >>  Thank you very much Marcelino.
> >>
> >>  And how can overimpose those grids to a spatial polygon?
> >>
> >>  Manuel
> >>
> >>  On Fri, 10 Feb 2023 at 03:09 Marcelino de la Cruz Rot
> >>   wrote:
> >>
> >>  Dear Manuel,
> >>  This is R. There is no "it is possible". Only "how" ;-).
> >>
> >>  For example, with spatstat.geom,
> >>
> >>  A <- tess(xgrid=seq(0,80, by=8),ygrid=seq(0,80, by=8))
> >>  B <- tess(xgrid=seq(0,80, by=4),ygrid=seq(0,80, by=4))
> >>  C <- tess(xgrid=seq(0,80, by=2),ygrid=seq(0,80, by=2))
> >>  D <- tess(xgrid=seq(0,80, by=1),ygrid=seq(0,80, by=1))
> >>
> >>  Cheers,
> >>  Marcelino
> >>
> >>
> >>  El 10/02/2023 a las 0:21, Manuel Spínola escribió:
> >> >  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
> >> >
> >>
> >>  --
> >>  Marcelino de la Cruz Rot
> >>  Coordinador funcional de Biología
> >>  Depto. de Biología y Geología
> >>  Física y Química Inorgánica
> >>  Universidad Rey Juan Carlos
> >>  Móstoles España
> >>
> >>  ___
> >>  R-sig-Geo mailing list
> >>  R-sig-Geo@r-project.org
> >>
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo=05%7C01%7CRoger.Bivand%40nhh.no%7C0b29de36aca54242ddf008db0b6ade31%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C638116325854200214%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=Ngv4yEcnP6JM4zq5rpVgzcYgRHAFwPPS8JRFhMaRA58%3D=0
> >>
> >>  --
> >>  *Manuel Spínola, Ph.D.*
> >>  Instituto Internacional en Conservación y Manejo de Vida Silvestre
> >>  Universidad Nacional
> >>  Apartado 1350-3000
> >>  Heredia
> >>  COSTA RICA
> >>  mspin...@una.cr 
> >>  mspinol...@gmail.com
> >>  Teléfono: (506) 8706 - 4662
> >>  Institutional website: ICOMVIS
> >>  <
> https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.icomvis.una.ac.cr%2Findex.php%2Fmanuel=05%7C01%7CRoger.Bivand%40nhh.no%7C0b29de36aca54242ddf008db0b6ade31%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C638116325854200214%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=fCKSKsYuj7JXD5CbsQDKFUkeAVpqekVl%2BbTYM2dpuzU%3D=0
> >
> >>  Blog sobre Ciencia de Datos:
> >>
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmspinola-ciencia-de-datos.netlify.app%2F=05%7C01%7CRoger.Bivand%40nhh.no%7C0b29de36aca54242ddf008db0b6ade31%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C638116325854200214%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=cVcjfP2hgnbfK%2BZCrCGFi4HhnQjGEWtx8zeJ%2BjBZDtE%3D=0
> >
> >
> >
>
> --
> Roger Bivand
> Emeritus Professor
> Department of Economics, Norwegian School of Economics,
> Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway.
> e-mail: roger.biv...@nhh.no
> https://orcid.org/-0003-2392-6140
> https://scholar.google.no/citations?user=AWeghB0J=en
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>


-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.cr 
mspinol...@gmail.com
Teléfono: (506) 8706 - 4662
Institutional website: ICOMVIS

Blog sobre Ciencia de Datos: https://mspinola-ciencia-de-datos.netlify.app

[[alternative 

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

2023-02-10 Thread Roger Bivand

On Fri, 10 Feb 2023, Marcelino de la Cruz Rot wrote:


It depends on what you mean by "overimpose".

Maybe this way?

# some spatial polygon


Please, in the spirit of the evolving r-spatial package ecosystem 
(maptools will retire during 2023):


library(sf)
R <- st_as_sf(affine(letterR, mat=diag(c(20,20
plot(R, border="blue")

See https://r-spatial.org/r/2022/12/14/evolution2.html, maybe 
https://rsbivand.github.io/csds_jan23/bivand_csds_ssg_230117.pdf and 
https://www.youtube.com/watch?v=TlpjIqTPMCA=PLzREt6r1NenmWEidssmLm-VO_YmAh4pq9=1


Roger


library(maptools)
R <- as(affine(letterR, mat=diag(c(20,20))), "SpatialPolygons")
plot(R, border="blue")

# "overimpose" grids A to C on R:
plot(C, border="green", add=T)
plot(B, border="red", add=T)
plot(A, add=T)

Cheers,
Marcelino



El 10/02/2023 a las 13:29, Manuel Spínola escribió:

 Thank you very much Marcelino.

 And how can overimpose those grids to a spatial polygon?

 Manuel

 On Fri, 10 Feb 2023 at 03:09 Marcelino de la Cruz Rot
  wrote:

 Dear Manuel,
 This is R. There is no "it is possible". Only "how" ;-).

 For example, with spatstat.geom,

 A <- tess(xgrid=seq(0,80, by=8),ygrid=seq(0,80, by=8))
 B <- tess(xgrid=seq(0,80, by=4),ygrid=seq(0,80, by=4))
 C <- tess(xgrid=seq(0,80, by=2),ygrid=seq(0,80, by=2))
 D <- tess(xgrid=seq(0,80, by=1),ygrid=seq(0,80, by=1))

 Cheers,
 Marcelino


 El 10/02/2023 a las 0:21, Manuel Spínola escribió:
>  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
> 


 --
 Marcelino de la Cruz Rot
 Coordinador funcional de Biología
 Depto. de Biología y Geología
 Física y Química Inorgánica
 Universidad Rey Juan Carlos
 Móstoles España

 ___
 R-sig-Geo mailing list
 R-sig-Geo@r-project.org
 
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo=05%7C01%7CRoger.Bivand%40nhh.no%7C0b29de36aca54242ddf008db0b6ade31%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C638116325854200214%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=Ngv4yEcnP6JM4zq5rpVgzcYgRHAFwPPS8JRFhMaRA58%3D=0

 --
 *Manuel Spínola, Ph.D.*
 Instituto Internacional en Conservación y Manejo de Vida Silvestre
 Universidad Nacional
 Apartado 1350-3000
 Heredia
 COSTA RICA
 mspin...@una.cr 
 mspinol...@gmail.com
 Teléfono: (506) 8706 - 4662
 Institutional website: ICOMVIS
 

 Blog sobre Ciencia de Datos:
 
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmspinola-ciencia-de-datos.netlify.app%2F=05%7C01%7CRoger.Bivand%40nhh.no%7C0b29de36aca54242ddf008db0b6ade31%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C638116325854200214%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=cVcjfP2hgnbfK%2BZCrCGFi4HhnQjGEWtx8zeJ%2BjBZDtE%3D=0






--
Roger Bivand
Emeritus Professor
Department of Economics, Norwegian School of Economics,
Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway.
e-mail: roger.biv...@nhh.no
https://orcid.org/-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0J=en___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


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

2023-02-10 Thread Manuel Spínola
Thank you very much Marcelino.

Manuel

El vie, 10 feb 2023 a las 7:29, Marcelino de la Cruz Rot (<
marcelino.delac...@urjc.es>) escribió:

> It depends on what you mean by "overimpose".
>
> Maybe this way?
>
> # some spatial polygon
> library(maptools)
> R <- as(affine(letterR, mat=diag(c(20,20))), "SpatialPolygons")
> plot(R, border="blue")
>
> # "overimpose" grids A to C on R:
> plot(C, border="green", add=T)
> plot(B, border="red", add=T)
> plot(A, add=T)
>
> Cheers,
> Marcelino
>
>
>
> El 10/02/2023 a las 13:29, Manuel Spínola escribió:
> > Thank you very much Marcelino.
> >
> > And how can overimpose those grids to a spatial polygon?
> >
> > Manuel
> >
> > On Fri, 10 Feb 2023 at 03:09 Marcelino de la Cruz Rot
> >  wrote:
> >
> > Dear Manuel,
> > This is R. There is no "it is possible". Only "how" ;-).
> >
> > For example, with spatstat.geom,
> >
> > A <- tess(xgrid=seq(0,80, by=8),ygrid=seq(0,80, by=8))
> > B <- tess(xgrid=seq(0,80, by=4),ygrid=seq(0,80, by=4))
> > C <- tess(xgrid=seq(0,80, by=2),ygrid=seq(0,80, by=2))
> > D <- tess(xgrid=seq(0,80, by=1),ygrid=seq(0,80, by=1))
> >
> > Cheers,
> > Marcelino
> >
> >
> > El 10/02/2023 a las 0:21, Manuel Spínola escribió:
> > > 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
> > >
> >
> > --
> > Marcelino de la Cruz Rot
> > Coordinador funcional de Biología
> > Depto. de Biología y Geología
> > Física y Química Inorgánica
> > Universidad Rey Juan Carlos
> > Móstoles España
> >
> > ___
> > R-sig-Geo mailing list
> > R-sig-Geo@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> > --
> > *Manuel Spínola, Ph.D.*
> > Instituto Internacional en Conservación y Manejo de Vida Silvestre
> > Universidad Nacional
> > Apartado 1350-3000
> > Heredia
> > COSTA RICA
> > mspin...@una.cr 
> > mspinol...@gmail.com
> > Teléfono: (506) 8706 - 4662
> > Institutional website: ICOMVIS
> > 
> > Blog sobre Ciencia de Datos:
> https://mspinola-ciencia-de-datos.netlify.app
>
>
> --
> Marcelino de la Cruz Rot
> Coordinador funcional de Biología
> Depto. de Biología y Geología
> Física y Química Inorgánica
> Universidad Rey Juan Carlos
> Móstoles España
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>


-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.cr 
mspinol...@gmail.com
Teléfono: (506) 8706 - 4662
Institutional website: ICOMVIS

Blog sobre Ciencia de Datos: https://mspinola-ciencia-de-datos.netlify.app

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


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

2023-02-10 Thread Marcelino de la Cruz Rot

It depends on what you mean by "overimpose".

Maybe this way?

# some spatial polygon
library(maptools)
R <- as(affine(letterR, mat=diag(c(20,20))), "SpatialPolygons")
plot(R, border="blue")

# "overimpose" grids A to C on R:
plot(C, border="green", add=T)
plot(B, border="red", add=T)
plot(A, add=T)

Cheers,
Marcelino



El 10/02/2023 a las 13:29, Manuel Spínola escribió:

Thank you very much Marcelino.

And how can overimpose those grids to a spatial polygon?

Manuel

On Fri, 10 Feb 2023 at 03:09 Marcelino de la Cruz Rot 
 wrote:


Dear Manuel,
This is R. There is no "it is possible". Only "how" ;-).

For example, with spatstat.geom,

A <- tess(xgrid=seq(0,80, by=8),ygrid=seq(0,80, by=8))
B <- tess(xgrid=seq(0,80, by=4),ygrid=seq(0,80, by=4))
C <- tess(xgrid=seq(0,80, by=2),ygrid=seq(0,80, by=2))
D <- tess(xgrid=seq(0,80, by=1),ygrid=seq(0,80, by=1))

Cheers,
Marcelino


El 10/02/2023 a las 0:21, Manuel Spínola escribió:
> 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
>

-- 
Marcelino de la Cruz Rot

Coordinador funcional de Biología
Depto. de Biología y Geología
Física y Química Inorgánica
Universidad Rey Juan Carlos
Móstoles España

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

--
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.cr 
mspinol...@gmail.com
Teléfono: (506) 8706 - 4662
Institutional website: ICOMVIS 


Blog sobre Ciencia de Datos: https://mspinola-ciencia-de-datos.netlify.app



--
Marcelino de la Cruz Rot
Coordinador funcional de Biología
Depto. de Biología y Geología
Física y Química Inorgánica
Universidad Rey Juan Carlos
Móstoles España

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


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

2023-02-10 Thread Manuel Spínola
Thank you very much Marcelino.

And how can overimpose those grids to a spatial polygon?

Manuel

On Fri, 10 Feb 2023 at 03:09 Marcelino de la Cruz Rot <
marcelino.delac...@urjc.es> wrote:

> Dear Manuel,
> This is R. There is no "it is possible". Only "how" ;-).
>
> For example, with spatstat.geom,
>
> A <- tess(xgrid=seq(0,80, by=8),ygrid=seq(0,80, by=8))
> B <- tess(xgrid=seq(0,80, by=4),ygrid=seq(0,80, by=4))
> C <- tess(xgrid=seq(0,80, by=2),ygrid=seq(0,80, by=2))
> D <- tess(xgrid=seq(0,80, by=1),ygrid=seq(0,80, by=1))
>
> Cheers,
> Marcelino
>
>
> El 10/02/2023 a las 0:21, Manuel Spínola escribió:
> > 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
> >
>
> --
> Marcelino de la Cruz Rot
> Coordinador funcional de Biología
> Depto. de Biología y Geología
> Física y Química Inorgánica
> Universidad Rey Juan Carlos
> Móstoles España
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.cr 
mspinol...@gmail.com
Teléfono: (506) 8706 - 4662
Institutional website: ICOMVIS

Blog sobre Ciencia de Datos: https://mspinola-ciencia-de-datos.netlify.app

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


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

2023-02-10 Thread Marcelino de la Cruz Rot

Dear Manuel,
This is R. There is no "it is possible". Only "how" ;-).

For example, with spatstat.geom,

A <- tess(xgrid=seq(0,80, by=8),ygrid=seq(0,80, by=8))
B <- tess(xgrid=seq(0,80, by=4),ygrid=seq(0,80, by=4))
C <- tess(xgrid=seq(0,80, by=2),ygrid=seq(0,80, by=2))
D <- tess(xgrid=seq(0,80, by=1),ygrid=seq(0,80, by=1))

Cheers,
Marcelino


El 10/02/2023 a las 0:21, Manuel Spínola escribió:

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



--
Marcelino de la Cruz Rot
Coordinador funcional de Biología
Depto. de Biología y Geología
Física y Química Inorgánica
Universidad Rey Juan Carlos
Móstoles España

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


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

2023-02-09 Thread Manuel Spínola
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
mspin...@una.cr 
mspinol...@gmail.com
Teléfono: (506) 8706 - 4662
Institutional website: ICOMVIS

Blog sobre Ciencia de Datos: https://mspinola-ciencia-de-datos.netlify.app

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo