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

Implements 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

source
SatelliteDataSources.Landsat8Type

Implements 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

source
SatelliteDataSources.Landsat9Type

Implements 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

source
SatelliteDataSources.Sentinel2Type

Implements 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

source
SatelliteDataSources.DESISType

Implements 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

source

User Interface

SatelliteDataSources.layersFunction
layers(::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)
source
SatelliteDataSources.decodeFunction
decode(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: The AbstractSatellite that produced the raster(s) in question.
  • raster: Either a Rasters.Raster or Rasters.RasterStack to be decoded.
source
SatelliteDataSources.encodeFunction
encode(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: The AbstractSatellite that produced the raster(s) in question.
  • raster: Either a Rasters.Raster or Rasters.RasterStack to 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).
source
SatelliteDataSources.metadataFunction
metadata(x::AbstractSatellite)

Parses the metadata fields for the given satellite scene.

Metadata varies between products, but typically includes the acquisition date and processing level.

source
SatelliteDataSources.translate_colorFunction
translate_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)
:B8A
source
Rasters.RasterType
Raster(x::AbstractSatellite, layer::Symbol; kwargs...)

Read a single layer into a Rasters.Raster.

Parameters

  • x: An AbstractSatellite from which to read a layer.
  • layer: The layer to be read. See layers(s) for a list of available layers for sensor s.
  • kwargs: Refer to the Rasters.Raster documentation for a summary of supported keywords.
source
Rasters.RasterStackType
RasterStack(x::AbstractSatellite, layers=bands(T); kwargs...)

Read multiple layers into a Rasters.RasterStack.

Parameters

  • x: An AbstractSatellite from which to read a layer.
  • layer: The layer to be read. See layers(s) for a list of available layers for sensor s.
  • kwargs: Refer to the Rasters.RasterStack documentation for a summary of supported keywords.
source

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

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

source
SatelliteDataSources.MaskValueType

A layer corresponding to a specific value in a single-band file.

Sentinel 2 uses this format to encode segmentation masks in the SCL file.

source
SatelliteDataSources.BitFieldType

A layer corresponding to a particular bit in a single-band file.

Landsat uses this format to encode segmentation masks within the QA file.

source
SatelliteDataSources.UnionLayerType

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

source
SatelliteDataSources.parse_fileFunction
parse_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.

source

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