SatelliteDataSources
SatelliteDataSources is a pure Julia package built on top of Rasters.jl for reading and manipulating satellite imagery. Each AbstractSatellite provides a set of layers that can be conveniently read into either a Raster or RasterStack. Additionally, all AbstractSatellite types define a collection of sensor-specific information, such as digital number encoding, band wavelength, and band color.
Supported Sensors
Several popular satellites are already supported, and we provide a simple interface for adding more down the line.
SatelliteDataSources.AbstractSatellite — TypeThe super-type of all satellites.
Sub-types must implement the AbstractSatellite interface.
SatelliteDataSources.Landsat7 — TypeImplements the AbstractSatellite interface for Landsat 7.
Supported Bands: :B1, :B2, :B3, :B4, :B5, :B7, :thermal, :panchromatic
Supported Colors: :blue, :green, :red, :nir, :swir1, :swir2
Supported Masks: :dilated_clouds, :clouds, :cloud_shadow, :snow, :water
SatelliteDataSources.Landsat8 — TypeImplements the AbstractSatellite interface for Landsat 8.
Supported Bands: :B1, :B2, :B3, :B4, :B5, :B6, :B7, :thermal1, :thermal2, :panchromatic
Supported Colors: :blue, :green, :red, :nir, :swir1, :swir2
Supported Masks: :dilated_clouds, :clouds, :cloud_shadow, :snow, :water
SatelliteDataSources.Landsat9 — TypeImplements the AbstractSatellite interface for Landsat 9.
Supported Layers: :B1, :B2, :B3, :B4, :B5, :B6, :B7, :thermal1, :thermal2, :panchromatic
Supported Colors: :blue, :green, :red, :nir, :swir1, :swir2
Supported Masks: :dilated_clouds, :clouds, :cloud_shadow, :snow, :water
SatelliteDataSources.Sentinel2 — TypeImplements the AbstractSatellite interface for Sentinel 2.
The user must specify a resolution of 10, 20, or 60 meters.
Supported Bands (10m): :B02, :B03, :B04, :B08
Supported Bands (20m): :B02, :B03, :B04, :B05, :B06, :B07, :B8A, :B11, :B12
Supported Bands (60m): :B01, :B02, :B03, :B04, :B05, :B06, :B07, :B8A, :B09, :B11, :B12
Supported Colors (10m): :blue, :green, :red, :nir
Supported Colors (20m and 60m): :blue, :green, :red, :nir, :swir1, :swir2
Supported Masks (20m and 60m): :cloud_shadow, :clouds_med, :clouds_high, :cirrus, :vegetation, :soil, :water, :snow
SatelliteDataSources.DESIS — TypeImplements the AbstractSatellite interface for DESIS.
Supported Bands: :Bands, :Band_30, :Band_65, :Band_100, :Band_175
Supported Colors: :blue, :green, :red, :nir
Supported Masks: :clouds, :shadow, :haze, :snow, :land, :water
User Interface
SatelliteDataSources.files — Functionfiles(x::AbstractSatellite)Return a list of files for the given satellite product.
SatelliteDataSources.bands — Functionbands(::Type{AbstractSatellite})Return the band names in order from shortest to longest wavelength.
SatelliteDataSources.layers — Functionlayers(::Type{AbstractSatellite})
layers(x::AbstractSatellite)Return the names of all layers available for the given sensor.
Example
# Get all Available Layers for Landsat 8
landsat_layers = layers(Landsat8)
# Get all Available Layers for a Specific Scene
src = Landsat8("LC08_L2SP_043024_20200802_20200914_02_T1")
available_layers = layers(src)SatelliteDataSources.wavelengths — Functionwavelengths(::Type{AbstractSatellite})Return the central wavelengths for all bands in order from shortest to longest.
SatelliteDataSources.wavelength — Functionwavelength(::Type{AbstractSatellite}, band::Symbol)Return the central wavelength for the corresponding band.
SatelliteDataSources.blue_band — Functionblue_band(::Type{AbstractSatellite})Return the blue band for the given sensor.
SatelliteDataSources.green_band — Functiongreen_band(::Type{AbstractSatellite})Return the green band for the given sensor.
SatelliteDataSources.red_band — Functionred_band(::Type{AbstractSatellite})Return the red band for the given sensor.
SatelliteDataSources.nir_band — Functionnir_band(::Type{AbstractSatellite})Return the nir band for the given sensor.
SatelliteDataSources.swir1_band — Functionswir1_band(::Type{AbstractSatellite})Return the swir1 band for the given sensor.
SatelliteDataSources.swir2_band — Functionswir2_band(::Type{AbstractSatellite})Return the swir2 band for the given sensor.
SatelliteDataSources.dn_scale — Functiondn_scale(::Type{AbstractSatellite}, layer::Symbol)Return the scale factor applied to digital numbers.
SatelliteDataSources.dn_offset — Functiondn_offset(::Type{AbstractSatellite}, layer::Symbol)Return the offset factor applied to digital numbers.
SatelliteDataSources.decode — Functiondecode(s::Type{AbstractSatellite}, raster::Rasters.AbstractRaster)
decode(s::Type{AbstractSatellite}, raster::Rasters.AbstractRasterStack)Decode the Digital Number (DN) values in the given raster(s). Typically, the decoded values will be in either reflectance (visual bands) or Kelvin (thermal bands).
Parameters
s: TheAbstractSatellitethat produced the raster(s) in question.raster: Either aRasters.RasterorRasters.RasterStackto be decoded.
SatelliteDataSources.encode — Functionencode(s::Type{AbstractSatellite}, raster::Rasters.AbstractRaster; encoding_type=UInt16, missingval=0x0000)
encode(s::Type{AbstractSatellite}, raster::Rasters.AbstractRasterStack; kwargs...)Encode the provided raster(s) to Digital Numbers (DN).
Parameters
s: TheAbstractSatellitethat produced the raster(s) in question.raster: Either aRasters.RasterorRasters.RasterStackto be encoded.encoding_type: The Julia type to use for storing the encoded values (default =UInt16).missingval: The value to denote missing values (default =0x0000).
SatelliteDataSources.metadata — Functionmetadata(x::AbstractSatellite)Parses the metadata fields for the given satellite scene.
Metadata varies between products, but typically includes the acquisition date and processing level.
SatelliteDataSources.translate_color — Functiontranslate_color(::Type{AbstractSatellite}, layer::Symbol)Translates a color such as :red, :green, or :blue to the corresponding band name.
Example
julia> translate_color(Landsat8, :red)
:B4
julia> translate_color(Sentinel2{10}, :nir)
:B08
julia> translate_color(Sentinel2{20}, :nir)
:B8ARasters.Raster — TypeRaster(x::AbstractSatellite, layer::Symbol; kwargs...)Read a single layer into a Rasters.Raster.
Parameters
x: AnAbstractSatellitefrom which to read a layer.layer: The layer to be read. Seelayers(s)for a list of available layers for sensors.kwargs: Refer to theRasters.Rasterdocumentation for a summary of supported keywords.
Rasters.RasterStack — TypeRasterStack(x::AbstractSatellite, layers=bands(T); kwargs...)Read multiple layers into a Rasters.RasterStack.
Parameters
x: AnAbstractSatellitefrom which to read a layer.layer: The layer to be read. Seelayers(s)for a list of available layers for sensors.kwargs: Refer to theRasters.RasterStackdocumentation for a summary of supported keywords.
Layer Sources
A sensor's layers can come form a variety of sources, including single-band rasters, multiband rasters, and bit-fields. However, we do not want to expose these particulars to the end user. Thus, we rely on several Julia types to represent this abstraction. Each of these types are sub-types of AbstractLayerSource and store the necessary information to retrieve the corresponding layer.
SatelliteDataSources.AbstractLayerSource — TypeSuper type of all layer sources.
SatelliteDataSources.File — TypeA layer corresponding to a file.
Commonly used for sensors which store their bands as individual rasters.
SatelliteDataSources.Band — TypeA layer corresponding to a particular band in a multi-band file.
Commonly used for sensors which store their bands in a single multi-band raster.
SatelliteDataSources.MaskValue — TypeA layer corresponding to a specific value in a single-band file.
Sentinel 2 uses this format to encode segmentation masks in the SCL file.
SatelliteDataSources.BitField — TypeA layer corresponding to a particular bit in a single-band file.
Landsat uses this format to encode segmentation masks within the QA file.
SatelliteDataSources.UnionLayer — TypeA layer composed of the union of two other layers.
An example is a cloud mask expressed as the union of a cloud-over-water mask and a cloud-over-land mask.
SatelliteDataSources.layer_source — Functionlayer_source(::Type{AbstractSatellite}, layer::Symbol)Retrieve the AbstractLayerSource for the given layer and sensor type.
SatelliteDataSources.parse_file — Functionparse_file(x::AbstractLayerSource, files::Vector{String})Returns the first file that matches the provided AbstractLayerSource from a list of files.
Returns nothingif no matching file can be found.
Example
using ArchGDAL, Rasters, SatelliteDataSources, DataDeps, Fetch
# Download Landsat 8 Scene From Google Drive
landsat_link = "https://drive.google.com/file/d/1S5H_oyWZZInOzJK4glBCr6LgXSADzhOV/view?usp=sharing"
landsat_hash = "2ce24abc359d30320213237d78101d193cdb8433ce21d1f7e9f08ca140cf5785"
register(
DataDep(
"LC08_L2SP_043024_20200802_20200914_02_T1",
"Landsat 8 Test Data",
landsat_link,
landsat_hash,
fetch_method=gdownload,
post_fetch_method=unpack
)
)
# Place Scene in a Landsat8 Context
src = Landsat8(datadep"LC08_L2SP_043024_20200802_20200914_02_T1")
# Load the Blue, Green, Red, and NIR Bands
stack = RasterStack(src, [:blue, :green, :red, :nir], lazy=true)
# Mask Clouds and Cloud Shadow
cloud_mask = Raster(src, :clouds)
shadow_mask = Raster(src, :cloud_shadow)
raster_mask = .!(boolmask(cloud_mask) .|| boolmask(shadow_mask))
masked_stack = mask(stack, with=raster_mask)
# Save Processed Data as a Multiband Raster
masked_raster = Raster(masked_stack)
write("masked_bands.tif", masked_raster)Index
Rasters.RasterRasters.RasterStackSatelliteDataSources.AbstractLayerSourceSatelliteDataSources.AbstractSatelliteSatelliteDataSources.BandSatelliteDataSources.BitFieldSatelliteDataSources.DESISSatelliteDataSources.FileSatelliteDataSources.Landsat7SatelliteDataSources.Landsat8SatelliteDataSources.Landsat9SatelliteDataSources.MaskValueSatelliteDataSources.Sentinel2SatelliteDataSources.UnionLayerSatelliteDataSources.bandsSatelliteDataSources.blue_bandSatelliteDataSources.decodeSatelliteDataSources.dn_offsetSatelliteDataSources.dn_scaleSatelliteDataSources.encodeSatelliteDataSources.filesSatelliteDataSources.green_bandSatelliteDataSources.layer_sourceSatelliteDataSources.layersSatelliteDataSources.metadataSatelliteDataSources.nir_bandSatelliteDataSources.parse_fileSatelliteDataSources.red_bandSatelliteDataSources.swir1_bandSatelliteDataSources.swir2_bandSatelliteDataSources.translate_colorSatelliteDataSources.wavelengthSatelliteDataSources.wavelengths