-
Notifications
You must be signed in to change notification settings - Fork 0
/
geographic_map.R
28 lines (20 loc) · 1.02 KB
/
geographic_map.R
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
#geocoding
download.file(paste0('http://www.naturalearthdata.com/http//',
'www.naturalearthdata.com/download/110m/cultural/',
'ne_110m_admin_0_countries.zip'),
f <- tempfile())
unzip(f, exdir=tempdir())
library(rgdal)
countries <- readOGR(tempdir(), 'ne_110m_admin_0_countries')
pts <- data.frame(x=runif(10, -180, 180), y=runif(10, -90, 90),
VAR1=LETTERS[1:10])
existingGeocodedAddress <- readCsvFromDirectory('geocodedAddress', parameters$path_geocoded_address)
table(is.na(existingGeocodedAddress$longitude), useNA = 'ifany')
table(is.na(existingGeocodedAddress$latitude), useNA = 'ifany')
table(existingGeocodedAddress$location_type)
pts <- data.frame(existingGeocodedAddress[, .(x = as.double(longitude), y = as.double(latitude))])
coordinates(pts) <- ~x+y # pts needs to be a data.frame for this to work
proj4string(pts) <- proj4string(countries)
plot(countries)
points(pts, pch=20, col='red')
existingGeocodedAddress[, .(x = longitude, y = latitude)]