aQ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~(c) Colin Woodbury, 2018BSD3"Colin Woodbury <colin@fosskers.ca>None,-/8:;<=FKQV-` A count of  values across some <.The main type for ~ and q, used to calculate Focal Drainage. This scheme for encoding drainage patterns is described on page 81 of GaCM.Full Explanation[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.7The scheme for encoding these permutations in a single  as described in GaCM is this:>Flow in a particular direction is represented by a power of 2: 0[ 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 [ is just as easy: check if the bit corresponding to the desired direction is flipped. The  function handles this.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.3A 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 ] SOne edge of a corner is touching an opponent, but the other edge touches a friend. *[ 1 1 ] or [ 0 1 ] [ 0 0 ] [ 0 1 ] !"A corner is surrounded by friends. D[ 0 0 ] or [ 0 0 ] or [ 1 0 ] [ 0 0 ] [ 0 1 ] [ 0 0 ] " Similar to {, except that the diagonal opponent doesn't match the other two. The corner is considered surrounded, but not "occupied". [ 1 2 ] [ 0 1 ] # Similar to F, except that the area of the focus surrounds the diagonal neighbour. [ 0 1 ] [ 0 0 ] $-A layout of the areal conditions of a single <j pixel. It describes whether each pixel corner is occupied by the same "areal zone" as the pixel centre.*7Directions that neighbourhood foci can be connected by.3=A description of lineal directions with the same encoding as . See r and s.6.An RGBA image whose colour bands are distinct.<?A rectangular grid of data representing some area on the earth.u: What is the underlying representation of this Raster? (see massiv)p: What B 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 ?The most commonly used B& for mapping in internet applications.@CLatitude (north-south position) and Longitude (east-west position).AA perfect geometric sphere. The earth isn't actually shaped this way, but it's a convenient middle-ground for converting between various Bs.B_The Earth is not a sphere. Various schemes have been invented throughout history that provide Es 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 At coordinates to some other approximation. The Projection used most commonly for mapping on the internet is called ?.BA Projection is also known as a Coordinate Reference System (CRS).Use I to convert Es between various Projections.Note:/ Full support for Projections is still pending.C Convert a E3 in this Projection to one of radians on a perfect A.D Convert a EA of radians on a perfect sphere to that of a specific Projection.E A location on the Earth in some B.I Reproject a E from one B to another.J\mathcal{O}(1) . Force a <'s representation to  E, allowing it to undergo various operations. All operations between   <*s are fused and allocate no extra memory.KEvaluate some lazy ( ,  , or ) < to some explicit = type (i.e. to a real memory-backed Array). Will follow the $utation strategy of the underlying massiv .Note: If using the 8 computation strategy, make sure you're compiling with -with-rtsopts=-N~ to automatically use all available CPU cores at runtime. Otherwise your "parallel" operations will only execute on one core.L Create a <1 of any size which has the same value everywhere.M\mathcal{O}(1) . Create a <; from a function of its row and column number respectively.N\mathcal{O}(1) . Create a < from the values of any T type. Will fail if the size of the Vector does not match the declared size of the <.ORead any image type into a <e of distinct colour bands with the cell type you declare. If the source image stores its values as  but you declare ,, the conversion will happen automatically.&Will fail if the declared size of the <4 does not match the actual size of the input image.PmRead a grayscale image. If the source file has more than one colour band, they'll be combined automatically.Q,An invisible pixel (alpha channel set to 0)._Construct a colour ramp. ramp :: Ord k => [(Word8, Word8, Word8)] -> [k] -> M.Map k PixelRGBA8RFrom page 32 of Cartographer's Toolkit.SFrom page 33 of Cartographer's Toolkit.TFrom page 34 of Cartographer's Toolkit.UFrom page 35 of Cartographer's Toolkit.VFrom page 36 of Cartographer's Toolkit.WFrom page 37 of Cartographer's Toolkit.XFrom page 38 of Cartographer's Toolkit.YFrom page 39 of Cartographer's Toolkit.ZFrom page 40 of Cartographer's Toolkit.[From page 41 of Cartographer's Toolkit.\ Convert a <F into grayscale pixels, suitable for easy output with functions like .]Render a PNG-encoded  from a coloured <. Useful for returning a < from a webserver endpoint.^Called LocalClassificationq in GaCM. The first argument is the value to give to any index whose value is less than the lowest break in the .This is a glorified - operation, but we expose it for convenience._2Finds the minimum value at each index between two <s.`2Finds the maximum value at each index between two <s.a%Averages the values per-index of all <s in a collection.b0The count of unique values at each shared index.c9The most frequently appearing value at each shared index.#Find the most common value in some .d:The least frequently appearing value at each shared index.$Find the least common value in some .eKA measure of how spread out a dataset is. This calculation will fail with  if a length 1 list is given.f Combine two <(s, element-wise, with a binary operator.gFocal Addition.hFocal Product.iAFocal Monoid - combine all elements of a neighbourhood via their z 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.j Focal Mean.kFocal Maximum.lFocal Minimum.mBFocal Variety - the number of unique values in each neighbourhood.nKFocal Majority - the most frequently appearing value in each neighbourhood.oLFocal Minority - the least frequently appearing value in each neighbourhood.p~Focal Percentage - the percentage of neighbourhood values that are equal to the neighbourhood focus. Not to be confused with q.qCFocal Percentile - the percentage of neighbourhood values that are less8 than the neighbourhood focus. Not to be confused with p.rFocal 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.sFocal 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.GImagining a 2x2 neighbourhood with its focus in the bottom-left, what 8 relationship does the focus have with the other pixels?PWhat is the total length of the areal edges (if there are any) at a given pixel?tXFocal Partition - the areal form of each location, only considering the top-right edge.uLike t, but considers the O of all corners. Is alluded to in GaCM but isn't given its own operation name.If preparing for v or w3, you almost certainly want this function and not t.vTFocal Frontage - the length of areal edges between each pixel and its neighbourhood.Usually, the output of u, is the appropriate input for this function.WThe area of a 1x1 square is 1. It has 8 right-triangular sections, each with area 1/8.wFocal 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 u, is the appropriate input for this function.xCFocal Volume - the surficial volume under each pixel, assuming the <# represents elevation in some way.*Direct access to the entire neighbourhood.HGet the surficial facets for each pixel and apply some function to them.ybThe first part to the "left pseudo inverse" needed to calculate a best-fitting plane of 9 points.zFocal 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.{\tau'. One full rotation of the unit circle.Given a list of zI values, find the slope of the best-fit plane that matches those points.See: +https://stackoverflow.com/a/16669463/643684Given a list of z# values, find a normal vector that  points down6 from a best-fit plane toward the cartographic plane.4A non-normalized, non-Z-corrected normal. Handy for |-, which needs to drop the Z and renormalize.%Replace the Z-coordinate of a Vector.|xFocal Aspect - the compass direction toward which the surface descends most rapidly. Results are in radians, with 0 or \tau being North, \tau / 4S being East, and so on. For areas that are essentially flat, their aspect will be .}Like |I, but slightly faster. Beware of nonsense results when the plane is flat.$Approximate Equality. Considers two $ to be equal if they are less than  /tau / 1024 apart.KGiven two normalized (length 1) vectors in R3, find the angle between them.~Focal Drainage - downstream portion. This indicates the one or more compass directions of steepest descent from each location. Appropriate as the input to .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 5 would only contain the directions of the diagonals.Focal Drainage - upstream portion. This indicates the one of more compass directions from which liquid would flow into each surface location. See also ~. Does a given  indicate flow in a certain *?All * s that a  indicates flow toward.The opposite of .Given a <% of byte data, efficiently produce a @ that describes value counts across the image. To be passed to .Given a A, produce a list of "colour breaks" as needed by functions like R. has a specialized \mathcal{O}(1) implementation.IWarning: This will evaluate (at most) the 10x10 top-left corner of your <5 for display. This should only be used for debugging.    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~<=>JK6789:;LMNOP\QRSTUVWXYZ[]BCDIA@?EFGHf^`_abcdeghijklnompq345rs$%&'() !"#tuvw*+,-./012xz|}~y{     !"#$%&'()*+,-./0123456789:;<=>BCDEFGH          !"##$%%&'()*+,--./0123456789:;;<==>?@ABBCDEFGHIJJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'mapalgebra-0.1.1-CrP1qOGCHANGvjixx6RpZnGeography.MapAlgebra%massiv-0.1.6.1-60QAmxD2KdJJZIo6l9Akzt&Data.Massiv.Array.Manifest.BoxedStrictB"Data.Massiv.Array.Manifest.BoxedNFN$Data.Massiv.Array.Manifest.PrimitiveP#Data.Massiv.Array.Manifest.StorableS"Data.Massiv.Array.Manifest.UnboxedU"Data.Massiv.Array.Delayed.WindowedDW"Data.Massiv.Array.Delayed.InternalDData.Massiv.Core.Index.Ix:.Ix2Data.Massiv.Core.ComputationParOnSeqComp(massiv-io-0.1.3.0-AZYi1mgjBQ28AYwvUuEZoqData.Massiv.Array.IO displayImagewriteImageAuto writeImageGraphics.ColorSpace.YYGraphics.ColorSpace.RGBRGBAGraphics.ColorSpace.InternalPixel Histogram _histogramDrain_drainSurroundCompleteOneSideOpen RightAngleOutFlowCorners_topLeft _bottomLeft _bottomRight _topRight DirectionEast NorthEastNorth NorthWestWest SouthWestSouth SouthEastLine_line RGBARaster_red_green_blue_alphaRaster_array WebMercatorLatLngSphere ProjectiontoSphere fromSpherePointxy reprojectlazystrictconstant fromFunction fromVectorfromRGBAfromGray invisiblegreenRedspectrum blueGreen purpleYellow brownBlue grayBrown greenPurple brownYellow purpleGreen purpleRed grayscalepngclassifylminlmaxlmeanlvariety lmajority lminority lvariancezipWithfsumfproductfmonoidfmeanfmaxfminfvariety fmajority fminority fpercentage fpercentileflinkageflength fpartitionfshape ffrontagefareafvolume leftPseudo fgradienttaufaspectfaspect' fdownstream fupstream direction directionsdrainage histogrambreaks$fProjectionTYPESphere$fFoldableRaster$fFractionalRaster $fNumRaster$fMonoidRaster$fSemigroupRaster$fApplicativeRaster$fFunctorRaster$fFunctorRaster0$fFunctorRaster1 $fEqRaster $fEqRaster0 $fEqRaster1 $fEqRaster2 $fEqRaster3 $fEqRaster4 $fShowRaster $fNFDataLine$fNFDataSurround$fNFDataCorners $fNFDataDrain $fEqPoint $fShowPoint$fEqLine $fOrdLine $fShowLine$fStorableLine $fPrimLine $fDefaultLine $fEqDirection$fOrdDirection$fEnumDirection$fShowDirection $fEqSurround $fOrdSurround$fShowSurround $fEqCorners $fShowCorners $fEqDrain $fOrdDrain $fShowDrain$fStorableDrain $fPrimDrain$fDefaultDrain $fEqHistogram$fShowHistogrambaseGHC.WordWord8%Data.Massiv.Array.Delayed.InterleavedDIData.Massiv.Core.CommonManifestArrayPar&vector-0.12.0.1-LflPw1fguMb6as60UrZpxNData.Vector.Generic.BaseVectorghc-prim GHC.TypesIntDoublerampbytestring-0.10.8.2Data.ByteString.Lazy.Internal ByteStringcontainers-0.5.10.2Data.Map.InternalMapGHC.Basefmapmajo Data.FoldableFoldableminoNothingMonoidsurroundfrontagearea neighbourhood facetStencilgradientnormalnormal'zcoord=~anglelengthGraphics.ColorSpace.HSIPixelHSI PixelHSIAGraphics.ColorSpace.CMYK PixelCMYK PixelCMYKAPixelRGB PixelRGBAGraphics.ColorSpace.XPixelXPixelYPixelYAGraphics.ColorSpace.YCbCr PixelYCbCr PixelYCbCrAgetX