RemoteS

Index

Functions

RemoteS.clgMethod
CLG = clg(green, redEdge3; kw...)

Green cholorphyl index. Wu et al 2012.

CLG = (redEdge3)/(green)-1

source
RemoteS.clip_orbitsMethod
clip_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 the sat_tracks function.
  • 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]);
source
RemoteS.clreMethod
CLRE = clre(redEdge1, redEdge3; kw...)

RedEdge cholorphyl index. Clevers and Gitelson 2013.

CLRE = (redEdge3)/(redEdge1)-1

source
RemoteS.cutcubeMethod
cutcube(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 name
  • bands: When names is 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 case bands should be a vector of strings including the extension. e.g. ["02.jp2", "8A.jp2"]
  • template: Goes together with the bands option. They are both composed a template * band[n] to recreate the full file name of each band.
  • region Is 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 the bands is 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. Use sentinel=10, or =20 or =60 to 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")
source
RemoteS.dn2radianceMethod
R = 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 the cutcube function. In the first case, if the companion $...MTL.txt$ file is not in the same directory as fname one can still pass it via the mtl=path-to-MTL-file option. In the second case it is mandatory to use one of the following two options.
  • band: cubes created with cutcube assign descriptions starting with "Band 1 ..." an so on the other bands. So when band is 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 a bandname string that will be matched against the cube's bands descriptions. We can use the reportbands function 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 = dn2temperature("LC08_L1TP_204033_20210525_20210529_02_T1_B2.TIF")
source
RemoteS.dn2reflectanceMethod
R = 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 the cutcube function. In the first case, if the companion $...MTL.txt$ file is not in the same directory as fname one can still pass it via the mtl=path-to-MTL-file option. In the second case it is mandatory to use one of the following two options.
  • band: cubes created with cutcube assign descriptions starting with "Band 1 ..." an so on the other bands. So when band is 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 a bandname string that will be matched against the cube's bands descriptions. We can use the reportbands function 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")
source
RemoteS.dn2temperatureMethod
R = 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 the cutcube function. In the first case, if the companion $...MTL.txt$ file is not in the same directory as fname one can still pass it via the mtl=path-to-MTL-file option. In the second case it is mandatory to use one of the following two options.
  • band: cubes created with cutcube assign descriptions starting with "Band 1 ..." an so on the other bands. So when band is 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 a bandname string that will be matched against the cube's bands descriptions. We can use the reportbands function 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)
source
RemoteS.eviMethod
EVI = evi(blue, red, nir; kw...)

or

EVI = evi(cube::String; [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 second 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 the cutcube function. If this file was created with band descriptions one can use the bands or the bandnames options.
    • bands: cubes created with cutcube assign descriptions starting with "Band1 ..." an so on the other bands. So when bands is used we search for bands named "Band'band[k]'", where band[k] loops over all elements of the bands vector. 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 a bandnames string vector that will be matched against the cube's bands descriptions.
  • kwargs:
    • threshold: When a threshold is provided we return a GMTgrid where vals[ij] < threshold = NaN
    • classes: 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 with threshold outputs a UInt8 GMTimage mask with vals[ij] >= threshold = 255 and 0 otherwise If mask=-1 (or any other negative number) we compute instead a mask where vals[ij] < threshold = 255 and 0 otherwise
    • save: Use save="file_name.ext" to save the result in a disk file. File format is picked from file extension.

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.

source
RemoteS.evi2Method
EVI2 = evi2(red, nir; kw...)

or

EVI2 = evi2(cube::String; [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 second 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 the cutcube function. If this file was created with band descriptions one can use the bands or the bandnames options.
    • bands: cubes created with cutcube assign descriptions starting with "Band1 ..." an so on the other bands. So when bands is used we search for bands named "Band'band[k]'", where band[k] loops over all elements of the bands vector. 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 a bandnames string vector that will be matched against the cube's bands descriptions.
  • kwargs:
    • threshold: When a threshold is provided we return a GMTgrid where vals[ij] < threshold = NaN
    • classes: 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 with threshold outputs a UInt8 GMTimage mask with vals[ij] >= threshold = 255 and 0 otherwise If mask=-1 (or any other negative number) we compute instead a mask where vals[ij] < threshold = 255 and 0 otherwise
    • save: Use save="file_name.ext" to save the result in a disk file. File format is picked from file extension.

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.

source
RemoteS.findscenesMethod
findscenes(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, SAT or satellite: Name of the satellite to use; choose from (string or symbols) :TERRA, :AQUA
  • start: A DateTime object or a string convertable to a DateTime with DateTime(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 from start.
  • stop: As alternative to duration provide the end date for the serch. Same conditions as start
  • tle or TLE: 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"
source
RemoteS.gndviMethod
GNDVI = gndvi(green, nir; kw...)

or

GNDVI = gndvi(cube::String; [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 second 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 the cutcube function. If this file was created with band descriptions one can use the bands or the bandnames options.
    • bands: cubes created with cutcube assign descriptions starting with "Band1 ..." an so on the other bands. So when bands is used we search for bands named "Band'band[k]'", where band[k] loops over all elements of the bands vector. 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 a bandnames string vector that will be matched against the cube's bands descriptions.
  • kwargs:
    • threshold: When a threshold is provided we return a GMTgrid where vals[ij] < threshold = NaN
    • classes: 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 with threshold outputs a UInt8 GMTimage mask with vals[ij] >= threshold = 255 and 0 otherwise If mask=-1 (or any other negative number) we compute instead a mask where vals[ij] < threshold = 255 and 0 otherwise
    • save: Use save="file_name.ext" to save the result in a disk file. File format is picked from file extension.

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.

source
RemoteS.grid_at_sensorFunction
G = 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 | spacing and search_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 with region and inc kwargs as well. One can also set the $nearneighbor$ serach radius with option search_radius. The defaul is to set search_radius equal 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 the quality=val kwarg. 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_srs or target_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 the t_srs or target_proj option to tell the program to do a coordinate conversion before gridding. t_srs should 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.e nodata=-9999) Note that this is automatically set for the NSIDC products.

  • nointerp: Means to not do any nearneighbor interpolation but needs that region has been set.

  • NSIDC_N and NSIDC_S: Set the s_srs, region, nointerp, nodata appropriate to read the See Ice NSIDC https://nsidc.org/data/polar-stereo/ps_grids.html grids.

  • dataset or xyz: If instead of calculating a grid (returned as a GMTgrid type) user wants the x,y,z data intself, use the keywords dataset, or xyz and the output will be in a GMTdataset (i.e. use dataset=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);
source
RemoteS.mndwiMethod
MNDWI = mndwi(green, swir2; kw...)

or

MNDWI = mndwi(cube::String; [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 second 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 the cutcube function. If this file was created with band descriptions one can use the bands or the bandnames options.
    • bands: cubes created with cutcube assign descriptions starting with "Band1 ..." an so on the other bands. So when bands is used we search for bands named "Band'band[k]'", where band[k] loops over all elements of the bands vector. 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 a bandnames string vector that will be matched against the cube's bands descriptions.
  • kwargs:
    • threshold: When a threshold is provided we return a GMTgrid where vals[ij] < threshold = NaN
    • classes: 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 with threshold outputs a UInt8 GMTimage mask with vals[ij] >= threshold = 255 and 0 otherwise If mask=-1 (or any other negative number) we compute instead a mask where vals[ij] < threshold = 255 and 0 otherwise
    • save: Use save="file_name.ext" to save the result in a disk file. File format is picked from file extension.

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.

source
RemoteS.msaviMethod
MSAVI = msavi(red, nir; kw...)

or

MSAVI = msavi(cube::String; [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 second 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 the cutcube function. If this file was created with band descriptions one can use the bands or the bandnames options.
    • bands: cubes created with cutcube assign descriptions starting with "Band1 ..." an so on the other bands. So when bands is used we search for bands named "Band'band[k]'", where band[k] loops over all elements of the bands vector. 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 a bandnames string vector that will be matched against the cube's bands descriptions.
  • kwargs:
    • threshold: When a threshold is provided we return a GMTgrid where vals[ij] < threshold = NaN
    • classes: 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 with threshold outputs a UInt8 GMTimage mask with vals[ij] >= threshold = 255 and 0 otherwise If mask=-1 (or any other negative number) we compute instead a mask where vals[ij] < threshold = 255 and 0 otherwise
    • save: Use save="file_name.ext" to save the result in a disk file. File format is picked from file extension.

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.

source
RemoteS.mtciMethod
MTCI = mtci(red, redEdge1, redEdge2; kw...)

Meris Terrestrial Chlorophyll Index. Clevers and Gitelson 2013, Dash and Curran 2004

MTCI = (redEdge2-redEdge1) / (redEdge1-red)

source
RemoteS.ndrei1Method
NDREI1 = ndrei1(redEdge1, redEdge2; kw...)

Normalized difference red edge index. Gitelson and Merzlyak 1994

NDREI1 = (redEdge2 - redEdge1) / (redEdge2 + redEdge1)

source
RemoteS.ndrei2Method
NDREI2 = ndrei2(redEdge1, redEdge3; kw...)

Normalized difference red edge index 2. Barnes et al 2000

NDREI2 = (redEdge3 - redEdge1) / (redEdge3 + redEdge1)

source
RemoteS.ndviMethod
NDVI = ndvi(red, nir; kw...)

or

NDVI = ndvi(cube::String; [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 second 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 the cutcube function. If this file was created with band descriptions one can use the bands or the bandnames options.
    • bands: cubes created with cutcube assign descriptions starting with "Band1 ..." an so on the other bands. So when bands is used we search for bands named "Band'band[k]'", where band[k] loops over all elements of the bands vector. 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 a bandnames string vector that will be matched against the cube's bands descriptions.
  • kwargs:
    • threshold: When a threshold is provided we return a GMTgrid where vals[ij] < threshold = NaN
    • classes: 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 with threshold outputs a UInt8 GMTimage mask with vals[ij] >= threshold = 255 and 0 otherwise If mask=-1 (or any other negative number) we compute instead a mask where vals[ij] < threshold = 255 and 0 otherwise
    • save: Use save="file_name.ext" to save the result in a disk file. File format is picked from file extension.

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.

source
RemoteS.ndwiMethod
NDWI = ndwi(green, nir; kw...)

or

NDWI = ndwi(cube::String; [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 second 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 the cutcube function. If this file was created with band descriptions one can use the bands or the bandnames options.
    • bands: cubes created with cutcube assign descriptions starting with "Band1 ..." an so on the other bands. So when bands is used we search for bands named "Band'band[k]'", where band[k] loops over all elements of the bands vector. 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 a bandnames string vector that will be matched against the cube's bands descriptions.
  • kwargs:
    • threshold: When a threshold is provided we return a GMTgrid where vals[ij] < threshold = NaN
    • classes: 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 with threshold outputs a UInt8 GMTimage mask with vals[ij] >= threshold = 255 and 0 otherwise If mask=-1 (or any other negative number) we compute instead a mask where vals[ij] < threshold = 255 and 0 otherwise
    • save: Use save="file_name.ext" to save the result in a disk file. File format is picked from file extension.

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.

source
RemoteS.ndwi2Method
NDWI2 = ndwi2(nir, swir2; kw...)

or

NDWI2 = ndwi2(cube::String; [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 second 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 the cutcube function. If this file was created with band descriptions one can use the bands or the bandnames options.
    • bands: cubes created with cutcube assign descriptions starting with "Band1 ..." an so on the other bands. So when bands is used we search for bands named "Band'band[k]'", where band[k] loops over all elements of the bands vector. 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 a bandnames string vector that will be matched against the cube's bands descriptions.
  • kwargs:
    • threshold: When a threshold is provided we return a GMTgrid where vals[ij] < threshold = NaN
    • classes: 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 with threshold outputs a UInt8 GMTimage mask with vals[ij] >= threshold = 255 and 0 otherwise If mask=-1 (or any other negative number) we compute instead a mask where vals[ij] < threshold = 255 and 0 otherwise
    • save: Use save="file_name.ext" to save the result in a disk file. File format is picked from file extension.

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.

source
RemoteS.reflectance_surfMethod
R = 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 the cutcube function. In the first case, if the companion $...MTL.txt$ file is not in the same directory as fname one can still pass it via the mtl=path-to-MTL-file option. In the second case it is mandatory to use one of the following two options.
  • band: cubes created with cutcube assign descriptions starting with "Band 1 ..." an so on the other bands. So when band is 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 a bandname string that will be matched against the cube's bands descriptions. We can use the reportbands function 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

source
RemoteS.reportbandsMethod
reportbands(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 vector layers
  • layer: A scalar with a unique band number. Alternative form to reportbands(in, layers=[layer])

Returns a string vector.

source
RemoteS.sat_scenesMethod

satscenes(track, satname::String)

Compute polygons delimiting AQUA and TERRA scenes.

  • trac: Is an orbit computed with sat_tracks at 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");
source
RemoteS.sat_tracksMethod
sat_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 with DateTime(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 from start
  • step or inc or dt: 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 to duration provide the end date for the orbit. Same conditions as start
  • position: Computes only first location at the start time. Boolean, use position=true
  • geocentric: Boolean to controls if output is lon,lat,alt,time (the default) or ECEF coordinates + time.
  • tle or TLE: 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, SAT or satellite: Name of the satellite to use; choose from (string or symbols) :TERRA, :AQUA. Use only with the tiles option.

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)
source
RemoteS.satviMethod
SATVI = satvi(red, swir2, swir3; kw...)

Soil adjusted total vegetation index. Marsett 2006

SATVI = ((swir1 - red) / (swir1 + red + L)) * (1.0 + L) - (swir2 / 2.0)

source
RemoteS.saviMethod
SAVI = savi(red, nir; kw...)

or

SAVI = savi(cube::String; [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 second 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 the cutcube function. If this file was created with band descriptions one can use the bands or the bandnames options.
    • bands: cubes created with cutcube assign descriptions starting with "Band1 ..." an so on the other bands. So when bands is used we search for bands named "Band'band[k]'", where band[k] loops over all elements of the bands vector. 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 a bandnames string vector that will be matched against the cube's bands descriptions.
  • kwargs:
    • threshold: When a threshold is provided we return a GMTgrid where vals[ij] < threshold = NaN
    • classes: 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 with threshold outputs a UInt8 GMTimage mask with vals[ij] >= threshold = 255 and 0 otherwise If mask=-1 (or any other negative number) we compute instead a mask where vals[ij] < threshold = 255 and 0 otherwise
    • save: Use save="file_name.ext" to save the result in a disk file. File format is picked from file extension.

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.

source
RemoteS.slaviMethod
SLAVI = slavi(red, nir, swir2; kw...)

or

SLAVI = slavi(cube::String; [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 second 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 the cutcube function. If this file was created with band descriptions one can use the bands or the bandnames options.
    • bands: cubes created with cutcube assign descriptions starting with "Band1 ..." an so on the other bands. So when bands is used we search for bands named "Band'band[k]'", where band[k] loops over all elements of the bands vector. 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 a bandnames string vector that will be matched against the cube's bands descriptions.
  • kwargs:
    • threshold: When a threshold is provided we return a GMTgrid where vals[ij] < threshold = NaN
    • classes: 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 with threshold outputs a UInt8 GMTimage mask with vals[ij] >= threshold = 255 and 0 otherwise If mask=-1 (or any other negative number) we compute instead a mask where vals[ij] < threshold = 255 and 0 otherwise
    • save: Use save="file_name.ext" to save the result in a disk file. File format is picked from file extension.

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.

source
RemoteS.subcubeMethod
subcube(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"])
source
RemoteS.truecolorMethod
Irgb = 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 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 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");
source
RemoteS.RemoteSModule

Package 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.

source
RemoteS.nbriMethod
NBRI = nbri(nir, swir3; kw...)

Normalised Burn Ratio Index. Garcia 1991

NBRI = (nir - swir3) / (nir + swir3)

source
RemoteS.read_mtlFunction

readmtl(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)

source