getCodePoint: Compile/convert unzipped OS Code-Point(R) Open data into a...

Description Usage Arguments Value Note Author(s) Examples

View source: R/codepoint.R

Description

Compile/convert unzipped OS Code-Point(R) Open data into a form that I want.

Assumes you have downloaded and unzipped ‘codepo_gb.zip’ to ‘path’.

Alternatively, saves the output as an .rds file for subsequent re-loading.

Usage

1
2
3
4
5
6
7
8
9
getCodePoint( path, 
              doc.folder = paste(path, "Doc", sep = "/"), 
              csv.folder = paste(path, "Data/CSV", sep = "/"), 
              headers.we.want = c("Admin_county_code", "Admin_district_code"), 
              index.of.header.to.join = 2, 
              rds.output.folder = path,
              get.RDS.instead = FALSE )
              
getCodePointRDS( path, ... )

Arguments

path

the path where the unzipped codepoint files are

doc.folder

the path of the ‘Doc’ sub-folder

csv.folder

the path of the ‘CSV’ sub-folder

headers.we.want

a list of the headers to keep (apart from the mandatory headers, the rest are discarded).

Available headers are Positional_quality_indicator, Country_code, NHS_regional_HA_code, NHS_HA_code, Admin_county_code, Admin_district_code, Admin_ward_code.

Mandatory headers are Postcode, Eastings, Northings and do not need to be specified.

index.of.header.to.join

which header (in headers.we.want) to join with the names/types of the areas

rds.output.folder

where save the output as an .rds file, for faster re-loading in the future. This identifies the version from ‘metadata.txt’ and names the .rds file accordingly.

get.RDS.instead

return the full path of the RDS file that is saved instead of returning the data frame

Value

Depending on get.RDS.instead

TRUE

Returns a data frame consisting of the Code-Point csv files (all appended to each other), joined to the information in ‘Codelist.xls’ (which is the names related to the codes)

FALSE

Saves the data frame to a .rds file and returns the full path of that file.

getCodePointRDS is a wrapper function for getCodePoint that specifies get.RDS.instead = TRUE.

Note

This takes about 15 - 20 seconds on my computer. Please be patient.

Author(s)

Wei Liang Yap

Examples

1
2
3
4
5
6
# do it
CodePoint <- getCodePoint( "H:/DATASETS/OS/CodePoint/tmp" )

# re-load the saved .rds file
filename <- getCodePointRDS( "H:/DATASETS/OS/CodePoint/tmp",rds.output.folder="H:/DATASETS/OS/CodePoint" )
CodePoint2 <- readRDS(filename)

yapweiliang/codepoint documentation built on May 4, 2019, 2:30 p.m.