[R-sig-Geo] Extract VIIRS data in R

Edzer Pebesma edzer@pebe@m@ @end|ng |rom un|-muen@ter@de
Wed Mar 18 17:24:46 CET 2020


If the product info is in this document:
https://ladsweb.modaps.eosdis.nasa.gov/missions-and-measurements/viirs/NASAVIIRSL1BUGAug2019.pdf

then it sounds like these data are distributed as curvilinear grids,
meaning that there are two additional raster with for each pixel the
longitude and the latitude. The file you pointed to does not contain
these two grids, but you should be able to get them at the place where
you got the data. With that, you can use package stars to load them, and
e.g. resample to some (more) regular grid.

See e.g.
https://r-spatial.github.io/stars/articles/stars4.html#curvilinear-grids

On 3/18/20 3:29 PM, Michael Sumner wrote:
> You won't find much on this kind of file in the R community, this is
> relatively new NetCDF-4 with "groups", and contains a satellite "granule" -
> a kind of pre-mapping raw data array with only technical information about
> where the scanning occurred.
> 
> In short, raster and stars package (and RNetCDF and ncdf4) will read the
> data from this file, but give very little or no help for how to treat it
> like a map. The spatial resolution and extent are purely nominal as shown
> by raster, a spacing of 1 in two dimensions and extending from 0 to nrows,
> 0 to ncols (with a  half cell shift). There aren't any coordinate arrays in
> the file, or any simple way to transform from this matrix-space to
> geography as far as I know.  (Would love to be corrected on how to do
> that).
> 
> You'd need to pursue domain-specific expertise to discover the mapping of
> this, unless some kind soul turns up to help here. I expect you'll want to
> find a product that has been converted into simpler form for these data.
> 
> Cheers, Mike.
> 
> 
> On Wed, Mar 18, 2020 at 1:39 AM Miluji Sb <milujisb using gmail.com> wrote:
> 
>> Dear all,
>>
>> Hope everyone is keeping safe.
>>
>> I am trying to extract/read VIIRS nighttime lights data but the output
>> seems rather strange.
>>
>> I have uploaded the file here
>> <https://drive.google.com/open?id=1zpqXJ8AlEcnk6ApRb75tfQc4-Y8AfK5h> so as
>> not exceed the size limit of the email.
>>
>> ## Code ##
>> library(ncdf4)
>> library(rgdal)
>>
>> netcdf_file <- c("VNP02DNB_NRT.A2020069.1048.001.nc")
>> nl <- brick(netcdf_file, lvar=0, values=TRUE,
>> varname="observation_data/DNB_observations")
>>
>> ## Detail ##
>> class      : RasterLayer
>> dimensions : 3232, 4064, 13134848  (nrow, ncol, ncell)
>> resolution : 1, 1  (x, y)
>> extent     : 0.5, 4064.5, 0.5, 3232.5  (xmin, xmax, ymin, ymax)
>> crs        : NA
>> source     : C:/Users/shour/Desktop/VNP02DNB_NRT.A2020069.1048.001.nc
>> names      : DNB.observations.at.pixel.locations
>> zvar       : observation_data/DNB_observations
>>
>> The spatial resolution is supposed to be 750m but this shows 1°. What am I
>> doing wrong? Any help will be greatly appreciated. Thank you.
>>
>> Sincerely,
>>
>> Millu
>>
>>         [[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, 48149 Muenster, Germany
Phone: +49 251 8333081

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pEpkey.asc
Type: application/pgp-keys
Size: 3110 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20200318/e6388a96/attachment.bin>


More information about the R-sig-Geo mailing list