After you extracted data from the EBV netCDF and worked with it this function gives you the possibility to write it to disk as a GeoTiff.
ebv_write(
data,
outputpath,
epsg = 4326,
extent = c(-180, 180, -90, 90),
type = "FLT8S",
overwrite = FALSE,
verbose = TRUE
)
Your data object. May be SpatRaster, array, DelayedMatrix or list
of DelayedMatrix (see return values of ebv_read()
)
Character. Set the path where you want to write the data to disk as a GeoTiff. Ending needs to be *.tif.
Integer. Default: 4326 (WGS84). Defines the coordinate reference system via the corresponding epsg code.
Numeric. Default: c(-180,180,-90,90). Defines the extent of the data: c(xmin, xmax, ymin, ymax).
Character. Default is FLT8S Indicate the datatype of the GeoTiff file. Possible values: INT1S, INT2S, INT2U, INT4S, INT4U, FLT4S, FLT8S.
Locigal. Default: FALSE. Set to TRUE to overwrite the outputfile defined by 'outputpath'.
Logical. Default: TRUE. Turn off additional prints by setting it to FALSE.
Returns the outputpath.
If the nodata value of your data is not detected correctly, this could be due to the wrong choice of the datatype (type argument).
#set path to EBV netCDF
file <- system.file(file.path("extdata","martins_comcom_subset.nc"), package="ebvcube")
#get all datacubepaths of EBV netCDF
datacubes <- ebv_datacubepaths(file, verbose=FALSE)
if (FALSE) {
#read data
data <- ebv_read(filepath = file, datacubepath = datacubes[1,1], timestep = 1, entity = 1)
# HERE YOU CAN WORK WITH YOUR DATA
#write data to disk as GeoTiff
out <- file.path(system.file(package='ebvcube'),"extdata","write_data.tif")
ebv_write(data = data, outputpath = out, overwrite = TRUE)
#read a subset
data_bb <- ebv_read_bb(filepath = file, datacubepath = datacubes[1,1],
entity = 1, timestep = 1:3, bb = c(-26, 64, 30, 38))
#write subset to disk as GeoTiff
ebv_write(data = data_bb, outputpath = out, extent = c(-26, 64, 30, 38), overwrite = TRUE)
}