mapalgebra-0.2.1: Efficient, polymorphic Map Algebra.

Copyright (c) Colin Woodbury 2018 - 2020 BSD3 Colin Woodbury None Haskell2010

Geography.MapAlgebra

Description

This library is an implementation of Map Algebra as described in the book GIS and Cartographic Modeling (GaCM) by Dana Tomlin. The fundamental primitive is the Raster, a rectangular grid of data that usually describes some area on the earth. A Raster need not contain numerical data, however, and need not just represent satellite imagery. It is essentially a matrix, which of course forms a Functor, and thus is available for all the operations we would expect to run on any Functor. /GIS and Cartographic Modeling/ doesn't lean on this fact, and so describes many seemingly custom operations which to Haskell are just applications of fmap or zipWith with pure functions.

Here are the main classes of operations ascribed to Map Algebra and their corresponding approach in Haskell:

• Single-Raster Local Operations -> fmap with pure functions
• Multi-Raster Local Operations -> foldl with zipWith and pure functions
• Focal Operations -> massiv-based smart Stencil operations
• Zonal Operations -> Not yet implemented

Whether it is meaningful to perform operations between two given Rasters (i.e. whether the Rasters properly overlap on the earth) is not handled in this library and is left to the application.

The "colour ramp" generation functions (like greenRed) gratefully borrow colour sets from Gretchen N. Peterson's book Cartographer's Toolkit.

A Word on Massiv: Fused, Parallel Arrays

Thanks to the underlying Array library massiv, most operations over and between Rasters are fused, meaning that no extra memory is allocated in between each step of a composite operation.

Take the Enhanced Vegetation Index calculation:

evi :: Raster D p r c Double -> Raster D p r c Double -> Raster D p r c Double -> Raster D p r c Double
evi nir red blue = 2.5 * (numer / denom)
where numer = nir - red
denom = nir + (6 * red) - (7.5 * blue) + 1


8 binary operators are used here, but none allocate new memory. It's only when some lazy Raster is made strict that calculations occur and memory is allocated.

Provided your machine has more than 1 CPU, Rasters read by functions like fromRGBA will automatically be in Parallel mode. This means that forcing calculations with strict will cause evaluation to be done with every CPU your machine has. The effect of this is quite potent for Focal Operations, which yield special, cache-friendly windowed (DW) Rasters.

Familiarity with Massiv will help in using this library. A guide can be found here.

Compilation Options for Best Performance

When using this library, always compile your project with -threaded and -with-rtsopts=-N. These will ensure your executables will automatically use all the available CPU cores.

