This script extracts reflectance spectra of 3 objects from a VISNIR hyperspectral image acquired with a demo unit of the Specim IQ system in HSILab premises on 20180918:
A conventional RGB image in png format is automatically recorded by a dedicated CCD in Specim IQ. By some reason, this image is rotated vs. the hyperspectral one, so the code rotates it.
class : SpatVector
geometry : polygons
dimensions : 15, 4 (geometries, attributes)
extent : 121.7782, 495.9103, -354.6019, -131.6486 (xmin, xmax, ymin, ymax)
source : 013detailed.shp
coord. ref. : ETRS89 / UTM zone 31N (EPSG:25831)
names : id Name Descript State
type : <int> <chr> <chr> <chr>
values : 15 White White ref hydrated
1 h1 NA hydrated
2 h2 NA hydrated
Code
#knitr::kable(p)
2. Make consistent geometry and display
In case the CRS is not defined (and this is the unfortunate case of Specim hdr files), R and QGIS assume, by default, different geometry for the same tiff. As a consequence, polygons digitized in QGIS do not overlay the raster image in R. The code must account for this fact, making a consistent geometry for raster and vector layer, which we confirm in the display: