library(terra)
5 GDAL Virtual File Systems
5.1 Reading the data from a GeoTIFF file
vsicurl
: https://gdal.org/drivers/raster/vsicurl.html is a GDAL virtual file system that allows reading files from a URL.
<- terra::rast(
r "/vsicurl/https://gebco2023.s3.valeria.science/gebco_2023_sub_ice_topo_cog.tif"
)
r
class : SpatRaster
dimensions : 43200, 86400, 1 (nrow, ncol, nlyr)
resolution : 0.004166667, 0.004166667 (x, y)
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
coord. ref. : lon/lat WGS 84 (EPSG:4326)
source : gebco_2023_sub_ice_topo_cog.tif
name : gebco_2023_sub_ice_topo_cog
plot(r)
5.2 vsigzip
vsigzip
: https://gdal.org/drivers/raster/vsigzip.html is a GDAL virtual file system that allows reading files from a gzip compressed file.
<- rast(
sic "/vsigzip//vsicurl/ftp://ftp-projects.cen.uni-hamburg.de/seaice/AMSR2/3.125km/Arc_20201010_res3.125_pyres.nc.gz",
"sea_ice_concentration"
)
sic
class : SpatRaster
dimensions : 3584, 2432, 1 (nrow, ncol, nlyr)
resolution : 1, 1 (x, y)
extent : 0.5, 2432.5, 0.5, 3584.5 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs
source : Arc_20201010_res3.125_pyres.nc.gz:sea_ice_concentration
varname : sea_ice_concentration (daily averaged total ice concentration)
name : sea_ice_concentration
unit : %
time : 2020-10-10 12:00:00 UTC
plot(sic)
From the documentation, we expect that data to be in polar stereographic projection with a specific extent. However, the data does not have the correct extent and projection. We can set the extent and projection manually:
# Set the extent
ext(sic) <- ext(-3850000L, 3750000L, -5350000L, 5850000L)
# Set the polar stereographic projection
crs(sic) <- "EPSG:3413"
sic
class : SpatRaster
dimensions : 3584, 2432, 1 (nrow, ncol, nlyr)
resolution : 3125, 3125 (x, y)
extent : -3850000, 3750000, -5350000, 5850000 (xmin, xmax, ymin, ymax)
coord. ref. : WGS 84 / NSIDC Sea Ice Polar Stereographic North (EPSG:3413)
source : Arc_20201010_res3.125_pyres.nc.gz:sea_ice_concentration
varname : sea_ice_concentration (daily averaged total ice concentration)
name : sea_ice_concentration
unit : %
time : 2020-10-10 12:00:00 UTC
Now the data has the correct extent and projection. Each pixel represents the sea ice concentration in a 3.125 km x 3.125 km area.
plot(sic)