As always, -O2 is your friend. The {-# INLINE ... #-} pragma is also very likely to improve the performance of code that uses functions from this library. Make sure to benchmark proactively.

For particularly mathy operations like fmean, compiling with -fllvm grants about a 2x speedup.

Synopsis

Types

Rasters

newtype Raster u p (r :: Nat) (c :: Nat) a Source #

A rectangular grid of data representing some area on the earth.

• u: What is the underlying representation of this Raster? (see massiv)
• p: What Projection is this Raster in?
• r: How many rows does this Raster have?
• c: How many columns does this Raster have?
• a: What data type is held in this Raster?

By having explicit p, r, and c, we make impossible any operation between two Rasters of differing size or projection. Conceptually, we consider Rasters of different size and projection to be entirely different types. Example:

-- | A lazy 256x256 Raster with the value 5 at every index. Uses DataKinds
-- and "type literals" to achieve the same-size guarantee.
myRaster :: Raster D WebMercator 256 256 Int
myRaster = constant D Par 5

>>> length myRaster
65536


Constructors

 Raster Fields_array :: Array u Ix2 a
Instances
where cm = blueGreen . breaks $histogram r  If you aren't interested in colour but still want to render your Raster, consider grayscale. Coloured Rasters can be unwrapped with _array and then output with functions like writeImage. grayscale :: Functor (Raster u p r c) => Raster u p r c a -> Raster u p r c (Pixel Y a) Source # Convert a Raster into grayscale pixels, suitable for easy output with functions like writeImage. newtype Histogram Source # A count of Word8 values across some Raster. Constructors  Histogram Fields_histogram :: Vector Word Instances  Source # Instance detailsDefined in Geography.MapAlgebra Methods Source # Instance detailsDefined in Geography.MapAlgebra MethodsshowList :: [Histogram] -> ShowS # histogram :: Source u Ix2 Word8 => Raster u p r c Word8 -> Histogram Source # Given a Raster of byte data, efficiently produce a Histogram that describes value counts across the image. To be passed to breaks. breaks :: Histogram -> [Word8] Source # Given a Histogram, produce a list of "colour breaks" as needed by functions like greenRed. An invisible pixel (alpha channel set to 0). greenRed :: Ord k => [k] -> Map k (Pixel RGBA Word8) Source # From page 32 of Cartographer's Toolkit. spectrum :: Ord k => [k] -> Map k (Pixel RGBA Word8) Source # From page 33 of Cartographer's Toolkit. blueGreen :: Ord k => [k] -> Map k (Pixel RGBA Word8) Source # From page 34 of Cartographer's Toolkit. purpleYellow :: Ord k => [k] -> Map k (Pixel RGBA Word8) Source # From page 35 of Cartographer's Toolkit. brownBlue :: Ord k => [k] -> Map k (Pixel RGBA Word8) Source # From page 36 of Cartographer's Toolkit. grayBrown :: Ord k => [k] -> Map k (Pixel RGBA Word8) Source # From page 37 of Cartographer's Toolkit. greenPurple :: Ord k => [k] -> Map k (Pixel RGBA Word8) Source # From page 38 of Cartographer's Toolkit. brownYellow :: Ord k => [k] -> Map k (Pixel RGBA Word8) Source # From page 39 of Cartographer's Toolkit. purpleGreen :: Ord k => [k] -> Map k (Pixel RGBA Word8) Source # From page 40 of Cartographer's Toolkit. purpleRed :: Ord k => [k] -> Map k (Pixel RGBA Word8) Source # From page 41 of Cartographer's Toolkit. Output and Display For coloured output, first use classify over your Raster to produce a Raster u p r c (Pixel RGBA Word8). Then unwrap it with _array and output with something like writeImage. For quick debugging, you can visualize a Raster with displayImage: raster :: Raster D p 512 512 Word8 >>> displayImage . _array . strict S . grayscale  writeImage :: (Source r Ix2 (Pixel cs e), ColorSpace cs e) => FilePath -> Image r cs e -> IO () # This function will guess an output file format from the file extension and will write to file any image with the colorspace that is supported by that format. Precision of the image might be adjusted using Elevator if precision of the source array is not supported by the image file format. For instance an (Image r RGBA Double) being saved as PNG file would be written as (Image r RGBA Word16), thus using highest supported precision Word16 for that format. If automatic colors space is also desired, writeImageAuto can be used instead. Can throw ConvertError, EncodeError and other usual IO errors. writeImageAuto :: (Source r Ix2 (Pixel cs e), ColorSpace cs e, ToYA cs e, ToRGBA cs e, ToYCbCr cs e, ToCMYK cs e) => FilePath -> Image r cs e -> IO () # Write an image to file while performing all necessary precisiona and color space conversions. displayImage :: Writable (Auto TIF) (Image r cs e) => Image r cs e -> IO () # Makes a call to an external viewer that is set as a default image viewer by the OS. This is a non-blocking function call, so it might take some time before an image will appear. png :: (Source u Ix2 (Pixel cs a), ColorSpace cs a) => Raster u p r c (Pixel cs a) -> ByteString Source # Render a PNG-encoded ByteString from a coloured Raster. Useful for returning a Raster from a webserver endpoint. Projections class Projection p where Source # The Earth is not a sphere. Various schemes have been invented throughout history that provide Point coordinates for locations on the earth, although all are approximations and come with trade-offs. We call these Projections, since they are a mapping of Sphere coordinates to some other approximation. The Projection used most commonly for mapping on the internet is called WebMercator. A Projection is also known as a Coordinate Reference System (CRS). Use reproject to convert Points between various Projections. Note: Full support for Projections is still pending. Methods Convert a Point in this Projection to one of radians on a perfect Sphere. Convert a Point of radians on a perfect sphere to that of a specific Projection. Instances  Source # Instance detailsDefined in Geography.MapAlgebra Methods reproject :: (Projection p, Projection r) => Point p -> Point r Source # Reproject a Point from one Projection to another. data Sphere Source # A perfect geometric sphere. The earth isn't actually shaped this way, but it's a convenient middle-ground for converting between various Projections. Instances  Source # Instance detailsDefined in Geography.MapAlgebra Methods data LatLng Source # Latitude (north-south position) and Longitude (east-west position). The most commonly used Projection for mapping in internet applications. data Point p Source # A location on the Earth in some Projection. Constructors  Point Fieldsx :: !Double y :: !Double Instances  Eq (Point p) Source # Instance detailsDefined in Geography.MapAlgebra Methods(==) :: Point p -> Point p -> Bool #(/=) :: Point p -> Point p -> Bool # Show (Point p) Source # Instance detailsDefined in Geography.MapAlgebra MethodsshowsPrec :: Int -> Point p -> ShowS #show :: Point p -> String #showList :: [Point p] -> ShowS # Map Algebra Local Operations Operations between Rasters. All operations are element-wise: 1 1 + 2 2 == 3 3 1 1 2 2 3 3 2 2 * 3 3 == 6 6 2 2 3 3 6 6  If an operation you need isn't available here, use our zipWith: zipWith :: (a -> b -> d) -> Raster u p r c a -> Raster u p r c b -> Raster D p r c d -- Your operation. foo :: Int -> Int -> Int bar :: Raster u p r c Int -> Raster u p r c Int -> Raster D p r c Int bar a b = zipWith foo a b  zipWith :: (Source u Ix2 a, Source u Ix2 b) => (a -> b -> d) -> Raster u p r c a -> Raster u p r c b -> Raster D p r c d Source # Combine two Rasters, element-wise, with a binary operator. Unary If you want to do simple unary Raster -> Raster operations (called LocalCalculation in GaCM), Raster is a Functor so you can use fmap as normal: myRaster :: Raster D p r c Int -- Add 17 to every value in the Raster. fmap (+ 17) myRaster  classify :: (Ord a, Functor f) => b -> Map a b -> f a -> f b Source # Called LocalClassification in GaCM. The first argument is the value to give to any index whose value is less than the lowest break in the Map. This is a glorified fmap operation, but we expose it for convenience. Binary You can safely use these with the foldl family on any Foldable of Rasters. You would likely want foldl1' which is provided by both List and Vector. Keep in mind that Raster D has a Num instance, so you can use all the normal math operators with them as well. lmax :: (Ord a, Source u Ix2 a) => Raster u p r c a -> Raster u p r c a -> Raster D p r c a Source # Finds the maximum value at each index between two Rasters. lmin :: (Ord a, Source u Ix2 a) => Raster u p r c a -> Raster u p r c a -> Raster D p r c a Source # Finds the minimum value at each index between two Rasters. Other There is no binary form of these functions that exists without producing numerical error, so you can't use the foldl family with these. Consider the average operation, where the following is not true: $\forall abc \in \mathbb{R}. \frac{\frac{a + b}{2} + c}{2} = \frac{a + b + c}{3}$ lmean :: (Real a, Fractional b, KnownNat r, KnownNat c) => NonEmpty (Raster D p r c a) -> Raster D p r c b Source # Averages the values per-index of all Rasters in a collection. lvariety :: (KnownNat r, KnownNat c, Eq a) => NonEmpty (Raster D p r c a) -> Raster D p r c Word Source # The count of unique values at each shared index. lmajority :: (KnownNat r, KnownNat c, Ord a) => NonEmpty (Raster D p r c a) -> Raster D p r c a Source # The most frequently appearing value at each shared index. lminority :: (KnownNat r, KnownNat c, Ord a) => NonEmpty (Raster D p r c a) -> Raster D p r c a Source # The least frequently appearing value at each shared index. lvariance :: forall p a r c. (Real a, KnownNat r, KnownNat c) => NonEmpty (Raster D p r c a) -> Maybe (Raster D p r c Double) Source # A measure of how spread out a dataset is. This calculation will fail with Nothing if a length 1 list is given. Focal Operations Operations on one Raster, given some polygonal neighbourhood. Your Raster must be of a Manifest type (i.e. backed by real memory) before you attempt any focal operations. Without this constraint, wayward users run the risk of setting up operations that would perform terribly. Use strict to easily convert a lazy Raster to a memory-backed one. myRaster :: Raster D p r c Float averaged :: Raster DW p r c Float averaged = fmean$ strict P myRaster


fsum :: (Num a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c a Source #

fproduct :: (Num a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c a Source #

Focal Product.

fmonoid :: (Monoid a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c a Source #

Focal Monoid - combine all elements of a neighbourhood via their Monoid instance. In terms of precedence, the neighbourhood focus is the "left-most", and all other elements are "added" to it.

This is not mentioned in GaCM, but seems useful nonetheless.

fmean :: (Fractional a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c a Source #

Focal Mean.

fmax :: (Ord a, Bounded a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c a Source #

Focal Maximum.

fmin :: (Ord a, Bounded a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c a Source #

Focal Minimum.

fmajority :: (Ord a, Default a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c a Source #

Focal Majority - the most frequently appearing value in each neighbourhood.

fminority :: (Ord a, Default a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c a Source #

Focal Minority - the least frequently appearing value in each neighbourhood.

fvariety :: (Ord a, Default a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c Word Source #

Focal Variety - the number of unique values in each neighbourhood.

fpercentage :: (Eq a, Default a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c Double Source #

Focal Percentage - the percentage of neighbourhood values that are equal to the neighbourhood focus. Not to be confused with fpercentile.

fpercentile :: (Ord a, Default a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c Double Source #

Focal Percentile - the percentage of neighbourhood values that are less than the neighbourhood focus. Not to be confused with fpercentage.

Lineal

Focal operations that assume that groups of data points represent line-like objects in a Raster. GaCM calls these lineal characteristics and describes them fully on page 18 and 19.

newtype Line Source #

A description of lineal directions with the same encoding as Drain. See flinkage and flength.

Constructors

 Line Fields_line :: Word8
Instances
 Source # Instance detailsDefined in Geography.MapAlgebra Methods(==) :: Line -> Line -> Bool #(/=) :: Line -> Line -> Bool # Source # Instance detailsDefined in Geography.MapAlgebra Methodscompare :: Line -> Line -> Ordering #(<) :: Line -> Line -> Bool #(<=) :: Line -> Line -> Bool #(>) :: Line -> Line -> Bool #(>=) :: Line -> Line -> Bool #max :: Line -> Line -> Line #min :: Line -> Line -> Line # Source # Instance detailsDefined in Geography.MapAlgebra MethodsshowsPrec :: Int -> Line -> ShowS #show :: Line -> String #showList :: [Line] -> ShowS # Source # Instance detailsDefined in Geography.MapAlgebra MethodssizeOf :: Line -> Int #pokeElemOff :: Ptr Line -> Int -> Line -> IO () #peekByteOff :: Ptr b -> Int -> IO Line #pokeByteOff :: Ptr b -> Int -> Line -> IO () #poke :: Ptr Line -> Line -> IO () # Source # Instance detailsDefined in Geography.MapAlgebra Methodsdef :: Line # Source # Instance detailsDefined in Geography.MapAlgebra Methodsrnf :: Line -> () # Source # Instance detailsDefined in Geography.MapAlgebra MethodssizeOf# :: Line -> Int# #readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#State# s, Line#) #writeByteArray# :: MutableByteArray# s -> Int# -> Line -> State# s -> State# s #setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Line -> State# s -> State# s #readOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Line#) #writeOffAddr# :: Addr# -> Int# -> Line -> State# s -> State# s #setOffAddr# :: Addr# -> Int# -> Int# -> Line -> State# s -> State# s #

flinkage :: (Default a, Eq a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c Line Source #

Focal Linkage - a description of how each neighbourhood focus is connected to its neighbours. Foci of equal value to none of their neighbours will have a value of 0.

flength :: Functor (Raster u p r c) => Raster u p r c Line -> Raster u p r c Double Source #

Focal Length - the length of the lineal structure at every location. The result is in "pixel units", where 1 is the height/width of one pixel.

Areal

Focal operations that assume that groups of data points represent 2D areas in a Raster. GaCM calls these areal characteristics and describes them fully on page 20 and 21.

data Corners Source #

A layout of the areal conditions of a single Raster pixel. It describes whether each pixel corner is occupied by the same "areal zone" as the pixel centre.

Constructors

 Corners Fields_topLeft :: !Surround _bottomLeft :: !Surround _bottomRight :: !Surround _topRight :: !Surround
Instances
 Source # Instance detailsDefined in Geography.MapAlgebra Methods(==) :: Corners -> Corners -> Bool #(/=) :: Corners -> Corners -> Bool # Source # Instance detailsDefined in Geography.MapAlgebra MethodsshowList :: [Corners] -> ShowS # Source # Instance detailsDefined in Geography.MapAlgebra Methodsrnf :: Corners -> () #

data Surround Source #

A state of surroundedness of a pixel corner. For the examples below, the bottom-left pixel is considered the focus and we're wondering about the surroundedness of its top-right corner.

Constructors

 Complete A corner has three of the same opponent against it.The corner is considered "occupied" by the opponent value, thus forming a diagonal areal edge.[ 1 1 ] [ 0 1 ]  OneSide One edge of a corner is touching an opponent, but the other edge touches a friend.[ 1 1 ] or [ 0 1 ] [ 0 0 ] [ 0 1 ]  Open A corner is surrounded by friends.[ 0 0 ] or [ 0 0 ] or [ 1 0 ] [ 0 0 ] [ 0 1 ] [ 0 0 ]  RightAngle Similar to Complete, except that the diagonal opponent doesn't match the other two. The corner is considered surrounded, but not "occupied".[ 1 2 ] [ 0 1 ]  OutFlow Similar to Complete, except that the area of the focus surrounds the diagonal neighbour.[ 0 1 ] [ 0 0 ] 
Instances
 Source # Instance detailsDefined in Geography.MapAlgebra Methods Source # Instance detailsDefined in Geography.MapAlgebra Methods(<) :: Surround -> Surround -> Bool #(>) :: Surround -> Surround -> Bool # Source # Instance detailsDefined in Geography.MapAlgebra MethodsshowList :: [Surround] -> ShowS # Source # Instance detailsDefined in Geography.MapAlgebra Methodsrnf :: Surround -> () #

fpartition :: (Default a, Eq a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c Corners Source #

Focal Partition - the areal form of each location, only considering the top-right edge.

fshape :: (Default a, Eq a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c Corners Source #

Like fpartition, but considers the Surround of all corners. Is alluded to in GaCM but isn't given its own operation name.

If preparing for ffrontage or farea, you almost certainly want this function and not fpartition.

ffrontage :: Functor (Raster u p r c) => Raster u p r c Corners -> Raster u p r c Double Source #

Focal Frontage - the length of areal edges between each pixel and its neighbourhood.

Usually, the output of fshape is the appropriate input for this function.

farea :: Functor (Raster u p r c) => Raster u p r c Corners -> Raster u p r c Double Source #

Focal Area - the area of the shape made up by a neighbourhood focus and its surrounding pixels. Each pixel is assumed to have length and width of 1.

Usually, the output of fshape is the appropriate input for this function.

Surficial

Focal operations that work over elevation Rasters. GaCM calls elevation features surficial characteristics and describes them fully on page 21 and 22.

Some of these operations require finding a "best-fit plane" that approximates the surficial shape of each pixel. Each pixel has 9 "facet points" calculated for it based on its surrounding pixels. We then use these facets to determine a plane which adheres to this equation:

$ax + by + c = z$ This is a linear equation that we can solve for in the form $$Ax = B$$. For facet points $$(x_i, y_i, z_i)$$, we have:

$\begin{bmatrix} x_0 & y_0 & 1 \\ x_1 & y_1 & 1 \\ \vdots & \vdots & \vdots \\ x_n & y_n & 1 \end{bmatrix} \begin{bmatrix} a\\ b\\ c \end{bmatrix} = \begin{bmatrix} z_0\\ z_1\\ \vdots\\ z_n \end{bmatrix}$

Since this system of equations is "over determined", we rework the above to find the coefficients of the best-fitting plane via: $\begin{bmatrix} a\\ b\\ c \end{bmatrix} = \boxed{(A^{T}A)^{-1}A^{T}}B$ The boxed section is called the "left pseudo inverse" and is available as leftPseudo. The actual values of $$A$$ don't matter for our purposes, hence $$A$$ can be fixed to avoid redundant calculations.

newtype Drain Source #

The main type for fdownstream and fupstream, used to calculate Focal Drainage. This scheme for encoding drainage patterns is described on page 81 of GaCM.

Full Explanation

Expand

Fluid can flow in or out of a square pixel in one of 256 ways. Imagine a pit, whose neighbours are all higher in elevation: liquid would flow in from all eight compass directions, but no liquid would flow out. Consider then a neighbourhood of random heights - fluid might flow in or out of the focus in any permutation of the eight directions.

The scheme for encoding these permutations in a single Word8 as described in GaCM is this:

Flow in a particular direction is represented by a power of 2:

[  1   2   4  ]
[  8       16 ]
[ 32  64  128 ]


Direction values are summed to make the encoding. If there were drainage to the North, East, and SouthEast, we'd see a sum of $$2 + 16 + 128 = 146$$ to uniquely represent this.

Analysing a drainage pattern from a Drain is just as easy: check if the bit corresponding to the desired direction is flipped. The direction function handles this.

Constructors

 Drain Fields_drain :: Word8
Instances
 Source # Instance detailsDefined in Geography.MapAlgebra Methods(==) :: Drain -> Drain -> Bool #(/=) :: Drain -> Drain -> Bool # Source # Instance detailsDefined in Geography.MapAlgebra Methods(<) :: Drain -> Drain -> Bool #(<=) :: Drain -> Drain -> Bool #(>) :: Drain -> Drain -> Bool #(>=) :: Drain -> Drain -> Bool #max :: Drain -> Drain -> Drain #min :: Drain -> Drain -> Drain # Source # Instance detailsDefined in Geography.MapAlgebra MethodsshowsPrec :: Int -> Drain -> ShowS #show :: Drain -> String #showList :: [Drain] -> ShowS # Source # Instance detailsDefined in Geography.MapAlgebra MethodssizeOf :: Drain -> Int #pokeElemOff :: Ptr Drain -> Int -> Drain -> IO () #peekByteOff :: Ptr b -> Int -> IO Drain #pokeByteOff :: Ptr b -> Int -> Drain -> IO () #poke :: Ptr Drain -> Drain -> IO () # Source # Instance detailsDefined in Geography.MapAlgebra Methods Source # Instance detailsDefined in Geography.MapAlgebra Methodsrnf :: Drain -> () # Source # Instance detailsDefined in Geography.MapAlgebra MethodsreadByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#State# s, Drain#) #writeByteArray# :: MutableByteArray# s -> Int# -> Drain -> State# s -> State# s #setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Drain -> State# s -> State# s #readOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Drain#) #writeOffAddr# :: Addr# -> Int# -> Drain -> State# s -> State# s #setOffAddr# :: Addr# -> Int# -> Int# -> Drain -> State# s -> State# s #

data Direction Source #

Directions that neighbourhood foci can be connected by.

Constructors

 East NorthEast North NorthWest West SouthWest South SouthEast
Instances
 Source # Instance detailsDefined in Geography.MapAlgebra MethodsenumFrom :: Direction -> [Direction] # Source # Instance detailsDefined in Geography.MapAlgebra Methods Source # Instance detailsDefined in Geography.MapAlgebra Methods Source # Instance detailsDefined in Geography.MapAlgebra MethodsshowList :: [Direction] -> ShowS #

Does a given Drain indicate flow in a certain Direction?

All Directions that a Drain indicates flow toward.

The opposite of directions.

fvolume :: (Fractional a, Default a, Manifest u Ix2 a) => Raster u p r c a -> Raster DW p r c a Source #

Focal Volume - the surficial volume under each pixel, assuming the Raster represents elevation in some way.

fgradient :: Manifest u Ix2 Double => Raster u p r c Double -> Raster DW p r c Double Source #

Focal Gradient - a measurement of surficial slope for each pixel relative to the horizonal cartographic plane. Results are in radians, with a flat plane having a slope angle of 0 and a near-vertical plane approaching $$\tau / 4$$.

faspect :: Manifest u Ix2 Double => Raster u p r c Double -> Raster DW p r c (Maybe Double) Source #

Focal Aspect - the compass direction toward which the surface descends most rapidly. Results are in radians, with 0 or $$\tau$$ being North, $$\tau / 4$$ being East, and so on. For areas that are essentially flat, their aspect will be Nothing.

faspect' :: Manifest u Ix2 Double => Raster u p r c Double -> Raster DW p r c Double Source #

Like faspect, but slightly faster. Beware of nonsense results when the plane is flat.

fdownstream :: Manifest u Ix2 Double => Raster u p r c Double -> Raster DW p r c Drain Source #

Focal Drainage - downstream portion. This indicates the one or more compass directions of steepest descent from each location. Appropriate as the input to fupstream.

Note: Peak-like surfaces will not flow equally in all 8 directions. Consider this neighbourhood:

[ 1 1 1 ]
[ 1 3 1 ]
[ 1 1 1 ]


According to the rules in GaCM for calculating the intermediate surficial "facet" points for the focus, 3, we arrive at the following facet height matrix:

[ 1.5 2 1.5 ]
[  2  3  2  ]
[ 1.5 2 1.5 ]


With these numbers it's clear that the corners would yield a steeper angle, so our resulting Drain would only contain the directions of the diagonals.

fupstream :: Manifest u Ix2 Drain => Raster u p r c Drain -> Raster DW p r c Drain Source #

Focal Drainage - upstream portion. This indicates the one of more compass directions from which liquid would flow into each surface location. See also fdownstream.

Utilities

The first part to the "left pseudo inverse" needed to calculate a best-fitting plane of 9 points.

$$\tau$$. One full rotation of the unit circle.

Massiv Re-exports

data D #

Delayed representation.

Constructors

 D
Instances
 Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodsshowsPrec :: Int -> D -> ShowS #show :: D -> String #showList :: [D] -> ShowS # Num e => Numeric D e Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodsplusScalar :: Index ix => Array D ix e -> e -> Array D ix e #minusScalar :: Index ix => Array D ix e -> e -> Array D ix e #multiplyScalar :: Index ix => Array D ix e -> e -> Array D ix e #absPointwise :: Index ix => Array D ix e -> Array D ix e #additionPointwise :: Index ix => Array D ix e -> Array D ix e -> Array D ix e #subtractionPointwise :: Index ix => Array D ix e -> Array D ix e -> Array D ix e #multiplicationPointwise :: Index ix => Array D ix e -> Array D ix e -> Array D ix e #powerPointwise :: Index ix => Array D ix e -> Int -> Array D ix e #unsafeLiftArray :: Index ix => (a -> e) -> Array D ix a -> Array D ix e #unsafeLiftArray2 :: Index ix => (a -> b -> e) -> Array D ix a -> Array D ix b -> Array D ix e # Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodsdivideScalar :: Index ix => Array D ix e -> e -> Array D ix e #divisionPointwise :: Index ix => Array D ix e -> Array D ix e -> Array D ix e #recipPointwise :: Index ix => Array D ix e -> Array D ix e #sqrtPointwise :: Index ix => Array D ix e -> Array D ix e # Index ix => Resize D ix Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodsunsafeResize :: Index ix' => Sz ix' -> Array D ix e -> Array D ix' e # Index ix => Stream D ix e Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodstoStream :: Array D ix e -> Steps Id e # Index ix => Construct D ix e Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodssetComp :: Comp -> Array D ix e -> Array D ix e #makeArray :: Comp -> Sz ix -> (ix -> e) -> Array D ix e #makeArrayLinear :: Comp -> Sz ix -> (Int -> e) -> Array D ix e # Index ix => Extract D ix e Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodsunsafeExtract :: ix -> Sz ix -> Array D ix e -> Array (R D) ix e # Index ix => Source D ix e Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodsunsafeIndex :: Array D ix e -> ix -> e #unsafeLinearIndex :: Array D ix e -> Int -> e # Index ix => Load D ix e Instance detailsDefined in Data.Massiv.Array.Delayed.Pull Associated Typestype R D :: Type # MethodsgetComp :: Array D ix e -> Comp #size :: Array D ix e -> Sz ix #loadArrayM :: Monad m => Scheduler m () -> Array D ix e -> (Int -> e -> m ()) -> m () #defaultElement :: Array D ix e -> Maybe e #maxSize :: Array D ix e -> Maybe (Sz ix)unsafeLoadIntoS :: (Mutable r' ix e, PrimMonad m) => MArray (PrimState m) r' ix e -> Array D ix e -> m (MArray (PrimState m) r' ix e)unsafeLoadInto :: (Mutable r' ix e, MonadIO m) => MArray RealWorld r' ix e -> Array D ix e -> m (MArray RealWorld r' ix e) Index ix => StrideLoad D ix e Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodsloadArrayWithStrideM :: Monad m => Scheduler m () -> Stride ix -> Sz ix -> Array D ix e -> (Int -> e -> m ()) -> m () # (Elt D ix e ~ Array D (Lower ix) e, Index ix) => OuterSlice D ix e Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodsunsafeOuterSlice :: Array D ix e -> Int -> Elt D ix e # (Elt D ix e ~ Array D (Lower ix) e, Index ix) => InnerSlice D ix e Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodsunsafeInnerSlice :: Array D ix e -> (Sz (Lower ix), Sz Int) -> Int -> Elt D ix e # (Index ix, Index (Lower ix), Elt D ix e ~ Array D (Lower ix) e) => Slice D ix e Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodsunsafeSlice :: MonadThrow m => Array D ix e -> ix -> Sz ix -> Dim -> m (Elt D ix e) # Functor (Array D ix) Instance detailsDefined in Data.Massiv.Array.Delayed.Pull Methodsfmap :: (a -> b) -> Array D ix a -> Array D ix b #(<$) :: a -> Array D ix b -> Array D ix a # Index ix => Applicative (Array D ix) Instance detailsDefined in Data.Massiv.Array.Delayed.Pull Methodspure :: a -> Array D ix a #(<*>) :: Array D ix (a -> b) -> Array D ix a -> Array D ix b #liftA2 :: (a -> b -> c) -> Array D ix a -> Array D ix b -> Array D ix c #(*>) :: Array D ix a -> Array D ix b -> Array D ix b #(<*) :: Array D ix a -> Array D ix b -> Array D ix a # Index ix => Foldable (Array D ix) Row-major sequential folding over a Delayed array. Instance detailsDefined in Data.Massiv.Array.Delayed.Pull Methodsfold :: Monoid m => Array D ix m -> m #foldMap :: Monoid m => (a -> m) -> Array D ix a -> m #foldr :: (a -> b -> b) -> b -> Array D ix a -> b #foldr' :: (a -> b -> b) -> b -> Array D ix a -> b #foldl :: (b -> a -> b) -> b -> Array D ix a -> b #foldl' :: (b -> a -> b) -> b -> Array D ix a -> b #foldr1 :: (a -> a -> a) -> Array D ix a -> a #foldl1 :: (a -> a -> a) -> Array D ix a -> a #toList :: Array D ix a -> [a] #null :: Array D ix a -> Bool #length :: Array D ix a -> Int #elem :: Eq a => a -> Array D ix a -> Bool #maximum :: Ord a => Array D ix a -> a #minimum :: Ord a => Array D ix a -> a #sum :: Num a => Array D ix a -> a #product :: Num a => Array D ix a -> a # (Eq e, Index ix) => Eq (Array D ix e) Instance detailsDefined in Data.Massiv.Array.Delayed.Pull Methods(==) :: Array D ix e -> Array D ix e -> Bool #(/=) :: Array D ix e -> Array D ix e -> Bool # (Index ix, Floating e) => Floating (Array D ix e) Instance detailsDefined in Data.Massiv.Array.Delayed.Pull Methodspi :: Array D ix e #exp :: Array D ix e -> Array D ix e #log :: Array D ix e -> Array D ix e #sqrt :: Array D ix e -> Array D ix e #(**) :: Array D ix e -> Array D ix e -> Array D ix e #logBase :: Array D ix e -> Array D ix e -> Array D ix e #sin :: Array D ix e -> Array D ix e #cos :: Array D ix e -> Array D ix e #tan :: Array D ix e -> Array D ix e #asin :: Array D ix e -> Array D ix e #acos :: Array D ix e -> Array D ix e #atan :: Array D ix e -> Array D ix e #sinh :: Array D ix e -> Array D ix e #cosh :: Array D ix e -> Array D ix e #tanh :: Array D ix e -> Array D ix e #asinh :: Array D ix e -> Array D ix e #acosh :: Array D ix e -> Array D ix e #atanh :: Array D ix e -> Array D ix e #log1p :: Array D ix e -> Array D ix e #expm1 :: Array D ix e -> Array D ix e #log1pexp :: Array D ix e -> Array D ix e #log1mexp :: Array D ix e -> Array D ix e # (Index ix, Fractional e) => Fractional (Array D ix e) Instance detailsDefined in Data.Massiv.Array.Delayed.Pull Methods(/) :: Array D ix e -> Array D ix e -> Array D ix e #recip :: Array D ix e -> Array D ix e #fromRational :: Rational -> Array D ix e # (Index ix, Num e) => Num (Array D ix e) Instance detailsDefined in Data.Massiv.Array.Delayed.Pull Methods(+) :: Array D ix e -> Array D ix e -> Array D ix e #(-) :: Array D ix e -> Array D ix e -> Array D ix e #(*) :: Array D ix e -> Array D ix e -> Array D ix e #negate :: Array D ix e -> Array D ix e #abs :: Array D ix e -> Array D ix e #signum :: Array D ix e -> Array D ix e #fromInteger :: Integer -> Array D ix e # (Ord e, Index ix) => Ord (Array D ix e) Instance detailsDefined in Data.Massiv.Array.Delayed.Pull Methodscompare :: Array D ix e -> Array D ix e -> Ordering #(<) :: Array D ix e -> Array D ix e -> Bool #(<=) :: Array D ix e -> Array D ix e -> Bool #(>) :: Array D ix e -> Array D ix e -> Bool #(>=) :: Array D ix e -> Array D ix e -> Bool #max :: Array D ix e -> Array D ix e -> Array D ix e #min :: Array D ix e -> Array D ix e -> Array D ix e # (Ragged L ix e, Show e) => Show (Array D ix e) Instance detailsDefined in Data.Massiv.Array.Delayed.Pull MethodsshowsPrec :: Int -> Array D ix e -> ShowS #show :: Array D ix e -> String #showList :: [Array D ix e] -> ShowS # Functor (Raster D p r c) Source # Instance detailsDefined in Geography.MapAlgebra Methodsfmap :: (a -> b) -> Raster D p r c a -> Raster D p r c b #(<$) :: a -> Raster D p r c b -> Raster D p r c a # (KnownNat r, KnownNat c) => Applicative (Raster D p r c) Source # Instance detailsDefined in Geography.MapAlgebra Methodspure :: a -> Raster D p r c a #(<*>) :: Raster D p r c (a -> b) -> Raster D p r c a -> Raster D p r c b #liftA2 :: (a -> b -> c0) -> Raster D p r c a -> Raster D p r c b -> Raster D p r c c0 #(*>) :: Raster D p r c a -> Raster D p r c b -> Raster D p r c b #(<*) :: Raster D p r c a -> Raster D p r c b -> Raster D p r c a # Foldable (Raster D p r c) Source # length has a specialized $$\mathcal{O}(1)$$ implementation. Instance detailsDefined in Geography.MapAlgebra Methodsfold :: Monoid m => Raster D p r c m -> m #foldMap :: Monoid m => (a -> m) -> Raster D p r c a -> m #foldr :: (a -> b -> b) -> b -> Raster D p r c a -> b #foldr' :: (a -> b -> b) -> b -> Raster D p r c a -> b #foldl :: (b -> a -> b) -> b -> Raster D p r c a -> b #foldl' :: (b -> a -> b) -> b -> Raster D p r c a -> b #foldr1 :: (a -> a -> a) -> Raster D p r c a -> a #foldl1 :: (a -> a -> a) -> Raster D p r c a -> a #toList :: Raster D p r c a -> [a] #null :: Raster D p r c a -> Bool #length :: Raster D p r c a -> Int #elem :: Eq a => a -> Raster D p r c a -> Bool #maximum :: Ord a => Raster D p r c a -> a #minimum :: Ord a => Raster D p r c a -> a #sum :: Num a => Raster D p r c a -> a #product :: Num a => Raster D p r c a -> a # Eq a => Eq (Raster D p r c a) Source # Instance detailsDefined in Geography.MapAlgebra Methods(==) :: Raster D p r c a -> Raster D p r c a -> Bool #(/=) :: Raster D p r c a -> Raster D p r c a -> Bool # (Fractional a, KnownNat r, KnownNat c) => Fractional (Raster D p r c a) Source # Instance detailsDefined in Geography.MapAlgebra Methods(/) :: Raster D p r c a -> Raster D p r c a -> Raster D p r c a #recip :: Raster D p r c a -> Raster D p r c a #fromRational :: Rational -> Raster D p r c a # (Num a, KnownNat r, KnownNat c) => Num (Raster D p r c a) Source # Instance detailsDefined in Geography.MapAlgebra Methods(+) :: Raster D p r c a -> Raster D p r c a -> Raster D p r c a #(-) :: Raster D p r c a -> Raster D p r c a -> Raster D p r c a #(*) :: Raster D p r c a -> Raster D p r c a -> Raster D p r c a #negate :: Raster D p r c a -> Raster D p r c a #abs :: Raster D p r c a -> Raster D p r c a #signum :: Raster D p r c a -> Raster D p r c a #fromInteger :: Integer -> Raster D p r c a # Semigroup a => Semigroup (Raster D p r c a) Source # Instance detailsDefined in Geography.MapAlgebra Methods(<>) :: Raster D p r c a -> Raster D p r c a -> Raster D p r c a #sconcat :: NonEmpty (Raster D p r c a) -> Raster D p r c a #stimes :: Integral b => b -> Raster D p r c a -> Raster D p r c a # (Monoid a, KnownNat r, KnownNat c) => Monoid (Raster D p r c a) Source # Instance detailsDefined in Geography.MapAlgebra Methodsmempty :: Raster D p r c a #mappend :: Raster D p r c a -> Raster D p r c a -> Raster D p r c a #mconcat :: [Raster D p r c a] -> Raster D p r c a # data Array D ix e Instance detailsDefined in Data.Massiv.Array.Delayed.Pull data Array D ix e = DArray {dComp :: !CompdSize :: !(Sz ix)dIndex :: ix -> e} type R D Instance detailsDefined in Data.Massiv.Array.Delayed.Pull type R D = D

data DW #

Delayed Windowed Array representation.

Constructors

 DW
Instances
 Index ix => Construct DW ix e Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed MethodssetComp :: Comp -> Array DW ix e -> Array DW ix e #makeArray :: Comp -> Sz ix -> (ix -> e) -> Array DW ix e #makeArrayLinear :: Comp -> Sz ix -> (Int -> e) -> Array DW ix e # Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed Associated Typestype R DW :: Type # MethodsgetComp :: Array DW Ix2T e -> Comp #size :: Array DW Ix2T e -> Sz Ix2T #loadArrayM :: Monad m => Scheduler m () -> Array DW Ix2T e -> (Int -> e -> m ()) -> m () #maxSize :: Array DW Ix2T e -> Maybe (Sz Ix2T)unsafeLoadIntoS :: (Mutable r' Ix2T e, PrimMonad m) => MArray (PrimState m) r' Ix2T e -> Array DW Ix2T e -> m (MArray (PrimState m) r' Ix2T e)unsafeLoadInto :: (Mutable r' Ix2T e, MonadIO m) => MArray RealWorld r' Ix2T e -> Array DW Ix2T e -> m (MArray RealWorld r' Ix2T e) Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed Associated Typestype R DW :: Type # MethodsgetComp :: Array DW Ix3T e -> Comp #size :: Array DW Ix3T e -> Sz Ix3T #loadArrayM :: Monad m => Scheduler m () -> Array DW Ix3T e -> (Int -> e -> m ()) -> m () #maxSize :: Array DW Ix3T e -> Maybe (Sz Ix3T)unsafeLoadIntoS :: (Mutable r' Ix3T e, PrimMonad m) => MArray (PrimState m) r' Ix3T e -> Array DW Ix3T e -> m (MArray (PrimState m) r' Ix3T e)unsafeLoadInto :: (Mutable r' Ix3T e, MonadIO m) => MArray RealWorld r' Ix3T e -> Array DW Ix3T e -> m (MArray RealWorld r' Ix3T e) Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed Associated Typestype R DW :: Type # MethodsgetComp :: Array DW Ix4T e -> Comp #size :: Array DW Ix4T e -> Sz Ix4T #loadArrayM :: Monad m => Scheduler m () -> Array DW Ix4T e -> (Int -> e -> m ()) -> m () #maxSize :: Array DW Ix4T e -> Maybe (Sz Ix4T)unsafeLoadIntoS :: (Mutable r' Ix4T e, PrimMonad m) => MArray (PrimState m) r' Ix4T e -> Array DW Ix4T e -> m (MArray (PrimState m) r' Ix4T e)unsafeLoadInto :: (Mutable r' Ix4T e, MonadIO m) => MArray RealWorld r' Ix4T e -> Array DW Ix4T e -> m (MArray RealWorld r' Ix4T e) Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed Associated Typestype R DW :: Type # MethodsgetComp :: Array DW Ix5T e -> Comp #size :: Array DW Ix5T e -> Sz Ix5T #loadArrayM :: Monad m => Scheduler m () -> Array DW Ix5T e -> (Int -> e -> m ()) -> m () #maxSize :: Array DW Ix5T e -> Maybe (Sz Ix5T)unsafeLoadIntoS :: (Mutable r' Ix5T e, PrimMonad m) => MArray (PrimState m) r' Ix5T e -> Array DW Ix5T e -> m (MArray (PrimState m) r' Ix5T e)unsafeLoadInto :: (Mutable r' Ix5T e, MonadIO m) => MArray RealWorld r' Ix5T e -> Array DW Ix5T e -> m (MArray RealWorld r' Ix5T e) Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed Associated Typestype R DW :: Type # MethodsgetComp :: Array DW Ix2 e -> Comp #size :: Array DW Ix2 e -> Sz Ix2 #loadArrayM :: Monad m => Scheduler m () -> Array DW Ix2 e -> (Int -> e -> m ()) -> m () #maxSize :: Array DW Ix2 e -> Maybe (Sz Ix2)unsafeLoadIntoS :: (Mutable r' Ix2 e, PrimMonad m) => MArray (PrimState m) r' Ix2 e -> Array DW Ix2 e -> m (MArray (PrimState m) r' Ix2 e)unsafeLoadInto :: (Mutable r' Ix2 e, MonadIO m) => MArray RealWorld r' Ix2 e -> Array DW Ix2 e -> m (MArray RealWorld r' Ix2 e) Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed Associated Typestype R DW :: Type # MethodsgetComp :: Array DW Ix1 e -> Comp #size :: Array DW Ix1 e -> Sz Ix1 #loadArrayM :: Monad m => Scheduler m () -> Array DW Ix1 e -> (Int -> e -> m ()) -> m () #maxSize :: Array DW Ix1 e -> Maybe (Sz Ix1)unsafeLoadIntoS :: (Mutable r' Ix1 e, PrimMonad m) => MArray (PrimState m) r' Ix1 e -> Array DW Ix1 e -> m (MArray (PrimState m) r' Ix1 e)unsafeLoadInto :: (Mutable r' Ix1 e, MonadIO m) => MArray RealWorld r' Ix1 e -> Array DW Ix1 e -> m (MArray RealWorld r' Ix1 e) Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed MethodsloadArrayWithStrideM :: Monad m => Scheduler m () -> Stride Ix2T -> Sz Ix2T -> Array DW Ix2T e -> (Int -> e -> m ()) -> m () # Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed MethodsloadArrayWithStrideM :: Monad m => Scheduler m () -> Stride Ix3T -> Sz Ix3T -> Array DW Ix3T e -> (Int -> e -> m ()) -> m () # Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed MethodsloadArrayWithStrideM :: Monad m => Scheduler m () -> Stride Ix4T -> Sz Ix4T -> Array DW Ix4T e -> (Int -> e -> m ()) -> m () # Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed MethodsloadArrayWithStrideM :: Monad m => Scheduler m () -> Stride Ix5T -> Sz Ix5T -> Array DW Ix5T e -> (Int -> e -> m ()) -> m () # Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed MethodsloadArrayWithStrideM :: Monad m => Scheduler m () -> Stride Ix2 -> Sz Ix2 -> Array DW Ix2 e -> (Int -> e -> m ()) -> m () # Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed MethodsloadArrayWithStrideM :: Monad m => Scheduler m () -> Stride Ix1 -> Sz Ix1 -> Array DW Ix1 e -> (Int -> e -> m ()) -> m () # (Index (IxN n), Load DW (Ix (n - 1)) e) => Load DW (IxN n) e Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed Associated Typestype R DW :: Type # MethodsgetComp :: Array DW (IxN n) e -> Comp #size :: Array DW (IxN n) e -> Sz (IxN n) #loadArrayM :: Monad m => Scheduler m () -> Array DW (IxN n) e -> (Int -> e -> m ()) -> m () #defaultElement :: Array DW (IxN n) e -> Maybe e #maxSize :: Array DW (IxN n) e -> Maybe (Sz (IxN n))unsafeLoadIntoS :: (Mutable r' (IxN n) e, PrimMonad m) => MArray (PrimState m) r' (IxN n) e -> Array DW (IxN n) e -> m (MArray (PrimState m) r' (IxN n) e)unsafeLoadInto :: (Mutable r' (IxN n) e, MonadIO m) => MArray RealWorld r' (IxN n) e -> Array DW (IxN n) e -> m (MArray RealWorld r' (IxN n) e) (Index (IxN n), StrideLoad DW (Ix (n - 1)) e) => StrideLoad DW (IxN n) e Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed MethodsloadArrayWithStrideM :: Monad m => Scheduler m () -> Stride (IxN n) -> Sz (IxN n) -> Array DW (IxN n) e -> (Int -> e -> m ()) -> m () # Functor (Array DW ix) Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed Methodsfmap :: (a -> b) -> Array DW ix a -> Array DW ix b #(<$) :: a -> Array DW ix b -> Array DW ix a # (Ragged L ix e, Load DW ix e, Show e) => Show (Array DW ix e) Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed MethodsshowsPrec :: Int -> Array DW ix e -> ShowS #show :: Array DW ix e -> String #showList :: [Array DW ix e] -> ShowS # Functor (Raster DW p r c) Source # Instance detailsDefined in Geography.MapAlgebra Methodsfmap :: (a -> b) -> Raster DW p r c a -> Raster DW p r c b #(<$) :: a -> Raster DW p r c b -> Raster DW p r c a # data Array DW ix e Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed data Array DW ix e = DWArray {dwArray :: !(Array D ix e)dwWindow :: !(Maybe (Window ix e))} type R DW Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed type R DW = DW type R DW Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed type R DW = DW type R DW Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed type R DW = DW type R DW Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed type R DW = DW type R DW Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed type R DW = DW type R DW Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed type R DW = DW type R DW Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed type R DW = DW

data S #

Representation for Storable elements

Constructors

 S
Instances

data P #

Representation for Primitive elements

Constructors

 P
Instances

data U #

Representation for Unboxed elements

Constructors

 U
Instances

data B #

Array representation for Boxed elements. This structure is element and spine strict, but elements are strict to Weak Head Normal Form (WHNF) only.

Constructors

 B
Instances

data N #

Array representation for Boxed elements. This structure is element and spine strict, and elements are always in Normal Form (NF), therefore NFData instance is required.

Constructors

 N
Instances

data Ix2 #

2-dimensional index. This is also a base index for higher dimensions.

Since: massiv-0.1.0

Constructors

 !Int :. !Int infixr 5

Bundled Patterns

 pattern Ix2 :: Int -> Int -> Ix2 2-dimensional index constructor. Useful when infix notation is inconvenient. (Ix2 i j) == (i :. j)Since: massiv-0.1.0
Instances
 Instance detailsDefined in Data.Massiv.Core.Index.Ix Methods Instance detailsDefined in Data.Massiv.Core.Index.Ix Methods(==) :: Ix2 -> Ix2 -> Bool #(/=) :: Ix2 -> Ix2 -> Bool # Instance detailsDefined in Data.Massiv.Core.Index.Ix Methods(+) :: Ix2 -> Ix2 -> Ix2 #(-) :: Ix2 -> Ix2 -> Ix2 #(*) :: Ix2 -> Ix2 -> Ix2 #negate :: Ix2 -> Ix2 #abs :: Ix2 -> Ix2 #signum :: Ix2 -> Ix2 # Instance detailsDefined in Data.Massiv.Core.Index.Ix Methodscompare :: Ix2 -> Ix2 -> Ordering #(<) :: Ix2 -> Ix2 -> Bool #(<=) :: Ix2 -> Ix2 -> Bool #(>) :: Ix2 -> Ix2 -> Bool #(>=) :: Ix2 -> Ix2 -> Bool #max :: Ix2 -> Ix2 -> Ix2 #min :: Ix2 -> Ix2 -> Ix2 # Instance detailsDefined in Data.Massiv.Core.Index.Ix MethodsshowsPrec :: Int -> Ix2 -> ShowS #show :: Ix2 -> String #showList :: [Ix2] -> ShowS # Instance detailsDefined in Data.Massiv.Core.Index.Ix Methodsrnf :: Ix2 -> () # Instance detailsDefined in Data.Massiv.Core.Index.Ix Associated Typestype Dimensions Ix2 :: Nat # Methodsdimensions :: proxy Ix2 -> Dim #consDim :: Int -> Lower Ix2 -> Ix2 #unconsDim :: Ix2 -> (Int, Lower Ix2) #snocDim :: Lower Ix2 -> Int -> Ix2 #unsnocDim :: Ix2 -> (Lower Ix2, Int) #pullOutDimM :: MonadThrow m => Ix2 -> Dim -> m (Int, Lower Ix2) #insertDimM :: MonadThrow m => Lower Ix2 -> Dim -> Int -> m Ix2 #getDimM :: MonadThrow m => Ix2 -> Dim -> m Int #setDimM :: MonadThrow m => Ix2 -> Dim -> Int -> m Ix2 #modifyDimM :: MonadThrow m => Ix2 -> Dim -> (Int -> Int) -> m (Int, Ix2) #pureIndex :: Int -> Ix2 #liftIndex2 :: (Int -> Int -> Int) -> Ix2 -> Ix2 -> Ix2 #liftIndex :: (Int -> Int) -> Ix2 -> Ix2 #foldlIndex :: (a -> Int -> a) -> a -> Ix2 -> a #isSafeIndex :: Sz Ix2 -> Ix2 -> Bool #toLinearIndexAcc :: Int -> Ix2 -> Ix2 -> Int #fromLinearIndexAcc :: Ix2 -> Int -> (Int, Ix2) #repairIndex :: Sz Ix2 -> Ix2 -> (Sz Int -> Int -> Int) -> (Sz Int -> Int -> Int) -> Ix2 #iterM :: Monad m => Ix2 -> Ix2 -> Ix2 -> (Int -> Int -> Bool) -> a -> (Ix2 -> a -> m a) -> m a #iterM_ :: Monad m => Ix2 -> Ix2 -> Ix2 -> (Int -> Int -> Bool) -> (Ix2 -> m a) -> m () # Unboxing of a Ix2. Instance detailsDefined in Data.Massiv.Core.Index.Ix Instance detailsDefined in Data.Massiv.Core.Index.Ix MethodsbasicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Ix2 -> m (Vector Ix2) #basicUnsafeThaw :: PrimMonad m => Vector Ix2 -> m (Mutable Vector (PrimState m) Ix2) #basicUnsafeIndexM :: Monad m => Vector Ix2 -> Int -> m Ix2 #basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Ix2 -> Vector Ix2 -> m () #elemseq :: Vector Ix2 -> Ix2 -> b -> b # Instance detailsDefined in Data.Massiv.Core.Index.Ix MethodsbasicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) Ix2) #basicInitialize :: PrimMonad m => MVector (PrimState m) Ix2 -> m () #basicUnsafeReplicate :: PrimMonad m => Int -> Ix2 -> m (MVector (PrimState m) Ix2) #basicUnsafeRead :: PrimMonad m => MVector (PrimState m) Ix2 -> Int -> m Ix2 #basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) Ix2 -> Int -> Ix2 -> m () #basicClear :: PrimMonad m => MVector (PrimState m) Ix2 -> m () #basicSet :: PrimMonad m => MVector (PrimState m) Ix2 -> Ix2 -> m () #basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) Ix2 -> MVector (PrimState m) Ix2 -> m () #basicUnsafeMove :: PrimMonad m => MVector (PrimState m) Ix2 -> MVector (PrimState m) Ix2 -> m () #basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) Ix2 -> Int -> m (MVector (PrimState m) Ix2) # Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed Associated Typestype R DW :: Type # MethodsgetComp :: Array DW Ix2 e -> Comp #size :: Array DW Ix2 e -> Sz Ix2 #loadArrayM :: Monad m => Scheduler m () -> Array DW Ix2 e -> (Int -> e -> m ()) -> m () #maxSize :: Array DW Ix2 e -> Maybe (Sz Ix2)unsafeLoadIntoS :: (Mutable r' Ix2 e, PrimMonad m) => MArray (PrimState m) r' Ix2 e -> Array DW Ix2 e -> m (MArray (PrimState m) r' Ix2 e)unsafeLoadInto :: (Mutable r' Ix2 e, MonadIO m) => MArray RealWorld r' Ix2 e -> Array DW Ix2 e -> m (MArray RealWorld r' Ix2 e) Instance detailsDefined in Data.Massiv.Array.Delayed.Windowed MethodsloadArrayWithStrideM :: Monad m => Scheduler m () -> Stride Ix2 -> Sz Ix2 -> Array DW Ix2 e -> (Int -> e -> m ()) -> m () # ColorSpace cs e => Readable PBM (Image S cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.Netpbm Methodsdecode :: PBM -> ReadOptions PBM -> ByteString -> Image S cs e # ColorSpace cs e => Readable PGM (Image S cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.Netpbm Methodsdecode :: PGM -> ReadOptions PGM -> ByteString -> Image S cs e # ColorSpace cs e => Readable PPM (Image S cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.Netpbm Methodsdecode :: PPM -> ReadOptions PPM -> ByteString -> Image S cs e # ColorSpace cs e => Readable BMP (Image S cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: BMP -> ReadOptions BMP -> ByteString -> Image S cs e # ColorSpace cs e => Readable PNG (Image S cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: PNG -> ReadOptions PNG -> ByteString -> Image S cs e # ColorSpace cs e => Readable GIF (Image S cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: GIF -> ReadOptions GIF -> ByteString -> Image S cs e # ColorSpace cs e => Readable HDR (Image S cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: HDR -> ReadOptions HDR -> ByteString -> Image S cs e # ColorSpace cs e => Readable JPG (Image S cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: JPG -> ReadOptions JPG -> ByteString -> Image S cs e # ColorSpace cs e => Readable TGA (Image S cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: TGA -> ReadOptions TGA -> ByteString -> Image S cs e # ColorSpace cs e => Readable TIF (Image S cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: TIF -> ReadOptions TIF -> ByteString -> Image S cs e # (ColorSpace cs e, Source r Ix2 (Pixel cs e)) => Writable BMP (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: BMP -> WriteOptions BMP -> Image r cs e -> ByteString # (ColorSpace cs e, Source r Ix2 (Pixel cs e)) => Writable PNG (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: PNG -> WriteOptions PNG -> Image r cs e -> ByteString # (ColorSpace cs e, Source r Ix2 (Pixel cs e)) => Writable GIF (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: GIF -> WriteOptions GIF -> Image r cs e -> ByteString # (ColorSpace cs e, Source r Ix2 (Pixel cs e)) => Writable HDR (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: HDR -> WriteOptions HDR -> Image r cs e -> ByteString # (ColorSpace cs e, Source r Ix2 (Pixel cs e)) => Writable JPG (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: JPG -> WriteOptions JPG -> Image r cs e -> ByteString # (ColorSpace cs e, Source r Ix2 (Pixel cs e)) => Writable TGA (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: TGA -> WriteOptions TGA -> Image r cs e -> ByteString # (ColorSpace cs e, Source r Ix2 (Pixel cs e)) => Writable TIF (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: TIF -> WriteOptions TIF -> Image r cs e -> ByteString # FileFormat (Encode (Image r cs e)) Instance detailsDefined in Data.Massiv.Array.IO.Image Associated Typestype ReadOptions (Encode (Image r cs e)) :: Type #type WriteOptions (Encode (Image r cs e)) :: Type # Methodsext :: Encode (Image r cs e) -> String #exts :: Encode (Image r cs e) -> [String] #isFormat :: String -> Encode (Image r cs e) -> Bool # FileFormat (Decode (Image r cs e)) Instance detailsDefined in Data.Massiv.Array.IO.Image Associated Typestype ReadOptions (Decode (Image r cs e)) :: Type #type WriteOptions (Decode (Image r cs e)) :: Type # Methodsext :: Decode (Image r cs e) -> String #exts :: Decode (Image r cs e) -> [String] #isFormat :: String -> Decode (Image r cs e) -> Bool # Readable (Decode (Image r cs e)) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image Methodsdecode :: Decode (Image r cs e) -> ReadOptions (Decode (Image r cs e)) -> ByteString -> Image r cs e # ColorSpace cs e => Readable (Sequence PBM) (Array B Ix1 (Image S cs e)) Instance detailsDefined in Data.Massiv.Array.IO.Image.Netpbm Methodsdecode :: Sequence PBM -> ReadOptions (Sequence PBM) -> ByteString -> Array B Ix1 (Image S cs e) # ColorSpace cs e => Readable (Sequence PGM) (Array B Ix1 (Image S cs e)) Instance detailsDefined in Data.Massiv.Array.IO.Image.Netpbm Methodsdecode :: Sequence PGM -> ReadOptions (Sequence PGM) -> ByteString -> Array B Ix1 (Image S cs e) # ColorSpace cs e => Readable (Sequence PPM) (Array B Ix1 (Image S cs e)) Instance detailsDefined in Data.Massiv.Array.IO.Image.Netpbm Methodsdecode :: Sequence PPM -> ReadOptions (Sequence PPM) -> ByteString -> Array B Ix1 (Image S cs e) # ColorSpace cs e => Readable (Sequence GIF) (Array B Ix1 (GifDelay, Image S cs e)) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methods ColorSpace cs e => Readable (Sequence GIF) (Array B Ix1 (Image S cs e)) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: Sequence GIF -> ReadOptions (Sequence GIF) -> ByteString -> Array B Ix1 (Image S cs e) # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Sequence (Auto PBM)) (Array B Ix1 (Image r cs e)) Instance detailsDefined in Data.Massiv.Array.IO.Image.Netpbm Methodsdecode :: Sequence (Auto PBM) -> ReadOptions (Sequence (Auto PBM)) -> ByteString -> Array B Ix1 (Image r cs e) # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Sequence (Auto PGM)) (Array B Ix1 (Image r cs e)) Instance detailsDefined in Data.Massiv.Array.IO.Image.Netpbm Methodsdecode :: Sequence (Auto PGM) -> ReadOptions (Sequence (Auto PGM)) -> ByteString -> Array B Ix1 (Image r cs e) # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Sequence (Auto PPM)) (Array B Ix1 (Image r cs e)) Instance detailsDefined in Data.Massiv.Array.IO.Image.Netpbm Methodsdecode :: Sequence (Auto PPM) -> ReadOptions (Sequence (Auto PPM)) -> ByteString -> Array B Ix1 (Image r cs e) # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Sequence (Auto GIF)) (Array B Ix1 (Image r cs e)) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: Sequence (Auto GIF) -> ReadOptions (Sequence (Auto GIF)) -> ByteString -> Array B Ix1 (Image r cs e) # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Auto PBM) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.Netpbm Methodsdecode :: Auto PBM -> ReadOptions (Auto PBM) -> ByteString -> Image r cs e # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Auto PGM) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.Netpbm Methodsdecode :: Auto PGM -> ReadOptions (Auto PGM) -> ByteString -> Image r cs e # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Auto PPM) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.Netpbm Methodsdecode :: Auto PPM -> ReadOptions (Auto PPM) -> ByteString -> Image r cs e # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Auto BMP) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: Auto BMP -> ReadOptions (Auto BMP) -> ByteString -> Image r cs e # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Auto PNG) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: Auto PNG -> ReadOptions (Auto PNG) -> ByteString -> Image r cs e # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Auto GIF) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: Auto GIF -> ReadOptions (Auto GIF) -> ByteString -> Image r cs e # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Auto HDR) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: Auto HDR -> ReadOptions (Auto HDR) -> ByteString -> Image r cs e # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Auto JPG) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: Auto JPG -> ReadOptions (Auto JPG) -> ByteString -> Image r cs e # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Auto TGA) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: Auto TGA -> ReadOptions (Auto TGA) -> ByteString -> Image r cs e # (Mutable r Ix2 (Pixel cs e), ColorSpace cs e) => Readable (Auto TIF) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsdecode :: Auto TIF -> ReadOptions (Auto TIF) -> ByteString -> Image r cs e # Writable (Encode (Image r cs e)) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image Methodsencode :: Encode (Image r cs e) -> WriteOptions (Encode (Image r cs e)) -> Image r cs e -> ByteString # (ColorSpace cs e, Source r Ix2 (Pixel cs e)) => Writable (Sequence GIF) (Array B Ix1 (GifDelay, Image r cs e)) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: Sequence GIF -> WriteOptions (Sequence GIF) -> Array B Ix1 (GifDelay, Image r cs e) -> ByteString # (ColorSpace cs e, ToRGBA cs e, Source r Ix2 (Pixel cs e)) => Writable (Auto BMP) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: Auto BMP -> WriteOptions (Auto BMP) -> Image r cs e -> ByteString # (ColorSpace cs e, ToYA cs e, ToRGBA cs e, Source r Ix2 (Pixel cs e)) => Writable (Auto PNG) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: Auto PNG -> WriteOptions (Auto PNG) -> Image r cs e -> ByteString # (ColorSpace cs e, ToY cs e, ToRGB cs e, Source r Ix2 (Pixel cs e)) => Writable (Auto GIF) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: Auto GIF -> WriteOptions (Auto GIF) -> Image r cs e -> ByteString # (ColorSpace cs e, ToRGB cs e, Source r Ix2 (Pixel cs e)) => Writable (Auto HDR) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: Auto HDR -> WriteOptions (Auto HDR) -> Image r cs e -> ByteString # (ColorSpace cs e, ToYCbCr cs e, Source r Ix2 (Pixel cs e)) => Writable (Auto JPG) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: Auto JPG -> WriteOptions (Auto JPG) -> Image r cs e -> ByteString # (ColorSpace cs e, ToRGBA cs e, Source r Ix2 (Pixel cs e)) => Writable (Auto TGA) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: Auto TGA -> WriteOptions (Auto TGA) -> Image r cs e -> ByteString # (ColorSpace cs e, ToRGBA cs e, Source r Ix2 (Pixel cs e)) => Writable (Auto TIF) (Image r cs e) Instance detailsDefined in Data.Massiv.Array.IO.Image.JuicyPixels Methodsencode :: Auto TIF -> WriteOptions (Auto TIF) -> Image r cs e -> ByteString # newtype Vector Ix2 Instance detailsDefined in Data.Massiv.Core.Index.Ix newtype Vector Ix2 = V_Ix2 (Vector (Int, Int)) type Lower Ix2 Instance detailsDefined in Data.Massiv.Core.Index.Ix type Lower Ix2 = Ix1 type Dimensions Ix2 Instance detailsDefined in Data.Massiv.Core.Index.Ix type Dimensions Ix2 = 2 newtype MVector s Ix2 Instance detailsDefined in Data.Massiv.Core.Index.Ix newtype MVector s Ix2 = MV_Ix2 (MVector s (Int, Int)) type WriteOptions (Encode (Image r cs e)) Instance deta