Commit 52da3f93 authored by Carlos Cámara's avatar Carlos Cámara

Add geocoding script using Photon. (WIP)

parent adc00b0b
# Geocoding with Photon ---------------------------------------------------
# require(devtools)
# devtools::install_github(repo = 'rCarto/photon')
library(photon)
library(dplyr)
df = read.csv("https://code.montera34.com/airbnb/valencia/raw/master/data/original/190302_viviendas-turisticas-comunidad-valenciana_valencia.csv") %>%
mutate(Address = gsub("C ", "calle de ", Address)) %>%
mutate(Address2 = paste(Address, Municipio, sep = ", "))
geocoded.df = photon::geocode(head(df$Addresses2), limit = 1,
# lang = "es",
key = "highway",
locbias = c(-0.3766, 39.4665))
# Combine geocoded dataframe with original one.
df.combined = geocoded.df %>%
select(location, lon, lat) %>%
right_join(df, by = c("location" = "Address2"))
write.csv(df.combined, file = "../data/output/filename.csv")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment