[R-sig-Geo] raster - units assignment error in reading NetCDF4
Edzer Pebesma
edzer@pebe@m@ @end|ng |rom un|-muen@ter@de
Tue Apr 30 14:28:12 CEST 2019
It looks like this is a curvilinear grid; you could read & plot it with
library(stars)
r = read_stars("L8_OLI_2017_03_18_00_09_19_093086_L2R.nc", curvilinear =
c("lon", "lat"))
plot(r[1], border = NA)
Printing r shows the units of each of the variables. The plotting takes
a while because the data grid is not aligned with the pixel grid of the
plotting device.
On 4/30/19 12:43 PM, Alexandre Castagna wrote:
> Hi group,
>
> I'm trying to read a NetCDF4 file, but I get the following error message:
>
> fl <- 'L8_OLI_2017_03_18_00_09_19_093086_L2R.nc'
> r <- raster(fl, varname = 'rhos_443')
>
> Error in (function (cl, name, valueClass) :
> assignment of an object of class “numeric” is not valid for @‘unit’ in an
> object of class “.SingleLayerData”; is(value, "character") is not TRUE
>
> This data is OLI Landsat 8 atmospheric 'corrected' imagery with the ACOLITE
> software (link <https://github.com/acolite/acolite>).
> In a previous version of the software, exploring the file after nc_open
> function revealed that units was numeric ('num' qualifier was shown in R
> object print); but since, the developer has committed a change for all
> units to be written as characters. The unit in question is '1' (unitless,
> for bihemispherical reflectance). A new exploration after the update to
> check the units type does not show the qualifier 'num' anymore, but the
> error keep the same. Maybe R is translating '1' to 1 automatically?
>
> I can go around and create a raster directly from data read with ncdf4
> package, like:
>
> ncfl <- nc_open(fl)
> r <- raster(t(ncvar_get(ncfl, 'rhos_443')))
>
> But for a number of reasons that is less ideal. A temporary link to
> download the example data file is: https://we.tl/t-nENAV7tmBg
>
> Kind regards,
>
> Alexandre Castagna Mourão e Lima
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 2472 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20190430/9f46bdef/attachment.bin>
More information about the R-sig-Geo
mailing list