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)

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  
  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}
  • I don't see that at all. I get some warnings when reading the nc files, nc1_s1 already has that CRS and metadata set correctly, and so does nc1_out. Also, the variables in nc1_out are in a different order to yours and don't have a X.. prefix, and have different values (DQF has max 2.0, Rad is 52.03 to 647.30). So I don't think the file you linked to is the one you are showing here. – Spacedman Mar 9 at 9:27
  • Thank you @Spacedman I will check files I have. – Kazuhito Mar 9 at 9:33
  • @Spacedman I downloaded the same file (direct from my link). I still get the same output (attributes headers are X..DQF, X..Rad, and dimensions are full of NAs). I will edit my question with my R environment. – Kazuhito Mar 9 at 9:40
  • I'm on stars 0.3.0 – Spacedman Mar 9 at 9:43
  • @Spacedman Me, too. (Added environment information to my question). – Kazuhito Mar 9 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.