Documentation ¶
Index ¶
- Constants
- Variables
- func ClampedNormalizingTransform(edges *OptramEdges, bandValues ...uint16) float64
- func ConfidenceMatrixToImage(confidence [][]float64, colorScale func(float64) *color.RGBA, opacity uint8) *image.RGBA
- func ConvertS2ToRgb(bands [3]float64, advancedColorModel bool, options ...Options) [3]float64
- func CreatePolygonFromCoordinates(coordinates []float64) string
- func GenerateRamp(colors []RampEntry, steps int, blendMode BlendMode) []uint8
- func GetColor(normalizedVal float64, ramp []RampEntry) *color.RGBA
- func GetColorRamp(colorScaleName string) []uint8
- func GetColorScale(colorScaleName string) func(float64) *color.RGBA
- func ImageFromBands(paths []string, ramp []uint8, transform func(*OptramEdges, ...uint16) float64, ...) (*image.RGBA, error)
- func ImageFromCombination(datasetDir string, bandFileMapping map[string]string, bandCombo string, ...) (*image.RGBA, error)
- func ImageToJPEG(image *image.RGBA) ([]byte, error)
- func ImageToPNG(image *image.RGBA) ([]byte, error)
- func InfernoColorScale(normalizedVal float64) *color.RGBA
- func Initialize(config *env.Config)
- func LoadPNGImage(filename string) (*image.RGBA, error)
- func MagmaColorScale(normalizedVal float64) *color.RGBA
- func NormalizingTransform(edges *OptramEdges, bandValues ...uint16) float64
- func OptramTransform(edges *OptramEdges, bandValues ...uint16) float64
- func ParseGeoHashFromID(ID string, precision int) string
- func PlasmaColorScale(normalizedVal float64) *color.RGBA
- func RampToImage(height int, ramp []uint8) *image.RGBA
- func ReadOptramFile(file string) (map[string]OptramEdges, int, error)
- func SavePNGImage(image *image.RGBA, filename string) error
- func ScaleConfidenceMatrix(width int, height int, confidence *[][]float64) [][]float64
- func SplitMultiBandImage(dataset gdal.Dataset, outputFolder string, bandMapping map[int]string) ([]string, error)
- func TurboColorScale(normalizedVal float64) *color.RGBA
- func ViridisColorScale(normalizedVal float64) *color.RGBA
- type BandCombination
- type BandCombinationID
- type BlendMode
- type ImageCacheKey
- type ImageScale
- type Options
- type OptramEdges
- type RampEntry
Constants ¶
const ( // Sentinel2Max is the maximum expected value stored in a sentinel 2 satellite band. Spec indicates a 12 bit // value. Sentinel2Max = 10000 // NaturalColors1 identifies a band mapping that displays an image in natural color. NaturalColors1 = "natural_colors_1" // NaturalColors2 identifies a band mapping that displays an image in natural color. NaturalColors2 = "natural_colors_2" // FalseColorInfrared identifies a band mapping that displays an image in false color for visualizing vegatation. FalseColorInfrared = "false_color_infrared" // FalseColorUrban identifies a band mapping that displays an image in false color for visualizing urban development. FalseColorUrban = "false_color_urban" // Agriculture identifies a band mapping that displays an image in false color for visualization agricultural activity. Agriculture = "agriculture" // AtmosphericPenetration identifies a band mapping that displays an image in false for visualizing atmospheric penetration. AtmosphericPenetration = "atmospheric_penetration" // HealthyVegetation identifies a band mapping that displays an image in false color for visualizing vegatation health. HealthyVegetation = "healthy_vegetation" // LandWater identifies a band mapping that displays an image in in false color that separates land and water. LandWater = "land_water" // AtmosphericRemoval identifies a band mapping that displays an image in near true color with atmoshperic effects reduced. AtmosphericRemoval = "atmospheric_removal" // ShortwaveInfrared identifies a band mapping that displays an image in shortwave infrared. ShortwaveInfrared = "shortwave_infrared" // VegetationAnalysis identifies a band mapping that displays an image in in false color for analyzing vegetation. VegetationAnalysis = "vegetation_analysis" // ImageAttention identifies what the model is paying attention to in the image ImageAttention = "image_attention" // NDVI identifies a band mapping that displays Normalized Difference Vegetation Index mapped using an RGB ramp. NDVI = "ndvi" // NDWI identifies a band mapping that displays Normalized Difference Water Index mapped using an RGB ramp. NDWI = "ndwi" // NDMI identifies a band mapping that displays Normalized Difference Moisture Index mapped using an RGB ramp. NDMI = "ndmi" // NSMI identifies a band mapping that display Normalized Soil Moisture Index mapped using an RGB ramp. NSMI = "nsmi" // MNDWI identifies a band mapping that displays Modified Normalized Difference Moisture Index mapped using an RGB ramp MNDWI = "mndwi" // RSWIR identifies a band mapping that displays Red and Shortwave Infrared mapped using an RGB ramp RSWIR = "rswir" // OPTRAM identifies a band mapping that represents the soil moisture OPTRAM = "optram" // OPTRAMJSONFile contains the file name to look for in the learning folder to check if optram is supported OPTRAMJSONFile = "optram_variables.json" )
Variables ¶
var ( // RedYellowGreenRamp defines an evenly spaced ramp suitable for visualizing vegetation RedYellowGreenRamp = []uint8{} // BrownYellowBlueRamp defines an evenly spaced ramp suitable for visualizing moisture BrownYellowBlueRamp = []uint8{} // ViridisColorRamp color scale ViridisColorRamp = []RampEntry{} // MagmaColorRamp color scale MagmaColorRamp = []RampEntry{} // PlasmaColorRamp color scale PlasmaColorRamp = []RampEntry{} // InfernoColorRamp color scale InfernoColorRamp = []RampEntry{} // TurboColorRamp color scale TurboColorRamp = []RampEntry{} )
var ( // SentinelBandCombinations defines a list of recommended band combinations for sentinel 2 satellite missions SentinelBandCombinations = map[string]*BandCombination{} )
Functions ¶
func ClampedNormalizingTransform ¶
func ClampedNormalizingTransform(edges *OptramEdges, bandValues ...uint16) float64
ClampedNormalizingTransform transforms to a range of (-1, 1) and then clamps to (0, 1)
func ConfidenceMatrixToImage ¶
func ConfidenceMatrixToImage(confidence [][]float64, colorScale func(float64) *color.RGBA, opacity uint8) *image.RGBA
ConfidenceMatrixToImage takes the confidences matrix and a supplied colorScale function and returns an image.
func ConvertS2ToRgb ¶
ConvertS2ToRgb bands: [b02, b03, b04], Options gain amount, gamma correction amount, gainL light gain default options: gain=2.5, gamma=2.2, gainL=1.0
func CreatePolygonFromCoordinates ¶
CreatePolygonFromCoordinates creates a string that captures the polygon defined by the coordinates.
func GenerateRamp ¶
GenerateRamp creaets a a color ramp stored as a flat array of byte values.
func GetColorRamp ¶
GetColorRamp returns the color ramp based the supplied name. if name is incorrect defaults to viridis ramp
func GetColorScale ¶
GetColorScale returns the color scale function based the supplied name. if name is incorrect defaults to viridis function
func ImageFromBands ¶
func ImageFromBands(paths []string, ramp []uint8, transform func(*OptramEdges, ...uint16) float64, imageScale ImageScale, edges *OptramEdges, advancedColorModel bool, options ...Options) (*image.RGBA, error)
ImageFromBands loads band data from the file paths array into a single RGB image, where the file names map to R,G,B in order. The results are returned as a JPEG encoded byte stream. If errors are encountered processing a band an attempt will be made to create the image from the remaining bands, while logging an error.
func ImageFromCombination ¶
func ImageFromCombination(datasetDir string, bandFileMapping map[string]string, bandCombo string, imageScale ImageScale, edges *OptramEdges, ramp string, options ...Options) (*image.RGBA, error)
ImageFromCombination takes a base dataset directory, fileID and a band combination label and returns a composed image. NOTE: Currently a bit hardcoded for sentinel-2 data.
func ImageToJPEG ¶
ImageToJPEG encodes an RGBA image as a JPEG byte array for further processing or network transmission.
func ImageToPNG ¶
ImageToPNG encodes RGBA image as PNG byte array
func InfernoColorScale ¶
InfernoColorScale returns a functions used to return a color from the inferno color scale given a normalized value
func Initialize ¶
Initialize sets up the necessary structures for imagery processing.
func LoadPNGImage ¶
LoadPNGImage loads an RGBA PNG from the caller supplied path, decodes it, and returns it as an RGBA image. Return an error if the image is not RGBA.
func MagmaColorScale ¶
MagmaColorScale returns a functions used to return a color from the magma color scale given a normalized value
func NormalizingTransform ¶
func NormalizingTransform(edges *OptramEdges, bandValues ...uint16) float64
NormalizingTransform transforms to a range of (-1, 1) and then normalizes to (0, 1)
func OptramTransform ¶
func OptramTransform(edges *OptramEdges, bandValues ...uint16) float64
OptramTransform calculates a moisture normalized value between (0, 1)
func ParseGeoHashFromID ¶
ParseGeoHashFromID will extrapolate the geohash from the path
func PlasmaColorScale ¶
PlasmaColorScale returns a functions used to return a color from the plasma color scale given a normalized value
func RampToImage ¶
RampToImage converts a color ramp to an image for debugging purposes
func ReadOptramFile ¶
func ReadOptramFile(file string) (map[string]OptramEdges, int, error)
ReadOptramFile will parse the optram json file into a map[string]OptramEdges struct and return the precision
func SavePNGImage ¶
SavePNGImage saves an RGBA image to disk in PNG format.
func ScaleConfidenceMatrix ¶
ScaleConfidenceMatrix scales confidence matrix to desired size using linear scaling
func SplitMultiBandImage ¶
func SplitMultiBandImage(dataset gdal.Dataset, outputFolder string, bandMapping map[int]string) ([]string, error)
SplitMultiBandImage splits a multiband image into separate images, each being for a single band. Bands can be mapped and dropped.
func TurboColorScale ¶
TurboColorScale returns a functions used to return a color from the inferno color scale given a normalized value
func ViridisColorScale ¶
ViridisColorScale returns a functions used to return a color from the viridis color scale given a normalized value
Types ¶
type BandCombination ¶
type BandCombination struct { ID BandCombinationID DisplayName string Mapping []string Ramp []uint8 Transform func(*OptramEdges, ...uint16) float64 AdvancedColorModel bool }
BandCombination defines a mapping of satellite bands to image RGB channels.
type BandCombinationID ¶
type BandCombinationID string
BandCombinationID uniquely identifies a band combination
type BlendMode ¶
type BlendMode int
BlendMode indicates the blend mode to use when building the color ramp
type ImageCacheKey ¶
type ImageCacheKey struct { DatasetDir string BandCombination string ImageScale *ImageScale Ramp string Options []Options BandsMapped []string }
ImageCacheKey stores the fields used to generate an image hash key.
type ImageScale ¶
ImageScale defines what to scale the image size to. If one property is defined aspect ratio will be kept. If nil for both the func will determine the size.
type Options ¶
type Options struct { Gain float64 `json:"gain"` Gamma float64 `json:"gamma"` GainL float64 `json:"gainL"` Scale bool `json:"scale"` }
Options for ConvertS2ToRgb