RemoteS
Index
RemoteS.classification_probaRemoteS.classifyRemoteS.classifyRemoteS.clgRemoteS.clip_orbitsRemoteS.clreRemoteS.cutcubeRemoteS.dn2radianceRemoteS.dn2reflectanceRemoteS.dn2temperatureRemoteS.eviRemoteS.evi2RemoteS.findscenesRemoteS.gliRemoteS.gndviRemoteS.grid_at_sensorRemoteS.mcariRemoteS.mndwiRemoteS.msaviRemoteS.mtciRemoteS.nbriRemoteS.ndrei1RemoteS.ndrei2RemoteS.ndviRemoteS.ndwiRemoteS.ndwi2RemoteS.read_mtlRemoteS.reflectance_surfRemoteS.reportbandsRemoteS.sat_scenesRemoteS.sat_tracksRemoteS.satviRemoteS.saviRemoteS.slaviRemoteS.subcubeRemoteS.tgiRemoteS.train_rasterRemoteS.truecolorRemoteS.variRemoteS.RemoteS
Functions
RemoteS.classify — MethodI = classify(cube::GItype, model; class_names::Union{String, Vector{String}}="") -> GMTimagecube: The cube wtih band data to classify.model: The trained model obtained from thetrain_rasterfunction.class_names: A vector of strings with the class names to be used in the categorical colorbar or a comma separated single with those class names. The number of class names must match the number used when training the model withtrain_raster.
RemoteS.classify — MethodI = classify(cube::GItype, train::Union{Vector{<:GMTdataset}, String}) -> GMTimagecube: The cube wtih band data to classify.train: A vector of GMTdatasets or a file name of one containing the polygons used to train the model. NOTE: The individual datasets MUST have associated an attribute called "class" containing the class name as a string. This can be achieved for text data in the form of a GMT multi-segment file (one where segments are separated by the '>' symbol) if the multi-segment separator line contains the text $Attrib(class=name)$
Returns an image with the classification results where each class name was assigned a different integer number. That colorized image can plotted with $viz(I, colorbar=true)$.
RemoteS.clg — MethodCLG = clg(green, redEdge3; kw...)or
CLG = clg(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Green cholorphyl index. Wu et al 2012.
CLG = (redEdge3)/(green)-1
RemoteS.clip_orbits — Methodclip_orbits(track, BoundingBox::Vector{<:Real})Clips the orbits that are contained inside a rectangular geographical region
track: A GMTdataset or a Mx2 matrix with the orbits [lon, lat] position. This is normally calculated with thesat_tracksfunction.BoundingBox: A vector the region limits made up with [lonmin, lonmax, latmin, latmax]
Returns a GMTdataset vector with the chunks of tracks that cross inside the BoundingBox region.
#Example Suppose orb holds orbits computed with sat_tracks() during 2 days, clip them inside the 20W-10E, 30N-45N window
D = clip_orbits(orb, [-20, 10, 30, 50]);RemoteS.clre — MethodCLRE = clre(redEdge1, redEdge3; kw...)or
CLRE = clre(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)RedEdge cholorphyl index. Clevers and Gitelson 2013.
CLRE = (redEdge3)/(redEdge1)-1
RemoteS.cutcube — Methodcutcube(names=String[], bands=Int[], template="", region=nothing, extension=".TIF", description=String[], mtl="", sentinel2=0, save="")Cut a 3D cube out of a Landsat/Sentinel scene within a subregion region and a selection of bands.
names: (optional) A vector with the individual bands full file namebands: Whennamesis not provided give a vector of integers corresponding to the choosen bands. This works well for Landsat and most of Sentinel bands. However, in later case, there are also bands that contain characters, for example band 8A. In this casebandsshould be a vector of strings including the extension. e.g. ["02.jp2", "8A.jp2"]template: Goes together with thebandsoption. They are both composed a template * band[n] to recreate the full file name of each band.regionIs the region to extract and must contain the extracting region limits as [W, E, S, N] or a GMT style -R string (without the leading "-R").extension: In case thebandsis numeric but file extensions are not "*.TIF" (case insensitive), use the extension passed by this option.description: A vector of strings (as many as bands) with a description for each band. If not provided and the file is recognized as a Landasat 8, band description is added automatically, otherwise we build one with the bands file names. This info will saved if data is written to a file.mtl: If reading from Landsat and the MTL file is not automatically found (you get an error) use this option to pass the full name of the MTL file.sentinel2: ESA is just unconsistent and names change with time and band numbers can have character (e.g. 8A) hence we need help to recognize Sentinel files so the known description can be assigned. Usesentinel=10, or=20or=60to indicate Sentinel files at those resolutions.save: The file name where to save the output. If not provided, a GMTimage is returned.
Return: nothing if the result is written in file or a GMTimage otherwise.
Examples
# Cut a Landsat 8 scene for a small region (in UTM) and return a GMTimage with 3 bands in UInt16.
temp = "C:\SIG_AnaliseDadosSatelite\SIG_ADS\DadosEx2\LC82040332015145LGN00\LC82040332015145LGN00_B";
cube = cutcube(bands=[2,3,4], template=temp, region=[479670,492720,4282230,4294500])
# The same example as above but save the data in a GeoTIFF disk file and use a string for `region`
cutcube(bands=[2,3,4], template=temp, region="479670/492720/4282230/4294500", save="landsat_cube.tif")RemoteS.dn2radiance — MethodR = dn2radiance(fname::String, [band::Int, bandname::String, mtl::String, save::String])Computes the radiance at TopOfAtmosphere of a Landsat 8 file
fname: The name of either a $LANDSAT_PRODUCT_ID$ geotiff band, or the name of a cube file created with thecutcubefunction. In the first case, if the companion $...MTL.txt$ file is not in the same directory asfnameone can still pass it via themtl=path-to-MTL-fileoption. In the second case it is mandatory to use one of the following two options.band: cubes created withcutcubeassign descriptions starting with "Band 1 ..." an so on the other bands. So whenbandis used we search for the band named "Band N", where N =band.bandname: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamestring that will be matched against the cube's bands descriptions. We can use thereportbandsfunction to see the bands description.save: The file name where to save the output. If not provided, a GMTgrid is returned.
Returns a Float32 GMTgrid
Example:
Compute the radiance TOA of Band 2 file.
R = dn2radiance("LC08_L1TP_204033_20210525_20210529_02_T1_B2.TIF")RemoteS.dn2reflectance — MethodR = dn2reflectance(fname::String, [band::Int, bandname::String, mtl::String, save::String])Computes the TopOfAtmosphere planetary reflectance of a Landsat8 file
fname: The name of either a $LANDSAT_PRODUCT_ID$ geotiff band, or the name of a cube file created with thecutcubefunction. In the first case, if the companion $...MTL.txt$ file is not in the same directory asfnameone can still pass it via themtl=path-to-MTL-fileoption. In the second case it is mandatory to use one of the following two options.band: cubes created withcutcubeassign descriptions starting with "Band 1 ..." an so on the other bands. So whenbandis used we search for the band named "Band N", where N =band.bandname: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamestring that will be matched against the cube's bands descriptions. We can use thereportbandsfunction to see the bands description.save: The file name where to save the output. If not provided, a GMTgrid is returned.
Returns a Float32 GMTgrid
Example:
Compute the reflectance TOA of Red Band stored in a cube
R = dn2reflectance(cube, bandname="red")RemoteS.dn2temperature — MethodR = dn2temperature(fname::String; band::Int=0, mtl::String="", save::String)Computes the brigthness temperature of Landasat8 termal band (10 or 11)
fname: The name of either a $LANDSAT_PRODUCT_ID$ geotiff band, or the name of a cube file created with thecutcubefunction. In the first case, if the companion $...MTL.txt$ file is not in the same directory asfnameone can still pass it via themtl=path-to-MTL-fileoption. In the second case it is mandatory to use one of the following two options.band: cubes created withcutcubeassign descriptions starting with "Band 1 ..." an so on the other bands. So whenbandis used we search for the band named "Band N", where N =band.bandname: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamestring that will be matched against the cube's bands descriptions. We can use thereportbandsfunction to see the bands description.save: The file name where to save the output. If not provided, a GMTgrid is returned.
Returns a Float32 GMTgrid
Example:
Compute the brightness temperature of Band 10 stored in a cube
T = dn2temperature(cube, band=10)RemoteS.evi — MethodEVI = evi(blue, red, nir; kw...)or
EVI = evi(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Enhanced vegetation index. Huete et al 1990
EVI = G * ((nir - red) / (nir + C1 * red - C2 * blue + Levi)); C1, C2, G, Levi = 6.0, 7.5, 2.5, 1.
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.evi2 — MethodEVI2 = evi2(red, nir; kw...)or
EVI2 = evi2(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Two-band Enhanced vegetation index. Jiang et al 2008
EVI2 = G * ((nir - red) / (nir + 2.4 * red ))
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.findscenes — Methodfindscenes(lon::Real, lat::Real; kwargs...)Find the names of the scenes that cover the location point lon, lat in the period determined by the dates and satellite set via kwargs.
day: Search only on the day time part of the orbits.night: Search only on the night time part of the orbits.oc: For the AQUA or TERRA satellites pick only the chlorophyl content scenes.sst: For the AQUA or TERRA satellites pick only the Sae Surface Temperature content scenes.sat,SATorsatellite: Name of the satellite to use; choose from (string or symbols) :TERRA, :AQUAstart: A DateTime object or a string convertable to a DateTime withDateTime(start)specifying the start of the looking period. If omited, current time in UTC will be used.duration: Length of time for which the scenes are searched. The duration is expected in days and can be a negative number, meaning we'll look that span days fromstart.stop: As alternative todurationprovide the end date for the serch. Same conditions asstarttleorTLE: a file name with the TLE data for a specific satellite and period. It can also be a two elements string vector with the first and second lines of the TLE file.
Returns
A string vector with the scene names
Example:
Find the AQUA scenes with chlorophyl-a (oceancolor) that cover the point (-8, 36) in the two days before "2021-09-07T17:00:00" Note, this will be accurate for the month of September 2021. For other dates it needs an updated TLE.
tle1 = "1 27424U 02022A 21245.83760660 .00000135 00000-0 39999-4 0 9997";
tle2 = "2 27424 98.2123 186.0654 0002229 67.6025 313.3829 14.57107527 28342";
findscenes(-8,36, start="2021-09-07T17:00:00", sat=:aqua, day=true, duration=-2, oc=1, tle=[tle1, tle2])
2-element Vector{String}:
"A2021251125500.L2_LAC_OC.nc"
"A2021252134000.L2_LAC_OC.nc"RemoteS.gli — MethodGLI = gli(red, green, blue; kw...)or (here fname is a .png or .jpg file name)
GLI = gli(fname::String; kw...)or
GLI = gli(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Green Leaf Index. Louhaichi, M., Borman, M.M., Johnson, D.E., 2001.
GLI = (2green - red - blue) / (2green + red + blue)
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.gndvi — MethodGNDVI = gndvi(green, nir; kw...)or
GNDVI = gndvi(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)green Normalized diff vegetation index: more sensitive to cholorphyll than ndvi. Gitelson, A., and M. Merzlyak
GNDVI = (nir - green) / (nir + green)
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.grid_at_sensor — FunctionG = grid_at_sensor(fname::String, sds_name::String=""; V::Bool=false, kw...)Read one of those netCDF files that are not regular grids but have instead the coordinates in the LONGITUDE and LATITUDE arrays. MODIS L2 files are a good example of this. Data in theses files are not layed down on a regular grid and we must interpolate to get one. Normally the lon and lat arrays are called $longitude$ and $latitude$ and these it's what is seek for by default. But files exist that pretend to comply to CF but use other names. In this case, use the kwargs xarray & yarray to pass in the variable names. For example: xarray="XLONG", yarray="XLAT" The other fundamental info to pass in is the name of the array to be read/interpolated. We do that via the sds_name arg.
band: In simpler cases the variable to be interpolated lays down on a 2D array but it is also possible that it is stored in a 3D array. If that is the case, use the keyword 'band' to select a band (ex: 'band=2') Bands are numbered from 1.region|limits,inc|increment|spacingandsearch_radius: The interpolation is done so far with $nearneighbor$ Both the region (-R) and increment (-I) are estimated from data but they can be set withregionandinckwargs as well. One can also set the $nearneighbor$ serach radius with optionsearch_radius. The defaul is to setsearch_radiusequal to two times the average increment.quality: For MODIS data we can select the quality flag to filter by data quality. By default the best quality (=0) is used, but one can select another with thequality=valkwarg. Positive 'val' values select data of quality <= quality, whilst negative 'val' values select only data with quality >= abs(val). This allows for example to extract only the cloud coverage.t_srsortarget_proj: Some polar grids come with $longitude$, $latitude$ (or just $lon$, $lat$) arrays in geographical coordinates. There must be an (obscure) reason for this but the practical result is messy because coordinate spacings are highly variable preventing any decent guess. In these cases it is useful to reproject the data before griding. For that purpose use thet_srsortarget_projoption to tell the program to do a coordinate conversion before gridding.t_srsshould then be a proj4 string with the destiny projection system.nodata: Sometimes datasets use other than NaN to represent nodata but they don't specify it in the netCDF attributes (e.g. the NSIDC products). This option allows to fix this (i.enodata=-9999) Note that this is automatically set for the NSIDC products.nointerp: Means to not do any nearneighbor interpolation but needs thatregionhas been set.NSIDC_NandNSIDC_S: Set thes_srs,region,nointerp,nodataappropriate to read the See Ice NSIDC https://nsidc.org/data/polar-stereo/ps_grids.html grids.datasetorxyz: If instead of calculating a grid (returned as a GMTgrid type) user wants the x,y,z data intself, use the keywordsdataset, orxyzand the output will be in a GMTdataset (i.e. usedataset=true).
To inquire just the list of available arrays use list=true or gdalinfo=true to get the full file info.
Examples:
G = grid_at_sensor("AQUA_MODIS.20020717T135006.L2.SST.nc", "sst", V=true);
G = grid_at_sensor("TXx-narr-annual-timavg.nc", "T2MAX", xarray="XLONG", yarray="XLAT", V=true);
G = grid_at_sensor("RDEFT4_20101021.nc", "sea_ice_thickness", NSIDC_N=true);RemoteS.mcari — MethodMCARI = mcari(green, red, redEdge1; kw...)or
MCARI = mcari(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Modified Chlorophyll Absorption ratio index. Daughtery et al. 2000
MCARI = (redEdge1 - red - 0.2 * (redEdge1 - green)) * (redEdge1 / red)
(Sentinel-2 Band 5 (VNIR), Band 4 (Red) and Band 3 (Green)).
RemoteS.mndwi — MethodMNDWI = mndwi(green, swir2; kw...)or
MNDWI = mndwi(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Modified Normalised Difference Water Index. Xu2006
MNDWI = (green-swir2) / (green+swir2)
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.msavi — MethodMSAVI = msavi(red, nir; kw...)or
MSAVI = msavi(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Modified soil adjusted vegetation index. Qi 1994
MSAVI = nir + 0.5 - (0.5 * sqrt(pow(2.0 * nir + 1.0, 2) - 8.0 * (nir - (2.0 * red))))
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.mtci — MethodMTCI = mtci(red, redEdge1, redEdge2; kw...)Meris Terrestrial Chlorophyll Index. Clevers and Gitelson 2013, Dash and Curran 2004
MTCI = (redEdge2-redEdge1) / (redEdge1-red)
RemoteS.nbri — MethodNBRI = nbri(nir, swir3; kw...)or
NBRI = nbri(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Normalised Burn Ratio Index. Garcia 1991
NBRI = (nir - swir2) / (nir + swir2)
RemoteS.ndrei1 — MethodNDREI1 = ndrei1(redEdge1, redEdge2; kw...)Normalized difference red edge index. Gitelson and Merzlyak 1994
NDREI1 = (redEdge2 - redEdge1) / (redEdge2 + redEdge1)
RemoteS.ndrei2 — MethodNDREI2 = ndrei2(redEdge1, redEdge3; kw...)or
NDREI2 = ndrei2(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Normalized difference red edge index 2. Barnes et al 2000
NDREI2 = (redEdge3 - redEdge1) / (redEdge3 + redEdge1)
RemoteS.ndvi — MethodNDVI = ndvi(red, nir; kw...)or
NDVI = ndvi(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Compute the NDVI vegetation index. Input can be either the bands file names, or GMTimage objects with the band's data.
NDVI = (nir - red) / (nir + red)
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.ndwi — MethodNDWI = ndwi(green, nir; kw...)or
NDWI = ndwi(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Normalized difference water index. McFeeters 1996. NDWI => (green - nir)/(green + nir)
NDWI = (green - nir)/(green + nir)
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.ndwi2 — MethodNDWI2 = ndwi2(nir, swir2; kw...)or
NDWI2 = ndwi2(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Normalized difference water index. Gao 1996, Chen 2005 (also known as Normalized Difference Moisture Index NDBI and LSWI)
NDWI2 = (nir - swir2)/(nir + swir2)
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.reflectance_surf — MethodR = reflectance_surf(fname::String, [band::Int, bandname::String, mtl::String, save::String])Computes the radiance-at-surface of Landsat8 band using the COST model.
fname: The name of either a $LANDSAT_PRODUCT_ID$ geotiff band, or the name of a cube file created with thecutcubefunction. In the first case, if the companion $...MTL.txt$ file is not in the same directory asfnameone can still pass it via themtl=path-to-MTL-fileoption. In the second case it is mandatory to use one of the following two options.band: cubes created withcutcubeassign descriptions starting with "Band 1 ..." an so on the other bands. So whenbandis used we search for the band named "Band N", where N =band.bandname: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamestring that will be matched against the cube's bands descriptions. We can use thereportbandsfunction to see the bands description.save: The file name where to save the output. If not provided, a GMTgrid is returned.
Returns a Float32 GMTgrid
RemoteS.reportbands — Methodreportbands(in; [layers=Int[]])or
reportbands(in, layer;)Report the Bands description of the in input argument. This can be a GMTimage, a GMTgrid or a file name (a String) of a 'cube' file. Normally one made with the cutcube function. When the use conditions of this function are not met, either a warning or an error message (if too deep to be caught as a warning) will be issued.
layers: When this optional parameter is used, report the description of the bands in the vectorlayerslayer: A scalar with a unique band number. Alternative form toreportbands(in, layers=[layer])
Returns a string vector.
RemoteS.sat_scenes — Methodsatscenes(track, satname::String)
Compute polygons delimiting AQUA and TERRA scenes.
trac: Is an orbit computed withsat_tracksat steps of 1 minute (crucial)sat_name: The satellite name. At this time only AQUA and TERRA are allowed.
Returns a GMTdataset vector with the polygons and the scene names in the dataset header field.
Example
Imagine that orb was obtained with
orb = sat_tracks(tle=[tle1; tle2], start=DateTime("2021-09-02T13:30:00"), stop=DateTime("2021-09-02T13:40:00"), step="1m");
The scenes limits (two) are computed with:
Dscenes = sat_scenes(orb, "AQUA");RemoteS.sat_tracks — Methodsat_tracks(; geocentric::Bool=false, tiles::Bool=false, position::Bool=false, kwargs...)Compute satellite tracks using the TLE, or Two Line Elements set, a data format that contains information about the orbit at a specific epoch of an Earth-orbiting object. It can also calculate polygons arround the scene extents of AQUA and TERRA satellites as well as create the scene names, which provides a mean to direct download that data.
start: A DateTime object or a string convertable to a DateTime withDateTime(start)specifying the start of the orbit calculation. If omited, current time in UTC will be used.duration: Length of time for which the orbit is calculated. Accepts duration in days, hours, minutes or seconds. The default is minutes (100 minutes). To use other units use a string with the value appended with 'D', 'h', 'm' or 's'. e.g.duration="55m"to compute orbit 55 minutes fromstartsteporincordt: The time interval at which to compute locations along the orbit. The default unit here is seconds (30 sec) but minutes can be used as well by appending 'm'. e.g.step="1m"stop: As alternative todurationprovide the end date for the orbit. Same conditions asstartposition: Computes only first location at thestarttime. Boolean, useposition=truegeocentric: Boolean to controls if output islon,lat,alt,time(the default) orECEFcoordinates + time.tleorTLE: a file name with the TLE data for a specific satellite and period. It can also be a two elements string vector with the first and second lines of the TLE file.tiles: Compute the scene limits and file names for some satellites. Currently AQUA only.sat,SATorsatellite: Name of the satellite to use; choose from (string or symbols) :TERRA, :AQUA. Use only with thetilesoption.
Returns
A GMTdataset with the orbit or the scene polygons
Example:
Compute ~one orbit of the AQUA satellite starting at current local time. Note, this will be accurate for the month of September 2021. For other dates it needs an updated TLE.
tle1 = "1 27424U 02022A 21245.83760660 .00000135 00000-0 39999-4 0 9997";
tle2 = "2 27424 98.2123 186.0654 0002229 67.6025 313.3829 14.57107527 28342";
orb = sat_tracks(tle=[tle1; tle2], duration=100);and the orbit track can be visualized with
imshow(orb, proj=:Robinson, region=:global, coast=true)WARNING: This function depends on the SatelliteToolbox extension that is not loaded by default. Load it with:
- $using RemoteS, SatelliteToolboxTle, SatelliteToolboxPropagators, SatelliteToolboxTransformations$
RemoteS.satvi — MethodSATVI = satvi(red, swir2, swir3; kw...)or
SATVI = satvi(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Soil adjusted total vegetation index. Marsett 2006
SATVI = ((swir1 - red) / (swir1 + red + L)) * (1.0 + L) - (swir2 / 2.0)
RemoteS.savi — MethodSAVI = savi(red, nir; kw...)or
SAVI = savi(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Soil adjusted vegetation index. Huete 1988
SAVI = (nir - red) * (1.0 + L) / (nir + red + L)
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.slavi — MethodSLAVI = slavi(red, nir, swir2; kw...)or
SLAVI = slavi(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Specific Leaf Area Vegetation Index. Lymburger 2000
SLAVI = nir / (red + swir2)
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.subcube — Methodsubcube(cube::String; bands=Int[], bandnames=String[], layers=Int[])Extracts a subcube from cube with the layers in the bands vector, case in which we will search for bands named "Band band[k]", or those whose names correspond (even partially and case insensitive) to the descriptions in bandnames string vector. This means that the options bands and bandnames can only be used in 'cubes' with bands description. The layers option blindly extract the cube planes listed in the layer vector.
Returns a GMTimage
subcube(cube::Union{GMT.GMTimage{UInt16, 3}, AbstractArray{<:AbstractFloat, 3}}; bands=Int[], bandnames=String[], layers=Int[])Does the same but from an already in memory cube. Returns a type equal to the input type. No views, a data copy.
Example
Extracts the Red, Green and Blue layers from a Landsat 8 cube created with cutcube
Irgb = subcube("LC08__cube.tiff", bandnames = ["red", "green", "blue"])RemoteS.tgi — MethodTGI = tgi(red, green, blue; kw...)or (here fname is a .png or .jpg file name)
TGI = tgi(fname::String; kw...)or
TGI = tgi(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Triangular Greenness Index. Hunt et al. 2013
TGI = green - 0.39 * red - 0.61 * blue
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.train_raster — Methodmodel, classes = train_raster(cube::GItype, train::Union{Vector{<:GMTdataset}, String}; np::Int=0, density=0.1)cube: The cube wtih band data to classify.train: A vector of GMTdatasets or a file name of one containing the polygons used to train the model. NOTE: The individual datasets MUST have associated an attribute called "class" containing the class name as a string. This can be achieved for text data in the form of a GMT multi-segment file (one where segments are separated by the '>' symbol) if the multi-segment separator line contains the text $Attrib(class=name)$np: Number of points per polygon to be determined by $randinpolygon$density: Alternative tonp. See also the help of the $randinpolygon$ function.
Returns the trained model and the class names.
RemoteS.truecolor — MethodIrgb = truecolor(bndR, bndG, bndB)Take three Landsat8/Sentinel2 UINT16 GMTimages or the file names of those bands and compose an RGB true color image applying automatic histogram stretching.
Return an UInt8 RGB GMTimage
Irgb = truecolor(cube::GMTImage, bands::Vector{Int})Make an RGB composition of the 3 bands passed in the vector 'bands' from the layers in the multi-layered GMTimage cube
Return an auto-stretched UInt8 RGB GMTimage
Irgb = truecolor(cube::String, [bands::Vector{Int}], [bandnames::Vector{String}], [raw=false])Make an RGB composition of 3 bands from the cube file holding a UInt16 multi-layered array (often created with cutcube) The band selection can be made with bands vector, case in which we will search for bands named "Band[k]" or where the bands description contain the contents of bandnames. If none of bands or bandnames is used we search for a made up bandnames=["red", "green", "blue"].
Return an auto-stretched UInt8 RGB GMTimage OR a GMTimage{UInt16,3} if the raw option is set to true.
Irgb = truecolor(cube::GMTgrid, [bands|layers::Vector{Int}], [bandnames::Vector{String}], [type=UInt8])Make an RGB composition of 3 bands from the cube file holding a Float32 multi-layered array. The band selection can be made with bands vector, case in which we will search for bands named "Band[k]" or where the bands description contain the contents of bandnames. If none of bands or bandnames is used we search for a made up bandnames=["red", "green", "blue"].
By default we scale the bands to 0-255. Use type=UInt16 to scale the bands to 0-65535`. Note that this will matter only for the guessing of the good limits to perform the histogram stretching.
Example:
Make an RGB composite from data in the cube file "LC08__cube.tiff"
I = truecolor("LC08__cube.tiff");RemoteS.vari — MethodVARI = vari(red, green, blue; kw...)or (here fname is a .png or .jpg file name)
VARI = vari(fname::String; kw...)or
VARI = vari(cube::Union{String, GMTgrid}; [bands=Int[], bandnames=String[], layers=Int[]], kwargs...)Visible Atmospherically Resistant Index. Gitelson, A.A., Kaufman, Y.J., Stark, R., Rundquist, D., 2002
VARI = (green - red) / (green + red - blue)
- The first form accepts inputs as matrices, or file names of the data bands.
- The last form is more versatile but also more complex to describe.
cube: Is the file name of a 'cube', a multi-layered file normally created with thecutcubefunction. If this file was created with band descriptions one can use thebandsor thebandnamesoptions.bands: cubes created withcutcubeassign descriptions starting with "Band1 ..." an so on the other bands. So whenbandsis used we search for bands named "Band'band[k]'", where band[k] loops over all elements of thebandsvector. WARNING: the elements order in the vector must be sorted in increasing wavelength numbers, i.e. like the example for the first form.layers: Use this option when you are certain of the bands order in the cube or the it doesn't have a bands description. The selection will be made with cube[:,:,layer[1]], etc... WARNING: same warn as above.bandnames: When we know the common designation of a band, for example "Green", or any part of a band description, for example "NIR", we can use that info to create abandnamesstring vector that will be matched against the cube's bands descriptions.
Kwargs
threshold: When a threshold is provided we return a GMTgrid wherevals[ij] < threshold = NaNclasses: is a vector with up to 3 elements (class separators) and we return a UInt8 GMTimage with the indices categorized into vals[ij] > classes[1] = 1; vals[ij] > classes[2] = 2; vals[ij] > classes[3] = 3 and 0 otherwise.mask: Used together withthresholdoutputs a UInt8 GMTimage mask withvals[ij] >= threshold = 255and 0 otherwise Ifmask=-1(or any other negative number) we compute instead a mask wherevals[ij] < threshold = 255and 0 otherwisesave: Usesave="file_name.ext"to save the result in a disk file. File format is picked from file extension.order|bands_order|rgb: For the $GLI$, $TGI$ and $VARI$ (RGB) indices, we allow to reorder the bands and change the expected RGB order. Pass in a string, or symbol, with the color order. For example,order=:rbg
will swap the green and blue components making the result index identify the _reds_ instead of the _greens_.
Not good for vegetation indices, but potentially useful for other purposes.If none of bands, layers or bandnames is provided, we use the default band names shown in the first form.
See also https://www.indexdatabase.de/ for a list of indices and the appropriate band names per sensor.
Returns either a Float32 GMTgrid or a UInt8 GMTimage if the mask or classes options are used.
RemoteS.RemoteS — ModulePackage to perform operations with satellite data. Easy to use in computing true color images with automatic contrast stretch, many spectral indices and processing of MODIS L2 files.
RemoteS.classification_proba — MethodI = classification_proba(cube::GItype, model; class_number=1) -> GMTimageReturns an image with the assigned probabilities when classifying the class number class_number
cube: The cube wtih band data to classifymodel: is the model obtained from thetrain_rasterfunctionclass_number: is the class number to be classified
RemoteS.read_mtl — Functionreadmtl(bandname::String, mtl::String=""; get_full=false)
Use the band_name of a Landsat8 band to find the MTL file with the scene parameters at which that band belongs and read the params needed to compute Brightness temperature, radiance at top of atmosphere, etc. If the MTL file does not lieve next to the band file, send its name via the mtl argument.
The get_full option makes this function return a tring with contents of the MTL file or nothing if the MTL file is not found.
Returns a tuple with:
(band=band, radmul=radmul, radadd=radadd, radmax=radmax, reflectmul=reflectmul, reflectadd=reflectadd, reflectmax=reflectmax, sunazim=sunazim, sunelev=sunelev, sundis=sunazim, K1=K1, K2=K2)
or a string with MTL contents (or nothing if MTL file is not found)