Commit dafcd208 authored by Jean-Marie Lepioufle's avatar Jean-Marie Lepioufle

build grid_senorge with stars

parent 683a6167
No preview for this file type
library(sf)
library(stars)
grid_senorge2 <- st_make_grid(cellsize = c(1000, 1000), offset = c(-74500,6450500), n=c(1195,1550),crs = st_crs("+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs"), what ="centers")
m = matrix(0, nrow = 1195, ncol = 1550)
dim(m) = c(x = 1195, y = 1550) # named dim
grid_senorge2 <- st_as_stars(m)
attr(grid_senorge2, "dimensions")[[1]]$delta <- 1000
attr(grid_senorge2, "dimensions")[[2]]$delta <- -1000
st_crs(grid_senorge2) <- "+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs"
attr(grid_senorge2, "dimensions")[[1]]$offset <- -75000
attr(grid_senorge2, "dimensions")[[2]]$offset <- 8000000
save(grid_senorge2,file="grid_senorge2.rda",compress="xz")
# check
st_bbox(grid_senorge2)
# xmin ymin xmax ymax
# -74000 6451000 1120000 8000000
length(grid_senorge2) == 1195*1550 # TRUE
m = matrix(0, nrow = 1195, ncol = 1550)
dim(m) = c(x = 1195, y = 1550) # named dim
grid_senorge2 <- st_as_stars(m)
attr(grid_senorge2, "dimensions")[[1]]$delta <- 1000
attr(grid_senorge2, "dimensions")[[2]]$delta <- -1000
st_crs(grid_senorge2) <- "+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs"
attr(grid_senorge2, "dimensions")[[1]]$offset <- -75000
attr(grid_senorge2, "dimensions")[[2]]$offset <- 8000000
save(grid_senorge2,file="grid_senorge2.rda",compress="xz")
m = matrix(0, nrow = 43, ncol = 44)
dim(m) = c(x = 43, y = 44) # named dim
(s = st_as_stars(m))
attr(s, "dimensions")[[1]]$offset = offset[1]
attr(s, "dimensions")[[2]]$offset = offset[4]
attr(s, "dimensions")[[1]]$delta = 1000
attr(s, "dimensions")[[2]]$delta = -1000
st_crs(s) <- st_crs(catch)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment