wrking on os data

This commit is contained in:
Jeremy Kidwell 2018-08-29 15:32:18 +01:00
parent 0c0ec94b4b
commit 289950e88f
2 changed files with 64 additions and 6 deletions

View File

@ -1,14 +1,14 @@
# Presentation to Energy@Cambridge Good Energy Project
## 2018 Jan 30
# Presentation to the British Association for the Study of Religion
## 2018 Sep 04
This presentation uses [remark.js](https://github.com/gnab/remark).
This presentation was built using [remark.js](https://github.com/gnab/remark)
Examples of other presentations by me which have been built using other js-based platforms, includes [reveal.js](https://github.com/kidwellj/presentation-20170913-employability) and [impress.js](https://github.com/kidwellj/presentation-20170120-comm_anchors).
A live version of these slides can be viewed via my website at [https://jeremykidwell.info/files/presentations/presentation_20180130_cambridge_energy.html]
In the `atenergy_data` folder:
In the `data` folder:
* `laudatosi_awareness.png` - a cropped version of an image (`GWGraph4.jpg` is the original) from “[Speaking Out on Global Warming: Public Attitudes toward the Papal Encyclical on Climate Change](http://www.apnorc.org/projects/Pages/speaking-out-on-global-warming-public-attitudes-toward-the-papal-encyclical-on-climate-change.aspx)”. Copyright by Associated Press-NORC Centre for Public Affairs Research.
* `laudatosi_views.png` - a cropped version of an image (`GWGraph3.jpg` is the original) from “[Speaking Out on Global Warming: Public Attitudes toward the Papal Encyclical on Climate Change](http://www.apnorc.org/projects/Pages/speaking-out-on-global-warming-public-attitudes-toward-the-papal-encyclical-on-climate-change.aspx)”. Copyright by Associated Press-NORC Centre for Public Affairs Research.
* `ppri.png` a cropped version of an image from Daniel Cox, Juhem Navarro-Rivera, Robert P. Jones, “[Believers, Sympathizers, & Skeptics: Why Americans are Conflicted About Climate Change, Environmental Policy, and Science](http://publicreligion.org/research/2014/11/believers-sympathizers-skeptics-americans-conflicted-climate-change-environmental-policy-science)” by PPRI/AAR. 21 Nov 2014. Copyright Public Religion Research Institute (PRRI)
Any other files are copyright by me, Jeremy Kidwell. But please re-use them as they are covered by [Creative Commons Attribution 4.0 International Licence (CC BY 4.0)](http://creativecommons.org/licenses/by/4.0).

58
ordnance_survey_parse.R Normal file
View File

@ -0,0 +1,58 @@
require(sqldf) # using sqldf to filter while loading very large data sets
require(data.table)
require(sf) # new simplefeature data class, supercedes sp in many ways
require(osmdata) # for loading data from OSM, supercedes "overpass" package and "osmar"
setwd("/Users/kidwellj/gits/presentation-20180904-basr")
# Import filtered CSV, selecting only data
# Note: OS recently changed column names to remove underscores, dropping header simplifies this issue
pointx_201512 <- read.csv.sql("/Volumes/imac-storage1/GIS_data/Ordnance_Survey/PointX_Complete_2015_12/poi_2015_12_all06340459.csv", sql = "select * from file where V3 = '06340459'", header = FALSE, sep="|")
pointx_201806 <- read.csv.sql("/Volumes/imac-storage1/GIS_data/Ordnance_Survey/PointX_Complete_2018_06/poi.csv", sql = "select * from file where V3 = '06340459'", header = FALSE, sep="|")
# pointx_201409 <- read.csv.sql("/Volumes/imac-storage1/GIS_data/Ordnance_Survey/PointX_Complete_2014_09/Data/pointx_v2_National_Coverage_Sept14.txt", sql = "select * from file where V3 = '06340459'", header = FALSE, sep="|")
# pointx_201609 <- read.csv.sql("/Volumes/imac-storage1/GIS_data/Ordnance_Survey/PointX_Complete_2016_09/csv/pointx_v2_National_Coverage_Sept16.txt", sql = "select * from file where V3 = '06340459'", header = FALSE, sep="|")
# Filter out the distorting uncategorised category
plot(sort(table(pointx_201806$V26[pointx_201806$V26 !='"Not Identified (Christian)"'])))
# Calculate a descending sorted list of points by each denomination for 2015, and filter out distorting "not identified" category
denominationcounts_201512 <- (sort(table(pointx_201512$V26[pointx_201512$V26 !='Not Identified (Christian)']), decreasing = TRUE))
par(las=2) # make label text perpendicular to axis
par(mar=c(12,8,4,2)) # increase y-axis margin.
par(cex.axis=0.7)
par(cex.lab=1)
# Subset top 10 for plot
plot(denominationcounts_201512[1:15])
# Calculate a descending sorted list of points by each denomination for 2018, and filter out distorting "not identified" category
denominationcounts_201806 <- (sort(table(pointx_201806$V26[pointx_201806$V26 !='"Not Identified (Christian)"']), decreasing = TRUE))
par(las=2) # make label text perpendicular to axis
par(mar=c(12,8,4,2)) # increase y-axis margin.
par(cex.axis=0.7)
par(cex.lab=1)
# Subset top 10 for plot
plot(denominationcounts_201806[1:15])
denominationcounts_201806
# Get UK Admin polygons
if (dir.exists("data") == FALSE) {
dir.create("data")}
download.file("https://borders.ukdataservice.ac.uk/ukborders/easy_download/prebuilt/shape/infuse_dist_lyr_2011_clipped.zip", destfile = "infuse_dist_lyr_2011_clipped.zip")
unzip("infuse_dist_lyr_2011_clipped.zip", exdir = "data")
admin_uk <- st_read(infuse_dist_lyr_2011_clipped)
fname <- system.file("data/infuse_dist_lyr_2011_clipped.shp", package="sf")
admin_uk <- st_read(fname)
# Make maps
# Define CRS for British National Grid
BNG = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894"
xy <- pointx_201806[,c(4,5)]
pointx_201806_map <- SpatialPointsDataFrame(coords = xy, data = pointx_201806,
CRS("+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894"))
churches_ordnancesurvey_2018 <- st_read(pointx_201806)
sf("OS_pointX_2016_09-POW-UK_all-simplified.csv")
coordinates(churches_ordnancesurvey) <- c("FEATURE_EASTING", "FEATURE_NORTHING")
proj4string(churches_ordnancesurvey) <- proj4string(admin_uk) # borrow BNG CRS from admin boundaries shapefile