Fsharp.Gdal


Plot Geometry

This section defines a Plot utility to give a graphical visualization of GDAL geometries in a Xaml Window Page using a Canvas as a Cartesian Plan where to put the coordinates of the geometries.

Drawing coordinates with svg patterns

Geometries in the Canvas are rendered as Paths whose Data property follows the Standard Vector Graphics pattern. A path consists of a sequence of path segments and each path segment consists of a sequence of commands where the first defines a new current position and the remainder define a line or curve from the current position to some new position which becomes the current position for the next part of the curve and so on. The form of the path element is as follows:

1: 
let stringPath = "M 0 0 L 100 100"

The example above defines a path that consists of establishing a current position at the origin (Move to 0,0) and the path goes from there to the point (100,100) as a straight Line.

We define specific functions for each shapes type (points, line, rings) that return their path data as svg strings.

Points will be rendered graphically as little squares whose dimension must be choosen in a way appropriate to give a sense of a puntual shape.

Fo this reason the pointPath function takes an (x,y) argument representing the point's coordinates
together with a scale argument. The function will return the svg reppresentation of a little square centered at the point's coordinates and sized at the given scale as to give a sense of a punctual shape. The square will have a side of 6 points in a Canvas of 400 x 400 points. and so the scale should be calculated dividing the actual bounding box by 400.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
/// Takes a `scale` argument and a tuple reppresenting a point' coordinates type and returns the svg 
/// reppresentation of a little square centered at the point's coordinates and sized 
/// at the given scale as to give a sense of a punctual shape. The square will have 
/// a side of 6 points in a Canvas of 400 x 400 points. The appropriate scale should 
/// be calculated dividing the actual bounding box by 400.
let pointPath scale (x,y) = 
//    let x,y = coordinates |> List.head 
    let x1 = x - (3. / scale)
    let y1 = y - (3. / scale)
    let x2 = x + (3. / scale)
    let y2 = y + (3. / scale)
    sprintf "M %f,%f %f,%f %f,%f %f,%f %f,%fz" x1 y1 x2 y1 x2 y2 x1 y2 x1 y1

The linePath function takes a list representing a line's coordinatesand returns its svg reppresentation.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
/// Takes and a list representing a line's coordinates and returns its svg reppresentation as a string.
let linePath coordinates = 
    coordinates
    |> List.fold 
        (fun acc (x,y) -> 
            if acc = "" then
                acc + (sprintf "M %f,%f" x y)
            else
                acc + (sprintf " L %f,%f" x y)
        ) ""

Rings are the base elements of an OGR Polygon. Actually they are just lines but they have to be drawn in a different way for the Xaml Engine to fill the space they enclose with a solid color.

The ringPath function takes a list representing a ring's coordinates and returns its svg reppresentation.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
/// Takes a list representing a ring's coordinates and returns its svg reppresentation as a string.
let ringPath coordinates = 
    coordinates
    |> List.fold 
        (fun acc (x,y) -> 
            if acc = "" then
                acc + (sprintf "M %f,%f" x y)
            else
                acc + (sprintf " %f,%f" x y)
        ) ""

Creating Canvas Paths from OGR.Geometries

OGR includes different geometry types that for our purpose can be rendered as the same shape type.

Below we define 3 classes of shapes (for points, lines and polygons) that actually we will draw on the canvas, plus a ShapeCollection type to treat each type of Geometry Collection or Multi-Geometry. For these two last we won't draw just a single shape but more shapes at the same time.

Then we define the toShape function that maps an OGR.Geometry to the appropiate shape.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
open OSGeo

/// Classes of shapes reppresenting OGR.Geometries.
type Shape = 
    | Point
    | Line
    | Polygon
    | ShapeCollection

/// Just an utility function to more easily get the OGR.Geometry type.
let geomType (geom:OGR.Geometry) = 
    geom.GetGeometryType()
    
/// Maps an OGR.Geometry to the appropriate shape if the mapping is known and 
/// fails in the other case.
let toShape geom = 
    let geomType = geom |> geomType
    match geomType with
    | OGR.wkbGeometryType.wkbPoint
    | OGR.wkbGeometryType.wkbPoint25D               -> Point

    | OGR.wkbGeometryType.wkbLineString
    | OGR.wkbGeometryType.wkbLineString25D          -> Line

    | OGR.wkbGeometryType.wkbPolygon
    | OGR.wkbGeometryType.wkbPolygon25D             -> Polygon

    | OGR.wkbGeometryType.wkbMultiPoint 
    | OGR.wkbGeometryType.wkbMultiPoint25D 
    | OGR.wkbGeometryType.wkbMultiLineString
    | OGR.wkbGeometryType.wkbMultiLineString25D
    | OGR.wkbGeometryType.wkbMultiPolygon
    | OGR.wkbGeometryType.wkbMultiPolygon25D    
    | OGR.wkbGeometryType.wkbGeometryCollection
    | OGR.wkbGeometryType.wkbGeometryCollection25D  -> ShapeCollection
    | _                                             -> failwith (sprintf "can't map geomType %A to a known shape" geomType)

Below we will define a global shapePath function that actually will return a path only for geometry types that can be classified as points, lines or polygons. For every other geometry types the function will fail.

First of all we need to extract the coordinates from the OGR.Geometries.

