setwd("~/sdal/PRJ_201505_CENSUS/analysis/aschroed")
source(file="pg_connect.R")
library("ggmap")
gc <- geocode("1220 S Villge Way, Blackburg, VA", output = c("more"), source = c("google"))
print(paste(gc$address, "lat =", gc$lat, "lon =", gc$lon))
View(gc)
geosleep <- function(){
geocode(output = 'more', source = 'google')
Sys.sleep(0.3)
}
listingAddresses <- dbGetQuery(con, "SELECT list_number, st_number, st_direction,
street_name, street_suffix, city, state, zip_code
FROM housing.w_mls_location_data limit 5")
listingAddresses$geo <- lapply(paste(listingAddresses$st_number, listingAddresses$st_direction,
listingAddresses$street_name, listingAddresses$street_suffix,
listingAddresses$city, listingAddresses$state, listingAddresses$zip_code,
sep=" "), geocode, output = 'more', source = 'google')
geocode_sleep <- function(location, output = c("more"), source = c("google"), sleep_time = 0.3) {
# regular geocode function call
ret <- geocode(location, output, source)
# sleep!
Sys.sleep(sleep_time)
ret
}
listingAddresses$geo <- lapply(paste(listingAddresses$st_number, listingAddresses$st_direction,
listingAddresses$street_name, listingAddresses$street_suffix,
listingAddresses$city, listingAddresses$state, listingAddresses$zip_code,
sep=" "), geocode_sleep)
print(listingAddresses$geo)[aschroed@snowmane aschroed]$