Tuesday 27 August 2019

R stars package and set dimensions to a NetCDF file


Related: GDAL and reprojecting a NetCDF file


Following above, I would like to reproject a NetCDF ( NOAA GOES-16 file ) using R stars package. However, I have been unsuccessful at the first step; I mean, unable to assign original CRS information to the file.


Parameters I want to assign were obtained by gdalinfo:


Proj.4 string = "+proj=geos +lon_0=-75 +h=35786023 +x_0=0 +y_0=0 +ellps=GRS80 +units=m +no_defs  +sweep=x"
Origin = (-3627271.328111211769283,1583173.512170388596132)
Pixel Size = (1002.008657743770527,1002.008657743770527)

My failed R code is:



library(stars)              # stars package 0.3-0

nc1= "./OR_ABI-L1b-RadC-M3C01_G16_s20190611802132_e20190611804505_c20190611804549.nc"
(nc1_s1= read_stars(nc1, along= c("DQF", "Rad")))
crs_proj4 = "+proj=geos +lon_0=-75 +h=35786023 +x_0=0 +y_0=0 +ellps=GRS80 +units=m +no_defs +sweep=x"

nc1_out = st_set_dimensions(nc1_s1,
offset= c(-3627271.328111211769283, 1583173.512170388596132),
delta= c(1002.008657743770527, 1002.008657743770527),
refsys= c(crs_proj4, crs_proj4)

)
nc1_out

As my code did not take effect, both nc1_s1 (input to st_set_dimensions()) and nc1_out (its output) show the same dimensions as below.


stars object with 2 dimensions and 2 attributes
attribute(s), summary of first 1e+05 cells:
X..DQF X..Rad
Min. : 0.0 Min. : 157.0
1st Qu.: 0.0 1st Qu.: 256.0
Median : 0.0 Median : 329.0

Mean : 36.5 Mean : 408.8
3rd Qu.: 0.0 3rd Qu.: 396.0
Max. :255.0 Max. :1023.0
dimension(s):
from to offset delta refsys point values
x 1 5000 NA NA NA NA NULL [x]
y 1 3000 NA NA NA NA NULL [y]

How can I set dimensions to NetCDF using stars package?





[Update] This is my environment (see comment by Spacedman that this is not reproducible).



  • R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"

  • Running R in Rstudio Version 1.1.463

  • Windows10 (64bit)

  • library {stars 0.3-0} is linked to {GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3}




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...