The coordinates function extracts a list of tuples made of the x (longitude if we are in a geographic space) and y (latitude) coordinates that constitute the geometry:

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
/// Extracts the geometry's coordinates as a list of tuples made of 
/// longitude and latitude.
let coordinates (geom:OGR.Geometry) = 
    let last = geom.GetPointCount() - 1
    [
        for i in 0..last ->
            let p = [|0.;0.|]
            geom.GetPoint(i,p)
            (p.[0], p.[1])
    ]

While we already have function to calculate the svg pattern for point and line geometries we have not defined a corresponding function for polygons but instead a function for rings.

An OGR Polygon is a complex structure made of one or more rings. In this case we need to traverse the geometry structure to find all its rings and then concatenates their svg reppresentation in a single string.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
/// Returns the appropriate path for geometry types that can be classified as 
/// points, lines or polygons. Fails for every other geometry types.
let shapePath scale geom = 
    let shape = geom |> toShape
    match shape with
    | Point     -> geom |> coordinates |> List.head |> pointPath scale
    | Line      -> geom |> coordinates|> linePath
    | Polygon   -> 
                   let count = geom.GetGeometryCount()
                   [for i in [0..(count-1)] -> 
                       (geom.GetGeometryRef(i)) |> coordinates |> ringPath
                   ]
                   |> List.fold (fun acc ringPath -> ringPath + " " + acc) ""
    | _         -> failwith (sprintf "can't draw a shape of geomType %A" geomType)

Frequently will be plotting more geometries in the same chart and to distinguish one from the others we will have to choose a different color.

Colors in Xaml are rendered by Brushes so we define a getRandomBrush function that will return each time a Brush with a new random color:

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
/// Returna a `Brush` with a new random color.
let getRandomBrush seed  = 
    let brushArray = 
        typeof<Brushes>.GetProperties() 
        |> Array.map (fun c -> c.Name)

    let randomGen = new Random(seed)
    let randomColorName = brushArray.[randomGen.Next(brushArray.Length)]
    let color = (new BrushConverter()).ConvertFromString(randomColorName) :?> SolidColorBrush
    let mutable newColor = new SolidColorBrush(color.Color)
    newColor.Opacity <- 0.8 // sometimes we will need some transparency
    newColor

Since now, the function defined above return paths as strings. The toPath function below returns the actual Xaml Path that we will add to the canvas for each OGR.Geometry that is simple i.e. is a point, a line or a polygon. Then we will define a more generic toPaths function that for every type of geometry (either simple or compound) will return a list of shapes to be drawn on the Canvas.

The scale argument is needed to re-scale the sapes based on the fraction of the current bounding box respect to the 400 x 400 points Canvas. To re-scale the shapes we use the RenderTransform property of the Path. (More on the RenderTransform property below.)

The seed argument is needed to feed the getRandomBrush function to have a real random color.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
37: 
38: 
39: 
40: 
/// Maps a simple OGR.Geometry to a Xaml Path.
let toPath scale seed (geom:OGR.Geometry) = 
    let shape = geom |> toShape
    let path = new Path()
    
    let data = geom |> shapePath scale
    path.Data <- Media.Geometry.Parse(data)

    let thickness = 1. / scale
    path.StrokeThickness <- thickness

    let renderTransform = sprintf "%.5f 0 0 %.5f 0 0" scale scale
    path.RenderTransform <- Transform.Parse(renderTransform)

    match shape with
    | Point
    | Polygon   -> path.Fill    <- seed |> getRandomBrush
    | Line      -> path.Stroke  <- seed |> getRandomBrush
    | _         -> ()

//    printfn "Path Properties:"
//    printfn "Data = %s" data |> ignore
//    printfn "StrokeThickness = %f" thickness |> ignore
//    printfn "RenderTransform = %s" renderTransform |> ignore
//    printfn ""

    path

/// Maps any OGR.Geometry (simple or compound) to a a Xaml Paths list.
let rec toPaths scale seed xs (geom:OGR.Geometry) = 
    let shape = geom |> toShape

    match shape with
    | ShapeCollection -> 
        let count = geom.GetGeometryCount()
        [for i in [0..(count-1)] -> 
                (geom.GetGeometryRef(i)) |> toPaths scale i xs
            ] |> List.concat
    | _ -> let path = geom |> toPath scale seed
           [path]@xs

Setting the Canvas space: OGR.Envelope and RenderTransform

We need to set the space of the cartesian plan represented by the Canvas at a size and at a position that makes the shape visibile.

First with env we extract the bounding box of the geometry as an OGR.Envelope

1: 
2: 
3: 
4: 
5: 
/// Extracs the bounding box of the geometry.
let toEnv (geom:OGR.Geometry) = 
    let res = new OGR.Envelope()
    geom.GetEnvelope(res)
    res

... then we resize it based on a choosen zoom as a percentage of the shape size. If the geometry is made of just a point it has not a real size so in this case we just calculate a margin based on the coordinate's magnitude.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
/// Resizes the envelope based on a choosen zoom.
let resize zoom (env:OGR.Envelope) = 
    let dx = env.MaxX - env.MinX
    let dy = env.MaxY - env.MinY
    let xMargin = if dx = 0. then 200. else ((dx / zoom) - dx) / 2.
    let yMargin = if dy = 0. then 200. else ((dy / zoom) - dy) / 2.
    env.MaxX <- env.MaxX + xMargin
    env.MaxY <- env.MaxY + yMargin
    env.MinX <- env.MinX - xMargin
    env.MinY <- env.MinY - yMargin
    env

