Closed alexyshr closed 4 years ago
With stars
installed from github, I see
> st_dimensions(p)$band$values
[1] "B4" "B3" "B2" "B8"
Also:
> gdal_utils("info", p)
Error in CPL_gdalinfo(source, options, oo) :
Not compatible with STRSXP: [type=list].
> gdal_utils("info", s2)
Driver: SENTINEL2/Sentinel 2
Files: /vsizip//home/edzer/R/x86_64-pc-linux-gnu-library/4.0/starsdata/sentinel/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.zip/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/MTD_MSIL1C.xml
/vsizip//home/edzer/R/x86_64-pc-linux-gnu-library/4.0/starsdata/sentinel/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.zip/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/GRANULE/L1C_T32ULE_A013919_20180220T105539/MTD_TL.xml
/vsizip//home/edzer/R/x86_64-pc-linux-gnu-library/4.0/starsdata/sentinel/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.zip/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/GRANULE/L1C_T32ULE_A013919_20180220T105539/IMG_DATA/T32ULE_20180220T105051_B04.jp2
/vsizip//home/edzer/R/x86_64-pc-linux-gnu-library/4.0/starsdata/sentinel/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.zip/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/GRANULE/L1C_T32ULE_A013919_20180220T105539/IMG_DATA/T32ULE_20180220T105051_B03.jp2
/vsizip//home/edzer/R/x86_64-pc-linux-gnu-library/4.0/starsdata/sentinel/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.zip/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/GRANULE/L1C_T32ULE_A013919_20180220T105539/IMG_DATA/T32ULE_20180220T105051_B02.jp2
/vsizip//home/edzer/R/x86_64-pc-linux-gnu-library/4.0/starsdata/sentinel/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.zip/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/GRANULE/L1C_T32ULE_A013919_20180220T105539/IMG_DATA/T32ULE_20180220T105051_B08.jp2
Size is 10980, 10980
Coordinate System is:
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["easting",east,
ORDER[1],
LENGTHUNIT["metre",1]],
AXIS["northing",north,
ORDER[2],
LENGTHUNIT["metre",1]],
ID["EPSG",32632]]
Data axis to CRS axis mapping: 1,2
Origin = (300000.000000000000000,6000000.000000000000000)
Pixel Size = (10.000000000000000,-10.000000000000000)
Metadata:
CLOUD_COVERAGE_ASSESSMENT=66.2526
DATATAKE_1_DATATAKE_SENSING_START=2018-02-20T10:50:51.026Z
DATATAKE_1_DATATAKE_TYPE=INS-NOBS
DATATAKE_1_ID=GS2A_20180220T105051_013919_N02.06
DATATAKE_1_SENSING_ORBIT_DIRECTION=DESCENDING
DATATAKE_1_SENSING_ORBIT_NUMBER=51
DATATAKE_1_SPACECRAFT_NAME=Sentinel-2A
DEGRADED_ANC_DATA_PERCENTAGE=0.0
DEGRADED_MSI_DATA_PERCENTAGE=0
FORMAT_CORRECTNESS=PASSED
GENERAL_QUALITY=PASSED
GENERATION_TIME=2018-02-21T13:40:37.000000Z
GEOMETRIC_QUALITY=PASSED
PREVIEW_GEO_INFO=Not applicable
PREVIEW_IMAGE_URL=Not applicable
PROCESSING_BASELINE=02.06
PROCESSING_LEVEL=Level-1C
PRODUCT_START_TIME=2018-02-20T10:50:51.026Z
PRODUCT_STOP_TIME=2018-02-20T10:50:51.026Z
PRODUCT_TYPE=S2MSI1C
PRODUCT_URI=S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE
QUANTIFICATION_VALUE=10000
RADIOMETRIC_QUALITY=PASSED
REFLECTANCE_CONVERSION_U=1.02459181087746
SENSOR_QUALITY=PASSED
SPECIAL_VALUE_NODATA=0
SPECIAL_VALUE_SATURATED=65535
Image Structure Metadata:
COMPRESSION=JPEG2000
Corner Coordinates:
Upper Left ( 300000.000, 6000000.000) ( 5d56'25.46"E, 54d 6'33.14"N)
Lower Left ( 300000.000, 5890200.000) ( 6d 0'39.28"E, 53d 7'25.12"N)
Upper Right ( 409800.000, 6000000.000) ( 7d37' 9.32"E, 54d 8'24.67"N)
Lower Right ( 409800.000, 5890200.000) ( 7d39' 4.03"E, 53d 9'12.73"N)
Center ( 354900.000, 5945100.000) ( 6d48'19.52"E, 53d38' 4.35"N)
Band 1 Block=128x128 Type=UInt16, ColorInterp=Red
Description = B4, central wavelength 665 nm
Overviews: 5490x5490, 2745x2745, 1373x1373, 687x687
Metadata:
BANDNAME=B4
BANDWIDTH=30
BANDWIDTH_UNIT=nm
SOLAR_IRRADIANCE=1512.06
SOLAR_IRRADIANCE_UNIT=W/m2/um
WAVELENGTH=665
WAVELENGTH_UNIT=nm
Image Structure Metadata:
NBITS=15
Band 2 Block=128x128 Type=UInt16, ColorInterp=Green
Description = B3, central wavelength 560 nm
Overviews: 5490x5490, 2745x2745, 1373x1373, 687x687
Metadata:
BANDNAME=B3
BANDWIDTH=35
BANDWIDTH_UNIT=nm
SOLAR_IRRADIANCE=1823.24
SOLAR_IRRADIANCE_UNIT=W/m2/um
WAVELENGTH=560
WAVELENGTH_UNIT=nm
Image Structure Metadata:
NBITS=15
Band 3 Block=128x128 Type=UInt16, ColorInterp=Blue
Description = B2, central wavelength 490 nm
Overviews: 5490x5490, 2745x2745, 1373x1373, 687x687
Metadata:
BANDNAME=B2
BANDWIDTH=65
BANDWIDTH_UNIT=nm
SOLAR_IRRADIANCE=1959.72
SOLAR_IRRADIANCE_UNIT=W/m2/um
WAVELENGTH=490
WAVELENGTH_UNIT=nm
Image Structure Metadata:
NBITS=15
Band 4 Block=128x128 Type=UInt16, ColorInterp=Undefined
Description = B8, central wavelength 842 nm
Overviews: 5490x5490, 2745x2745, 1373x1373, 687x687
Metadata:
BANDNAME=B8
BANDWIDTH=115
BANDWIDTH_UNIT=nm
SOLAR_IRRADIANCE=1041.63
SOLAR_IRRADIANCE_UNIT=W/m2/um
WAVELENGTH=842
WAVELENGTH_UNIT=nm
Image Structure Metadata:
NBITS=15
It would be nice if we could address the bands by name in the ndvi
function, rather than by number.
According to this, the description for the 10 meters bands of sentinel 2 are:
So the function to calculate NDVI ((NIR – RED) / (NIR + RED)) in Vignette Stars Proxy Objects need to be changed from:
ndvi = function(x) (x[4] - x[1])/(x[4] + x[1])
to:ndvi = function(x) (x[4] - x[3])/(x[4] + x[3])
I am using
gdalUtils::gdalinfo
to check the content of the Sentinel 2 file present instarsdata
package (not available in R version 4.0.2)