Home > Blockchain >  How to constuct lon, lat, value dataframe from terra SpatRaster
How to constuct lon, lat, value dataframe from terra SpatRaster

Time:09-22

I have read a single-variable .nc file into R as a SpatRaster object using the excellent enter image description here

p <- terra::as.points(r)
df <- data.frame(values(p), geom(p))
head(df)
#>       lyr.1 geom part    x  y hole
#> 1 0.9557333    1    1 -162 81    0
#> 2 0.2974196    2    1 -126 81    0
#> 3 0.9703617    3    1  -90 81    0
#> 4 0.3046196    4    1  -54 81    0
#> 5 0.7334711    5    1  -18 81    0
#> 6 0.8880635    6    1   18 81    0
  • Related