RenderTranform can be used to scale, skew, rotate and translate a wpf control.

We will use the envelop information to calculate 1) the appropriate renderTransform both to scale the sapes in the canvas to render them bigger or smaller enough to be visibile; and 2) to translate the canvas at the shape positions

The pattern used by the property is:

1: 
let renderTransformString = "scaleX rotateAngle skewAngle scaleY translateX translateY"

Drawing a coordinates grid on X and Y Axis

Now before to define the final Plot class a little tricky thing.

I want to see on my canvas not only the geometries but also the scale at which they have been drawn. So I need to draw steps on the X and Y Axis with the associated coordinate number at the given scale.

The steps function writes the coordinate number on the steps:

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
/// Writes the coordinate number at the given x y coordinates.
let steps x y text color renderTransform (canvas:Canvas) = 
//    printfn "x = %f y = %f renderTransform = %s" x y renderTransform
    let textBlock = new TextBlock()
    textBlock.Text <- text
    textBlock.Foreground <- new SolidColorBrush(color)
    Canvas.SetLeft(textBlock, x)
    Canvas.SetTop(textBlock, y)
    textBlock.RenderTransform <- Transform.Parse(renderTransform)
    canvas.Children.Add(textBlock)

The blackPath function returns the Xaml Path for a black line at the given coordinates and will be used to draw both the x and y axis and also the single steps lines on them.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
/// Returns the Xaml Path for a black line at the given coordinates.
let blackPath scale coordinates = 
    let data = coordinates |> linePath
    let path = new Path()
    path.Data <- Media.Geometry.Parse(data)
    let thickness = 1. / scale
    path.StrokeThickness <- thickness
    let renderTransform = sprintf "%.5f 0 0 %.5f 0 0" scale scale
    path.RenderTransform <- Transform.Parse(renderTransform)
    path.Stroke  <- Brushes.Black
    path

Finally the axisXY draws on a give Canvas the X and Y axis, the steps on them and writes the numbers of their coordinates.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
let axisXY scale (env:OGR.Envelope) renderTransform (canvas:Canvas) = 
    let startX,startY = env.MinX, env.MinY
    let endX = startX + (400. / scale)
    let endY = startY + (400. / scale)

    // Draw X Axis 
    canvas.Children.Add([startX,startY;endX,startY] |> blackPath scale) |> ignore

    // Draw Y Axis 
    canvas.Children.Add([startX,startY;startX,endY] |> blackPath scale) |> ignore

    // Draw X Y Steps and write their coordinates number
    for i in [0.0..50.0..400.0] do
        
        // Draw X steps
        let startStepX = startX + (i / scale)
        let endStepY = startY + (10. / scale)
        canvas.Children.Add([startStepX,startY;startStepX,endStepY] |> blackPath scale) |> ignore

        // Draw Y steps
        let startStepY = startY + (i / scale)
        let endStepX = startX + (10. / scale)
        canvas.Children.Add([startX,startStepY;endStepX,startStepY] |> blackPath scale) |> ignore

        // Write X numbers
        let yOffset = if i % 100. = 0. then 0. else -15.
        let xCoord = startX + (i / scale)
        canvas |> steps i yOffset (sprintf "%.2f" xCoord) Colors.Black renderTransform |> ignore

        // Write Y numbers
        let xOffset = -70.
        let yCoord = startY + (i / scale)
        if i > 0.0 then
            canvas |> steps xOffset i (sprintf "%.2f" yCoord) Colors.Black renderTransform |> ignore

Saving a Canvas as an Image

Since I need to write this documentation and I don't want to take a print screen for each plot I made, I will define a save function to convert the canvas in a png immage and save it on my drive.

The saveAsBitmap function just do this for me:

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
/// Saves a canvas as a png image of a given width and height size to a given fileName
let saveAsBitmap width height fileName (canvas:Canvas) = 

    let size = new Size(width, height)
    canvas.Measure(size)
    let rtb = new RenderTargetBitmap(width |> int, height |> int, 96., 96., PixelFormats.Default)
    rtb.Render(canvas)

    let fileName = __SOURCE_DIRECTORY__ + sprintf "\output\img\%s.png" fileName

    let enc = new PngBitmapEncoder()
    let bitmapFrame = BitmapFrame.Create(rtb)
    enc.Frames.Add(bitmapFrame)

    use stm = File.Create(fileName)
    enc.Save(stm)

The Plot utility class

Armed with all the function defined above we can finally implement our Plot utility and to render it flexible enough to add future functionalities we define it as a plain F# Class:

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
37: 
38: 
39: 
40: 
41: 
42: 
43: 
44: 
45: 
46: 
47: 
48: 
49: 
50: 
51: 
52: 
53: 
/// Plots an OGR.Geometry on a Xaml Window
type Plot(geom:OGR.Geometry)  = 

    let env = geom |> toEnv |> resize 0.8
    let maxXYSide = max (env.MaxX - env.MinX) (env.MaxY - env.MinY)

//    do printfn "Geometry Properties:"
//    do printfn "Geometry Type: %A" (geom |> geomType)
//    do printfn "Envelope: MinX = %.2f, MaxX = %.2f, MinY = %.2f, MaxY = %.2f" env.MinX env.MinY env.MaxX env.MaxY
//    do printfn "Max Envelope XY size: %.2f" maxXYSide
//    do printfn ""

    let canvas = new Canvas()
    let canvasSize = 400.
    do canvas.Width <- canvasSize
    do canvas.Height <- canvasSize
    do canvas.RenderTransformOrigin <- new Point(0.5,0.5)
    
    let scale = canvasSize / maxXYSide

    let originX = env.MinX * scale * -1.
    let originY = env.MinY * scale
    let renderTransform = sprintf "1 0 0 -1 %.2f %.2f" originX originY
    
    do canvas.RenderTransform <- Transform.Parse(renderTransform)
    
//    do printfn "Canvas Properties:"
//    do printfn "Paths scale: (canvas size = %.2f / envelope size = %.2f) = %.5f" canvasSize maxXYSide scale
//    do printfn "RenderTransform = %s" renderTransform |> ignore
//    do printfn ""
    
    let paths = geom |> toPaths scale 0 []
    let addPaths = 
        for path in paths do 
            canvas.Children.Add(path) |> ignore
    do addPaths

    let renderTransformAxisXY = sprintf "1 0 0 -1 %.2f %.2f" -originX originY
    do canvas |> axisXY scale env renderTransformAxisXY

    let winWidth, winHeight = 600., 550.
    let win = new Window()
    do win.Width <- winWidth
    do win.Height <- winHeight
    do win.Content <- canvas
    do win.Topmost <- true

    do win.Title <- "F# Geometry Plot"

    do win.Show()

    member this.SaveAsBitmap(fileName) = 
        canvas |> saveAsBitmap winWidth winHeight fileName
namespace System
namespace System.IO
namespace System.Windows
namespace System.Windows.Media
namespace System.Windows.Media.Imaging
namespace System.Windows.Markup
namespace System.Windows.Shapes
namespace System.Windows.Controls
val stringPath : string

Full name: Plot-geometry.stringPath
val pointPath : scale:float -> x:float * y:float -> string

Full name: Plot-geometry.pointPath


 Takes a `scale` argument and a tuple reppresenting a point' coordinates type and returns the svg
 reppresentation of a little square centered at the point's coordinates and sized
 at the given scale as to give a sense of a punctual shape. The square will have
 a side of 6 points in a Canvas of 400 x 400 points. The appropriate scale should
 be calculated dividing the actual bounding box by 400.
val scale : float
val x : float
val y : float
val x1 : float
val y1 : float
val x2 : float
val y2 : float
val sprintf : format:Printf.StringFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.sprintf
val linePath : coordinates:(float * float) list -> string

Full name: Plot-geometry.linePath


 Takes and a list representing a line's coordinates and returns its svg reppresentation as a string.
val coordinates : (float * float) list
Multiple items
module List

from Microsoft.FSharp.Collections

--------------------
type List<'T> =
  | ( [] )
  | ( :: ) of Head: 'T * Tail: 'T list
  interface IEnumerable
  interface IEnumerable<'T>
  member GetSlice : startIndex:int option * endIndex:int option -> 'T list
  member Head : 'T
  member IsEmpty : bool
  member Item : index:int -> 'T with get
  member Length : int
  member Tail : 'T list
  static member Cons : head:'T * tail:'T list -> 'T list
  static member Empty : 'T list

