pixweight

package
v0.0.0-...-d35a074 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2024 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package pixweight associates a pixelation raster value with a normalized weight (between 0 and 1) for a pixel.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pixel

type Pixel map[int]weight

Pixel is a set of normalized weights (a value between 0 and 1) for the values given to a pixel.

Each pixel is assumed to be independent of all other pixels.

func New

func New() Pixel

New creates a new Pixel object to store normalized weight from pixel types.

By default, the ID 0 is defined with weight 0.

func ReadTSV

func ReadTSV(r io.Reader) (Pixel, error)

ReadTSV reads a TSV file used to define the normalized weight values for a given set of pixels values in a pixelation.

The pixel weight file is a tab-delimited file with the following columns:

-key	the value used as identifier
-weight	the normalized weight for a pixel with that value

Any other columns, will be ignored. Here is an example of a pixel weight file:

key	weight	comment
0	0.000000	deep ocean
1	0.010000	oceanic plateaus
2	0.050000	continental shelf
3	0.950000	lowlands
4	1.000000	highlands
5	0.001000	ice sheets

func (Pixel) LogWeight

func (px Pixel) LogWeight(v int) float64

LogWeight returns the log of the weight for a given raster value.

func (Pixel) Set

func (px Pixel) Set(v int, w float64) error

Set set a pixel normalized weight for a given raster value.

func (Pixel) TSV

func (px Pixel) TSV(w io.Writer) error

TSV encodes pixel weights as a TSV file.

func (Pixel) Values

func (px Pixel) Values() []int

Values return the raster values that have a defined weights.

func (Pixel) Weight

func (px Pixel) Weight(v int) float64

Weight returns the normalized weight for a given raster value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL