-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathScript_David_Chris.fsx
More file actions
49 lines (39 loc) · 1.65 KB
/
Script_David_Chris.fsx
File metadata and controls
49 lines (39 loc) · 1.65 KB
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
#r "references/OpenTK.dll"
#r "references/OpenTK.GLControl.dll"
#r "references/FSharp.Data.dll"
#load "functional3d.fs"
#load "TryFsharpUtilities.fs"
open Functional3D
open TryFsharpUtilities
open System.Drawing
open FSharp.Data
open TryFs
type corrds = CsvProvider<"C:\\Users\\Chris\\Desktop\\postcode-outcodes.csv">
type population = CsvProvider<"C:\\Users\\Chris\\Desktop\\population.csv">
//let file = corrds.Load("C:\\Users\\Chris\\Desktop\\postcode-outcodes.csv")
let file = corrds.Load("http://www.freemaptools.com/download/outcode-postcodes/postcode-outcodes.csv")
let populationFile = population.Load("C:\\Users\\Chris\\Desktop\\population.csv")
// lat goes from 49 to 60
// long goes from -7.8 to 1.7
let colourFromPostCode postCode =
let population =
populationFile.Rows
|> Seq.filter (fun row -> row.``Postcode District`` = postCode)
|> Seq.sumBy (fun row -> row.``All usual residents``)
match population with
| 0 -> Color.Green
| p when p < 1000 -> Color.Orange
| p when p < 5000 -> Color.DarkOrange
| p when p < 10000 -> Color.Red
| p when p < 20000 -> Color.DarkRed
| _ -> Color.Blue
let latInRange lat =
0.-(lat - 53.0)
let lonInRange lon =
lon + 2.5
let toPlot = file.Rows
|> Seq.map (fun row -> (row.Outcode, float row.Latitude, float row.Longitude))
|> Seq.map (fun (postcode, lat,lon) -> (colourFromPostCode postcode, latInRange lat, lonInRange lon))
|> Seq.map (fun (colour, lat,lon) -> cube lon lat 1.0 1.0 colour )
|> Seq.toList
|> TryFs.showEm