I've downloaded and import a Level 3 netcdf file for the OMI instrument. You can download a sample here: https://data.gesdisc.earthdata.nasa.gov/login?code=nY1ztQoDBlvAgq4cM19h-uxNn54_nx7l0wtOgykcznvRxbtvxyHDlJrGZkF1nRFufubxyNwsOmq6jcURkTWn&state=%2Fdata%2FMINDS%2FOMI_MINDS_NO2d.1.1%2F2016%2FOMI-Aura_L3-OMI_MINDS_NO2d_2016m0105_v01-01-2022m0218t115317.nc
I'm using the terra package to import it as follows:
path = "OMI-Aura_L3-OMI_MINDS_NO2d_2016m0101_v01-01-2022m0218t115312.nc"
r1 <- terra::rast(path,subds = "ColumnAmountNO2") ## select the variable name
plot(r1)
It's returning the following error:
Error in plot.xy(xy, type, ...) :
invalid type passed to graphics function
But the output of r1 looks good:
> r1
class : SpatRaster
dimensions : 720, 1440, 1 (nrow, ncol, nlyr)
resolution : 0.25, 0.25 (x, y)
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +a=6378137 +rf=298.25723 +no_defs
source : OMI-Aura_L3-OMI_MINDS_NO2d_2016m0101_v01-01-2022m0218t115312.nc:ColumnAmountNO2
varname : ColumnAmountNO2 (NO2 Vertical Column Density)
name : ColumnAmountNO2_Time=16071.5
unit : molec/cm2
What am I doing wrong?
As pointed out by Grzegorz Sapijaszko you need to explicitly use terra::plot
or use library(terra)
Problem:
x <- terra::rast(ncol=10, nrow=10, vals=1:100)
plot(x)
#Error in plot.xy(xy, type, ...) :
# invalid type passed to graphics function
Solution:
terra::plot(x)
Or
library(terra)
plot(x)