Full name: Microsoft.FSharp.Collections.List<_>
val fold : folder:('State -> 'T -> 'State) -> state:'State -> list:'T list -> 'State

Full name: Microsoft.FSharp.Collections.List.fold
val acc : string
val ringPath : coordinates:(float * float) list -> string

Full name: Plot-geometry.ringPath


 Takes a list representing a ring's coordinates and returns its svg reppresentation as a string.
namespace OSGeo
type Shape =
  | Point
  | Line
  | Polygon
  | ShapeCollection

Full name: Plot-geometry.Shape


 Classes of shapes reppresenting OGR.Geometries.
Multiple items
union case Shape.Point: Shape

--------------------
type Point =
  struct
    new : x:float * y:float -> Point
    member Equals : o:obj -> bool + 1 overload
    member GetHashCode : unit -> int
    member Offset : offsetX:float * offsetY:float -> unit
    member ToString : unit -> string + 1 overload
    member X : float with get, set
    member Y : float with get, set
    static member Add : point:Point * vector:Vector -> Point
    static member Equals : point1:Point * point2:Point -> bool
    static member Multiply : point:Point * matrix:Matrix -> Point
    ...
  end

Full name: System.Windows.Point

--------------------
Point()
Point(x: float, y: float) : unit
Multiple items
union case Shape.Line: Shape

--------------------
type Line =
  inherit Shape
  new : unit -> Line
  member X1 : float with get, set
  member X2 : float with get, set
  member Y1 : float with get, set
  member Y2 : float with get, set
  static val X1Property : DependencyProperty
  static val Y1Property : DependencyProperty
  static val X2Property : DependencyProperty
  static val Y2Property : DependencyProperty

Full name: System.Windows.Shapes.Line

--------------------
Line() : unit
Multiple items
union case Shape.Polygon: Shape

--------------------
type Polygon =
  inherit Shape
  new : unit -> Polygon
  member FillRule : FillRule with get, set
  member Points : PointCollection with get, set
  static val PointsProperty : DependencyProperty
  static val FillRuleProperty : DependencyProperty

Full name: System.Windows.Shapes.Polygon

--------------------
Polygon() : unit
union case Shape.ShapeCollection: Shape
val geomType : geom:OGR.Geometry -> OGR.wkbGeometryType

Full name: Plot-geometry.geomType


 Just an utility function to more easily get the OGR.Geometry type.
val geom : OGR.Geometry
namespace OSGeo.OGR
Multiple items
type Geometry =
  new : type:wkbGeometryType -> Geometry + 2 overloads
  member AddGeometry : other:Geometry -> int
  member AddGeometryDirectly : other_disown:Geometry -> int
  member AddPoint : x:float * y:float * z:float -> unit
  member AddPoint_2D : x:float * y:float -> unit
  member Area : unit -> float
  member AssignSpatialReference : reference:SpatialReference -> unit
  member Boundary : unit -> Geometry
  member Buffer : distance:float * quadsecs:int -> Geometry
  member Centroid : unit -> Geometry
  ...

Full name: OSGeo.OGR.Geometry

--------------------
OGR.Geometry(type: OGR.wkbGeometryType) : unit
OGR.Geometry(cPtr: nativeint, cMemoryOwn: bool, parent: obj) : unit
OGR.Geometry(type: OGR.wkbGeometryType, wkt: string, wkb: int, wkb_buf: nativeint, gml: string) : unit
OGR.Geometry.GetGeometryType() : OGR.wkbGeometryType
val toShape : geom:OGR.Geometry -> Shape

Full name: Plot-geometry.toShape


 Maps an OGR.Geometry to the appropriate shape if the mapping is known and
 fails in the other case.
val geomType : OGR.wkbGeometryType
type wkbGeometryType =
  | wkbUnknown = 0
  | wkbPoint = 1
  | wkbLineString = 2
  | wkbPolygon = 3
  | wkbMultiPoint = 4
  | wkbMultiLineString = 5
  | wkbMultiPolygon = 6
  | wkbGeometryCollection = 7
  | wkbNone = 100
  | wkbLinearRing = 101
  ...

Full name: OSGeo.OGR.wkbGeometryType
field OGR.wkbGeometryType.wkbPoint = 1
field OGR.wkbGeometryType.wkbPoint25D = -2147483647
field OGR.wkbGeometryType.wkbLineString = 2
field OGR.wkbGeometryType.wkbLineString25D = -2147483646
field OGR.wkbGeometryType.wkbPolygon = 3
field OGR.wkbGeometryType.wkbPolygon25D = -2147483645
field OGR.wkbGeometryType.wkbMultiPoint = 4
field OGR.wkbGeometryType.wkbMultiPoint25D = -2147483644
field OGR.wkbGeometryType.wkbMultiLineString = 5
field OGR.wkbGeometryType.wkbMultiLineString25D = -2147483643
field OGR.wkbGeometryType.wkbMultiPolygon = 6
field OGR.wkbGeometryType.wkbMultiPolygon25D = -2147483642
field OGR.wkbGeometryType.wkbGeometryCollection = 7
field OGR.wkbGeometryType.wkbGeometryCollection25D = -2147483641
val failwith : message:string -> 'T

Full name: Microsoft.FSharp.Core.Operators.failwith
val coordinates : geom:OGR.Geometry -> (float * float) list

Full name: Plot-geometry.coordinates


 Extracts the geometry's coordinates as a list of tuples made of
 longitude and latitude.
val last : int
OGR.Geometry.GetPointCount() : int
val i : int
val p : float []
OGR.Geometry.GetPoint(iPoint: int, argout: float []) : unit
val shapePath : scale:float -> geom:OGR.Geometry -> string

Full name: Plot-geometry.shapePath


 Returns the appropriate path for geometry types that can be classified as
 points, lines or polygons. Fails for every other geometry types.
val shape : Shape
val head : list:'T list -> 'T

Full name: Microsoft.FSharp.Collections.List.head
val count : int
OGR.Geometry.GetGeometryCount() : int
OGR.Geometry.GetGeometryRef(geom: int) : OGR.Geometry
val ringPath : string
val getRandomBrush : seed:int -> SolidColorBrush

Full name: Plot-geometry.getRandomBrush


 Returna a `Brush` with a new random color.
val seed : int
val brushArray : string []
val typeof<'T> : Type

Full name: Microsoft.FSharp.Core.Operators.typeof
type Brushes =
  static member AliceBlue : SolidColorBrush
  static member AntiqueWhite : SolidColorBrush
  static member Aqua : SolidColorBrush
  static member Aquamarine : SolidColorBrush
  static member Azure : SolidColorBrush
  static member Beige : SolidColorBrush
  static member Bisque : SolidColorBrush
  static member Black : SolidColorBrush
  static member BlanchedAlmond : SolidColorBrush
  static member Blue : SolidColorBrush
  ...

Full name: System.Windows.Media.Brushes
type Array =
  member Clone : unit -> obj
  member CopyTo : array:Array * index:int -> unit + 1 overload
  member GetEnumerator : unit -> IEnumerator
  member GetLength : dimension:int -> int
  member GetLongLength : dimension:int -> int64
  member GetLowerBound : dimension:int -> int
  member GetUpperBound : dimension:int -> int
  member GetValue : [<ParamArray>] indices:int[] -> obj + 7 overloads
  member Initialize : unit -> unit
  member IsFixedSize : bool
  ...

Full name: System.Array
val map : mapping:('T -> 'U) -> array:'T [] -> 'U []

Full name: Microsoft.FSharp.Collections.Array.map
val c : Reflection.PropertyInfo
property Reflection.MemberInfo.Name: string
val randomGen : Random
Multiple items
type Random =
  new : unit -> Random + 1 overload
  member Next : unit -> int + 2 overloads
  member NextBytes : buffer:byte[] -> unit
  member NextDouble : unit -> float

Full name: System.Random

--------------------
Random() : unit
Random(Seed: int) : unit
val randomColorName : string
Random.Next() : int
Random.Next(maxValue: int) : int
Random.Next(minValue: int, maxValue: int) : int
property Array.Length: int
val color : SolidColorBrush
Multiple items
type BrushConverter =
  inherit TypeConverter
  new : unit -> BrushConverter
  member CanConvertFrom : context:ITypeDescriptorContext * sourceType:Type -> bool
  member CanConvertTo : context:ITypeDescriptorContext * destinationType:Type -> bool
  member ConvertFrom : context:ITypeDescriptorContext * culture:CultureInfo * value:obj -> obj
  member ConvertTo : context:ITypeDescriptorContext * culture:CultureInfo * value:obj * destinationType:Type -> obj

Full name: System.Windows.Media.BrushConverter

--------------------
BrushConverter() : unit
Multiple items
type SolidColorBrush =
  inherit Brush
  new : unit -> SolidColorBrush + 1 overload
  member Clone : unit -> SolidColorBrush
  member CloneCurrentValue : unit -> SolidColorBrush
  member Color : Color with get, set
  static val ColorProperty : DependencyProperty
  static member DeserializeFrom : reader:BinaryReader -> obj

Full name: System.Windows.Media.SolidColorBrush

--------------------
SolidColorBrush() : unit
SolidColorBrush(color: Color) : unit
val mutable newColor : SolidColorBrush
property SolidColorBrush.Color: Color
property Brush.Opacity: float
val toPath : scale:float -> seed:int -> geom:OGR.Geometry -> Path

Full name: Plot-geometry.toPath


 Maps a simple OGR.Geometry to a Xaml Path.
val path : Path
Multiple items
type Path =
  inherit Shape
  new : unit -> Path
  member Data : Geometry with get, set
  static val DataProperty : DependencyProperty

Full name: System.Windows.Shapes.Path

--------------------
Path() : unit
val data : string
property Path.Data: Geometry
Multiple items
namespace System.Windows.Media

--------------------
namespace System.Media
type Geometry =
  inherit Animatable
  member Bounds : Rect
  member Clone : unit -> Geometry
  member CloneCurrentValue : unit -> Geometry
  member FillContains : hitPoint:Point -> bool + 3 overloads
  member FillContainsWithDetail : geometry:Geometry -> IntersectionDetail + 1 overload
  member GetArea : unit -> float + 1 overload
  member GetFlattenedPathGeometry : unit -> PathGeometry + 1 overload
  member GetOutlinedPathGeometry : unit -> PathGeometry + 1 overload
  member GetRenderBounds : pen:Pen -> Rect + 1 overload
  member GetWidenedPathGeometry : pen:Pen -> PathGeometry + 1 overload
  ...

Full name: System.Windows.Media.Geometry
Geometry.Parse(source: string) : Geometry
val thickness : float
property Shape.StrokeThickness: float
val renderTransform : string
property UIElement.RenderTransform: Transform
type Transform =
  inherit GeneralTransform
  member Clone : unit -> Transform
  member CloneCurrentValue : unit -> Transform
  member Inverse : GeneralTransform
  member TransformBounds : rect:Rect -> Rect
  member TryTransform : inPoint:Point * result:Point -> bool
  member Value : Matrix
  static member Identity : Transform
  static member Parse : source:string -> Transform

Full name: System.Windows.Media.Transform
Transform.Parse(source: string) : Transform
property Shape.Fill: Brush
property Shape.Stroke: Brush
val toPaths : scale:float -> seed:int -> xs:Path list -> geom:OGR.Geometry -> Path list

Full name: Plot-geometry.toPaths


 Maps any OGR.Geometry (simple or compound) to a a Xaml Paths list.
val xs : Path list
val concat : lists:seq<'T list> -> 'T list

Full name: Microsoft.FSharp.Collections.List.concat
val toEnv : geom:OGR.Geometry -> OGR.Envelope

Full name: Plot-geometry.toEnv


 Extracs the bounding box of the geometry.
val res : OGR.Envelope
Multiple items
type Envelope =
  new : unit -> Envelope + 1 overload
  member Dispose : unit -> unit
  member MaxX : float with get, set
  member MaxY : float with get, set
  member MinX : float with get, set
  member MinY : float with get, set
  static member getCPtr : obj:Envelope -> HandleRef
  static member getCPtrAndDisown : obj:Envelope * parent:obj -> HandleRef
  static member getCPtrAndSetReference : obj:Envelope * parent:obj -> HandleRef

Full name: OSGeo.OGR.Envelope

--------------------
OGR.Envelope() : unit
OGR.Envelope(cPtr: nativeint, cMemoryOwn: bool, parent: obj) : unit
OGR.Geometry.GetEnvelope(env: OGR.Envelope) : unit
val resize : zoom:float -> env:OGR.Envelope -> OGR.Envelope

Full name: Plot-geometry.resize


 Resizes the envelope based on a choosen zoom.
val zoom : float
val env : OGR.Envelope
val dx : float
property OGR.Envelope.MaxX: float
property OGR.Envelope.MinX: float
val dy : float
property OGR.Envelope.MaxY: float
property OGR.Envelope.MinY: float
val xMargin : float
val yMargin : float
val renderTransformString : string

Full name: Plot-geometry.renderTransformString
val steps : x:float -> y:float -> text:string -> color:Color -> renderTransform:string -> canvas:Canvas -> int

Full name: Plot-geometry.steps


 Writes the coordinate number at the given x y coordinates.
val text : string
val color : Color
val canvas : Canvas
Multiple items
type Canvas =
  inherit Panel
  new : unit -> Canvas
  static val LeftProperty : DependencyProperty
  static val TopProperty : DependencyProperty
  static val RightProperty : DependencyProperty
  static val BottomProperty : DependencyProperty
  static member GetBottom : element:UIElement -> float
  static member GetLeft : element:UIElement -> float
  static member GetRight : element:UIElement -> float
  static member GetTop : element:UIElement -> float
  static member SetBottom : element:UIElement * length:float -> unit
  ...

Full name: System.Windows.Controls.Canvas

--------------------
Canvas() : unit
val textBlock : TextBlock
Multiple items
type TextBlock =
  inherit FrameworkElement
  new : unit -> TextBlock + 1 overload
  member Background : Brush with get, set
  member BaselineOffset : float with get, set
  member BreakAfter : LineBreakCondition
  member BreakBefore : LineBreakCondition
  member ContentEnd : TextPointer
  member ContentStart : TextPointer
  member FontFamily : FontFamily with get, set
  member FontSize : float with get, set
  member FontStretch : FontStretch with get, set
  ...

Full name: System.Windows.Controls.TextBlock

--------------------
TextBlock() : unit
TextBlock(inline: Documents.Inline) : unit
property TextBlock.Text: string
property TextBlock.Foreground: Brush
Canvas.SetLeft(element: UIElement, length: float) : unit
Canvas.SetTop(element: UIElement, length: float) : unit
property Panel.Children: UIElementCollection
UIElementCollection.Add(element: UIElement) : int
val blackPath : scale:float -> coordinates:(float * float) list -> Path

Full name: Plot-geometry.blackPath


 Returns the Xaml Path for a black line at the given coordinates.
property Brushes.Black: SolidColorBrush
val axisXY : scale:float -> env:OGR.Envelope -> renderTransform:string -> canvas:Canvas -> unit

Full name: Plot-geometry.axisXY
val startX : float
val startY : float
val endX : float
val endY : float
val ignore : value:'T -> unit

Full name: Microsoft.FSharp.Core.Operators.ignore
val i : float
val startStepX : float
val endStepY : float
val startStepY : float
val endStepX : float
val yOffset : float
val xCoord : float
type Colors =
  static member AliceBlue : Color
  static member AntiqueWhite : Color
  static member Aqua : Color
  static member Aquamarine : Color
  static member Azure : Color
  static member Beige : Color
  static member Bisque : Color
  static member Black : Color
  static member BlanchedAlmond : Color
  static member Blue : Color
  ...

Full name: System.Windows.Media.Colors
property Colors.Black: Color
val xOffset : float
val yCoord : float
val saveAsBitmap : width:float -> height:float -> fileName:string -> canvas:Canvas -> unit

Full name: Plot-geometry.saveAsBitmap


 Saves a canvas as a png image of a given width and height size to a given fileName
val width : float
val height : float
val fileName : string
val size : Size
Multiple items
type Size =
  struct
    new : width:float * height:float -> Size
    member Equals : o:obj -> bool + 1 overload
    member GetHashCode : unit -> int
    member Height : float with get, set
    member IsEmpty : bool
    member ToString : unit -> string + 1 overload
    member Width : float with get, set
    static member Empty : Size
    static member Equals : size1:Size * size2:Size -> bool
    static member Parse : source:string -> Size
  end

Full name: System.Windows.Size

--------------------
Size()
Size(width: float, height: float) : unit
UIElement.Measure(availableSize: Size) : unit
val rtb : RenderTargetBitmap
Multiple items
type RenderTargetBitmap =
  inherit BitmapSource
  new : pixelWidth:int * pixelHeight:int * dpiX:float * dpiY:float * pixelFormat:PixelFormat -> RenderTargetBitmap
  member Clear : unit -> unit
  member Render : visual:Visual -> unit

Full name: System.Windows.Media.Imaging.RenderTargetBitmap

--------------------
RenderTargetBitmap(pixelWidth: int, pixelHeight: int, dpiX: float, dpiY: float, pixelFormat: PixelFormat) : unit
Multiple items
val int : value:'T -> int (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.int

--------------------
type int = int32

Full name: Microsoft.FSharp.Core.int

--------------------
type int<'Measure> = int

Full name: Microsoft.FSharp.Core.int<_>
type PixelFormats =
  static member Bgr101010 : PixelFormat
  static member Bgr24 : PixelFormat
  static member Bgr32 : PixelFormat
  static member Bgr555 : PixelFormat
  static member Bgr565 : PixelFormat
  static member Bgra32 : PixelFormat
  static member BlackWhite : PixelFormat
  static member Cmyk32 : PixelFormat
  static member Default : PixelFormat
  static member Gray16 : PixelFormat
  ...

Full name: System.Windows.Media.PixelFormats
property PixelFormats.Default: PixelFormat
RenderTargetBitmap.Render(visual: Visual) : unit
val enc : PngBitmapEncoder
Multiple items
type PngBitmapEncoder =
  inherit BitmapEncoder
  new : unit -> PngBitmapEncoder
  member Interlace : PngInterlaceOption with get, set

Full name: System.Windows.Media.Imaging.PngBitmapEncoder

--------------------
PngBitmapEncoder() : unit
val bitmapFrame : BitmapFrame
type BitmapFrame =
  inherit BitmapSource
  member BaseUri : Uri with get, set
  member ColorContexts : ReadOnlyCollection<ColorContext>
  member CreateInPlaceBitmapMetadataWriter : unit -> InPlaceBitmapMetadataWriter
  member Decoder : BitmapDecoder
  member Thumbnail : BitmapSource
  static member Create : bitmapUri:Uri -> BitmapFrame + 8 overloads

Full name: System.Windows.Media.Imaging.BitmapFrame
BitmapFrame.Create(source: BitmapSource) : BitmapFrame
   (+0 other overloads)
BitmapFrame.Create(bitmapStream: Stream) : BitmapFrame
   (+0 other overloads)
BitmapFrame.Create(bitmapUri: Uri) : BitmapFrame
   (+0 other overloads)
BitmapFrame.Create(source: BitmapSource, thumbnail: BitmapSource) : BitmapFrame
   (+0 other overloads)
BitmapFrame.Create(bitmapUri: Uri, uriCachePolicy: Net.Cache.RequestCachePolicy) : BitmapFrame
   (+0 other overloads)
BitmapFrame.Create(bitmapStream: Stream, createOptions: BitmapCreateOptions, cacheOption: BitmapCacheOption) : BitmapFrame
   (+0 other overloads)
BitmapFrame.Create(bitmapUri: Uri, createOptions: BitmapCreateOptions, cacheOption: BitmapCacheOption) : BitmapFrame
   (+0 other overloads)
BitmapFrame.Create(source: BitmapSource, thumbnail: BitmapSource, metadata: BitmapMetadata, colorContexts: Collections.ObjectModel.ReadOnlyCollection<ColorContext>) : BitmapFrame
   (+0 other overloads)
BitmapFrame.Create(bitmapUri: Uri, createOptions: BitmapCreateOptions, cacheOption: BitmapCacheOption, uriCachePolicy: Net.Cache.RequestCachePolicy) : BitmapFrame
   (+0 other overloads)
BitmapSource.Create(pixelWidth: int, pixelHeight: int, dpiX: float, dpiY: float, pixelFormat: PixelFormat, palette: BitmapPalette, pixels: Array, stride: int) : BitmapSource
   (+0 other overloads)
property BitmapEncoder.Frames: Collections.Generic.IList<BitmapFrame>
Collections.Generic.ICollection.Add(item: BitmapFrame) : unit
val stm : FileStream
type File =
  static member AppendAllLines : path:string * contents:IEnumerable<string> -> unit + 1 overload
  static member AppendAllText : path:string * contents:string -> unit + 1 overload
  static member AppendText : path:string -> StreamWriter
  static member Copy : sourceFileName:string * destFileName:string -> unit + 1 overload
  static member Create : path:string -> FileStream + 3 overloads
  static member CreateText : path:string -> StreamWriter
  static member Decrypt : path:string -> unit
  static member Delete : path:string -> unit
  static member Encrypt : path:string -> unit
  static member Exists : path:string -> bool
  ...

Full name: System.IO.File
File.Create(path: string) : FileStream
File.Create(path: string, bufferSize: int) : FileStream
File.Create(path: string, bufferSize: int, options: FileOptions) : FileStream
File.Create(path: string, bufferSize: int, options: FileOptions, fileSecurity: Security.AccessControl.FileSecurity) : FileStream
BitmapEncoder.Save(stream: Stream) : unit
Multiple items
type Plot =
  new : geom:Geometry -> Plot
  member SaveAsBitmap : fileName:string -> unit

Full name: Plot-geometry.Plot


 Plots an OGR.Geometry on a Xaml Window


--------------------
new : geom:OGR.Geometry -> Plot
val maxXYSide : float
val max : e1:'T -> e2:'T -> 'T (requires comparison)

Full name: Microsoft.FSharp.Core.Operators.max
val canvasSize : float
property FrameworkElement.Width: float
property FrameworkElement.Height: float
property UIElement.RenderTransformOrigin: Point
val originX : float
val originY : float
val paths : Path list
val addPaths : unit
val renderTransformAxisXY : string
val winWidth : float
val winHeight : float
val win : Window
Multiple items
type Window =
  inherit ContentControl
  new : unit -> Window
  member Activate : unit -> bool
  member AllowsTransparency : bool with get, set
  member Close : unit -> unit
  member DialogResult : Nullable<bool> with get, set
  member DragMove : unit -> unit
  member Hide : unit -> unit
  member Icon : ImageSource with get, set
  member IsActive : bool
  member Left : float with get, set
  ...

Full name: System.Windows.Window

--------------------
Window() : unit
property ContentControl.Content: obj
property Window.Topmost: bool
property Window.Title: string
Window.Show() : unit
val this : Plot
member Plot.SaveAsBitmap : fileName:string -> unit

Full name: Plot-geometry.Plot.SaveAsBitmap
namespace Fsharp.Gdal
F# Project
Fork me on GitHub