Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Efecto Airbnb
Efecto Airbnb Valencia
Commits
4de1242c
Commit
4de1242c
authored
Apr 05, 2019
by
Carlos Cámara
Browse files
Fixed last dataframe joins + minor cleanup.
parent
2739469e
Changes
1
Hide whitespace changes
Inline
Side-by-side
scraping/geocoding-viviendas-turisticas-comunitat-valenciana.R
View file @
4de1242c
...
...
@@ -25,8 +25,6 @@ df = read.csv("data/original/190302_viviendas-turisticas-comunidad-valenciana_va
separate
(
num
,
c
(
"num"
,
"puerta"
),
extra
=
"merge"
,
sep
=
", "
,
remove
=
FALSE
)
%>%
mutate
(
nombre_es_raw
=
as.factor
(
toupper
(
nombre_es_raw
)))
# Basic Record linkage.
record.linkage.names
=
function
(
names
,
officialnames
=
calles_valencia
$
nombre_es
)
{
...
...
@@ -43,15 +41,13 @@ record.linkage.names = function(names,
}
# df$nombre_es = record.linkage.names(df$nombre_es_raw)
df
=
df
%>%
mutate
(
nombre_es
=
record.linkage.names
(
nombre_es_raw
))
%>%
left_join
(
calles_valencia
)
# Geocoding with Photon ---------------------------------------------------
# Build a new dataframe with desired information.
df2
=
df
%>%
select
(
Signatura
,
Municipio
,
tipovia_ca
,
nomoficial
,
num
)
%>%
mutate
(
full_address_ca
=
paste
(
tipovia_ca
,
nomoficial
,
num
,
Municipio
,
...
...
@@ -64,8 +60,7 @@ geocoded.df = photon::geocode(head(df2$full_address_ca), limit = 1,
# Combine geocoded dataframe with original one.
df.combined
=
geocoded.df
%>%
select
(
location
,
lon
,
lat
)
%>%
right_join
(
df
,
by
=
c
(
"location"
=
"Address2"
))
df.combined
=
df2
%>%
left_join
(
geocoded.df
,
by
=
c
(
"full_address_ca"
=
"location"
))
write.csv
(
df.combined
,
file
=
"data/output/filename.csv"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment