This accessory function extract some useful metadata from a vector of raster paths.

raster_metadata(raster_paths, meta = "all", format = "data.table")

Arguments

raster_paths

A vector of raster paths.

meta

Vector with the desired metadata: one or more values among 'res', 'size', 'bbox', 'proj', 'unit', 'outformat', 'type'. Alternatively meta = 'all' (default) allows to return all metadata.

format

One between data.table (default), data.frame and list.

Value

A data.table, data.frame or list of the output metadata.

Note

License: GPL 3.0

References

L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). "sen2r": An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. DOI: 10.1016/j.cageo.2020.104473, URL: http://sen2r.ranghetti.info/.

Author

Luigi Ranghetti, phD (2019) luigi@ranghetti.info

Examples

# Define product names examplenames <- c( system.file("tif/L7_ETMs.tif", package="stars"), system.file("extdata/out/S2A2A_20190723_022_Barbellino_BOA_10.tif", package = "sen2r") ) # \donttest{ # Return metadata as data.table raster_metadata(examplenames)
#> path #> 1: /home/lranghetti/R/x86_64-pc-linux-gnu-library/4.0/stars/tif/L7_ETMs.tif #> 2: /home/lranghetti/share/git/github/ranghetti/sen2r/inst/extdata/out/S2A2A_20190723_022_Barbellino_BOA_10.tif #> valid res.x res.y size.x size.y nbands xmin ymin xmax ymax #> 1: TRUE 28.5 28.5 349 352 6 288776.3 9110729 298722.8 9120761 #> 2: TRUE 10.0 10.0 24 42 11 580560.0 5101700 580800.0 5102120 #> proj #> 1: PROJCRS["unknown",\n BASEGEOGCRS["unknown",\n DATUM["Unknown based on GRS80 ellipsoid",\n ELLIPSOID["GRS 1980",6378137,298.257222101,\n LENGTHUNIT["metre",1],\n ID["EPSG",7019]]],\n PRIMEM["Greenwich",0,\n ANGLEUNIT["degree",0.0174532925199433],\n ID["EPSG",8901]]],\n CONVERSION["UTM zone 25S",\n METHOD["Transverse Mercator",\n ID["EPSG",9807]],\n PARAMETER["Latitude of natural origin",0,\n ANGLEUNIT["degree",0.0174532925199433],\n ID["EPSG",8801]],\n PARAMETER["Longitude of natural origin",-33,\n ANGLEUNIT["degree",0.0174532925199433],\n ID["EPSG",8802]],\n PARAMETER["Scale factor at natural origin",0.9996,\n SCALEUNIT["unity",1],\n ID["EPSG",8805]],\n PARAMETER["False easting",500000,\n LENGTHUNIT["metre",1],\n ID["EPSG",8806]],\n PARAMETER["False northing",10000000,\n LENGTHUNIT["metre",1],\n ID["EPSG",8807]],\n ID["EPSG",17025]],\n CS[Cartesian,2],\n AXIS["(E)",east,\n ORDER[1],\n LENGTHUNIT["metre",1,\n ID["EPSG",9001]]],\n AXIS["(N)",north,\n ORDER[2],\n LENGTHUNIT["metre",1,\n ID["EPSG",9001]]]] #> 2: EPSG:32632 #> unit outformat type #> 1: metre GTiff Byte #> 2: metre GTiff UInt16
# } # Return some metadata as data.table raster_metadata(examplenames, c("res", "size", "bbox", "outformat"))
#> path #> 1: /home/lranghetti/R/x86_64-pc-linux-gnu-library/4.0/stars/tif/L7_ETMs.tif #> 2: /home/lranghetti/share/git/github/ranghetti/sen2r/inst/extdata/out/S2A2A_20190723_022_Barbellino_BOA_10.tif #> valid res.x res.y size.x size.y xmin ymin xmax ymax outformat #> 1: TRUE 28.5 28.5 349 352 288776.3 9110729 298722.8 9120761 GTiff #> 2: TRUE 10.0 10.0 24 42 580560.0 5101700 580800.0 5102120 GTiff
# Return some metadata as list raster_metadata(examplenames, c("res", "size", "bbox", "proj"), format = "list")
#> [[1]] #> [[1]]$path #> [1] "/home/lranghetti/R/x86_64-pc-linux-gnu-library/4.0/stars/tif/L7_ETMs.tif" #> #> [[1]]$valid #> [1] TRUE #> #> [[1]]$res #> x y #> 28.5 28.5 #> #> [[1]]$size #> x y #> 349 352 #> #> [[1]]$bbox #> xmin ymin xmax ymax #> 288776.3 9110728.8 298722.8 9120760.8 #> #> [[1]]$proj #> Coordinate Reference System: #> User input: UTM Zone 25, Southern Hemisphere #> wkt: #> BOUNDCRS[ #> SOURCECRS[ #> PROJCRS["UTM Zone 25, Southern Hemisphere", #> BASEGEOGCRS["GRS 1980(IUGG, 1980)", #> DATUM["unknown", #> ELLIPSOID["GRS80",6378137,298.257222101, #> LENGTHUNIT["metre",1, #> ID["EPSG",9001]]]], #> PRIMEM["Greenwich",0, #> ANGLEUNIT["degree",0.0174532925199433, #> ID["EPSG",9122]]]], #> CONVERSION["Transverse Mercator", #> METHOD["Transverse Mercator", #> ID["EPSG",9807]], #> PARAMETER["Latitude of natural origin",0, #> ANGLEUNIT["degree",0.0174532925199433], #> ID["EPSG",8801]], #> PARAMETER["Longitude of natural origin",-33, #> ANGLEUNIT["degree",0.0174532925199433], #> ID["EPSG",8802]], #> PARAMETER["Scale factor at natural origin",0.9996, #> SCALEUNIT["unity",1], #> ID["EPSG",8805]], #> PARAMETER["False easting",500000, #> LENGTHUNIT["metre",1], #> ID["EPSG",8806]], #> PARAMETER["False northing",10000000, #> LENGTHUNIT["metre",1], #> ID["EPSG",8807]]], #> CS[Cartesian,2], #> AXIS["easting",east, #> ORDER[1], #> LENGTHUNIT["metre",1, #> ID["EPSG",9001]]], #> AXIS["northing",north, #> ORDER[2], #> LENGTHUNIT["metre",1, #> ID["EPSG",9001]]]]], #> TARGETCRS[ #> GEOGCRS["WGS 84", #> DATUM["World Geodetic System 1984", #> ELLIPSOID["WGS 84",6378137,298.257223563, #> LENGTHUNIT["metre",1]]], #> PRIMEM["Greenwich",0, #> ANGLEUNIT["degree",0.0174532925199433]], #> CS[ellipsoidal,2], #> AXIS["geodetic latitude (Lat)",north, #> ORDER[1], #> ANGLEUNIT["degree",0.0174532925199433]], #> AXIS["geodetic longitude (Lon)",east, #> ORDER[2], #> ANGLEUNIT["degree",0.0174532925199433]], #> USAGE[ #> SCOPE["unknown"], #> AREA["World"], #> BBOX[-90,-180,90,180]], #> ID["EPSG",4326]]], #> ABRIDGEDTRANSFORMATION["Transformation to WGS84", #> METHOD["Position Vector transformation (geog2D domain)", #> ID["EPSG",9606]], #> PARAMETER["X-axis translation",0, #> ID["EPSG",8605]], #> PARAMETER["Y-axis translation",0, #> ID["EPSG",8606]], #> PARAMETER["Z-axis translation",0, #> ID["EPSG",8607]], #> PARAMETER["X-axis rotation",0, #> ID["EPSG",8608]], #> PARAMETER["Y-axis rotation",0, #> ID["EPSG",8609]], #> PARAMETER["Z-axis rotation",0, #> ID["EPSG",8610]], #> PARAMETER["Scale difference",1, #> ID["EPSG",8611]]]] #> #> #> [[2]] #> [[2]]$path #> [1] "/home/lranghetti/share/git/github/ranghetti/sen2r/inst/extdata/out/S2A2A_20190723_022_Barbellino_BOA_10.tif" #> #> [[2]]$valid #> [1] TRUE #> #> [[2]]$res #> x y #> 10 10 #> #> [[2]]$size #> x y #> 24 42 #> #> [[2]]$bbox #> xmin ymin xmax ymax #> 580560 5101700 580800 5102120 #> #> [[2]]$proj #> Coordinate Reference System: #> User input: WGS 84 / UTM zone 32N #> wkt: #> PROJCRS["WGS 84 / UTM zone 32N", #> BASEGEOGCRS["WGS 84", #> DATUM["World Geodetic System 1984", #> ELLIPSOID["WGS 84",6378137,298.257223563, #> LENGTHUNIT["metre",1]]], #> PRIMEM["Greenwich",0, #> ANGLEUNIT["degree",0.0174532925199433]], #> ID["EPSG",4326]], #> CONVERSION["UTM zone 32N", #> METHOD["Transverse Mercator", #> ID["EPSG",9807]], #> PARAMETER["Latitude of natural origin",0, #> ANGLEUNIT["degree",0.0174532925199433], #> ID["EPSG",8801]], #> PARAMETER["Longitude of natural origin",9, #> ANGLEUNIT["degree",0.0174532925199433], #> ID["EPSG",8802]], #> PARAMETER["Scale factor at natural origin",0.9996, #> SCALEUNIT["unity",1], #> ID["EPSG",8805]], #> PARAMETER["False easting",500000, #> LENGTHUNIT["metre",1], #> ID["EPSG",8806]], #> PARAMETER["False northing",0, #> LENGTHUNIT["metre",1], #> ID["EPSG",8807]]], #> CS[Cartesian,2], #> AXIS["(E)",east, #> ORDER[1], #> LENGTHUNIT["metre",1]], #> AXIS["(N)",north, #> ORDER[2], #> LENGTHUNIT["metre",1]], #> USAGE[ #> SCOPE["unknown"], #> AREA["World - N hemisphere - 6°E to 12°E - by country"], #> BBOX[0,6,84,12]], #> ID["EPSG",32632]] #> #>
# Output with an invalid raster examplenames <- c( examplenames, system.file("extdata/settings/gdal_formats.json", package="sen2r") ) raster_metadata(examplenames, c("bbox", "proj"))
#> trying to read file: /home/lranghetti/share/git/github/ranghetti/sen2r/inst/extdata/settings/gdal_formats.json
#> path #> 1: /home/lranghetti/R/x86_64-pc-linux-gnu-library/4.0/stars/tif/L7_ETMs.tif #> 2: /home/lranghetti/share/git/github/ranghetti/sen2r/inst/extdata/out/S2A2A_20190723_022_Barbellino_BOA_10.tif #> 3: /home/lranghetti/share/git/github/ranghetti/sen2r/inst/extdata/settings/gdal_formats.json #> valid xmin ymin xmax ymax #> 1: TRUE 288776.3 9110729 298722.8 9120761 #> 2: TRUE 580560.0 5101700 580800.0 5102120 #> 3: FALSE NA NA NA NA #> proj #> 1: PROJCRS["unknown",\n BASEGEOGCRS["unknown",\n DATUM["Unknown based on GRS80 ellipsoid",\n ELLIPSOID["GRS 1980",6378137,298.257222101,\n LENGTHUNIT["metre",1],\n ID["EPSG",7019]]],\n PRIMEM["Greenwich",0,\n ANGLEUNIT["degree",0.0174532925199433],\n ID["EPSG",8901]]],\n CONVERSION["UTM zone 25S",\n METHOD["Transverse Mercator",\n ID["EPSG",9807]],\n PARAMETER["Latitude of natural origin",0,\n ANGLEUNIT["degree",0.0174532925199433],\n ID["EPSG",8801]],\n PARAMETER["Longitude of natural origin",-33,\n ANGLEUNIT["degree",0.0174532925199433],\n ID["EPSG",8802]],\n PARAMETER["Scale factor at natural origin",0.9996,\n SCALEUNIT["unity",1],\n ID["EPSG",8805]],\n PARAMETER["False easting",500000,\n LENGTHUNIT["metre",1],\n ID["EPSG",8806]],\n PARAMETER["False northing",10000000,\n LENGTHUNIT["metre",1],\n ID["EPSG",8807]],\n ID["EPSG",17025]],\n CS[Cartesian,2],\n AXIS["(E)",east,\n ORDER[1],\n LENGTHUNIT["metre",1,\n ID["EPSG",9001]]],\n AXIS["(N)",north,\n ORDER[2],\n LENGTHUNIT["metre",1,\n ID["EPSG",9001]]]] #> 2: EPSG:32632 #> 3: <NA>