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
4f0d916f
Commit
4f0d916f
authored
Apr 05, 2019
by
Carlos Cámara
Browse files
Geocoding improvements.
parent
905f17e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
scraping/geocoding-viviendas-turisticas-comunitat-valenciana.R
View file @
4f0d916f
...
...
@@ -10,13 +10,27 @@ library(tidyverse)
# Load Valencia's official street names from:
# http://gobiernoabierto.valencia.es/va/dataset/?id=listado-de-calles
calles_valencia
=
read.csv
(
"data/original/vias-valencia.csv"
)
%>%
mutate
(
codtipovia
=
sub
(
"C/"
,
"C"
,
codtipovia
))
%>%
mutate
(
tipovia_es
=
codtipovia
)
%>%
mutate
(
tipovia_es
=
sub
(
"PG"
,
"PA"
,
tipovia_es
))
%>%
mutate
(
tipovia_es
=
sub
(
"AV"
,
"Avenida"
,
tipovia_es
))
%>%
mutate
(
tipovia_es
=
sub
(
"C/"
,
"Calle"
,
tipovia_es
))
%>%
mutate
(
tipovia_es
=
sub
(
"PG"
,
"Paseo"
,
tipovia_es
))
%>%
mutate
(
tipovia_ca
=
sub
(
"PL"
,
"Plaza"
,
tipovia_ca
))
%>%
mutate
(
tipovia_ca
=
sub
(
"PTGE"
,
"Pasaje"
,
tipovia_ca
))
%>%
mutate
(
tipovia_ca
=
codtipovia
)
%>%
mutate
(
tipovia_ca
=
sub
(
"C/"
,
"Carrer de"
,
tipovia_ca
))
%>%
mutate
(
nombre_es
=
paste
(
tipovia_es
,
traducnooficial
,
sep
=
" "
))
%>%
mutate
(
nombre_es
=
as.factor
(
nombre_es
))
mutate
(
tipovia_ca
=
sub
(
"AV"
,
"Avinguda"
,
tipovia_ca
))
%>%
mutate
(
tipovia_ca
=
sub
(
"C/"
,
"Carrer"
,
tipovia_ca
))
%>%
mutate
(
tipovia_ca
=
sub
(
"PG"
,
"Passeig"
,
tipovia_ca
))
%>%
mutate
(
tipovia_ca
=
sub
(
"PL"
,
"Plaça"
,
tipovia_ca
))
%>%
mutate
(
tipovia_ca
=
sub
(
"PTGE"
,
"Passatge"
,
tipovia_ca
))
%>%
mutate
(
codtipovia
=
sub
(
"C/"
,
"C"
,
codtipovia
))
%>%
mutate
(
codtipovia
=
sub
(
"CAMI"
,
"CM"
,
codtipovia
))
%>%
mutate
(
codtipovia
=
sub
(
"PG"
,
"PA"
,
codtipovia
))
%>%
mutate
(
nombre_es
=
paste
(
codtipovia
,
traducnooficial
,
sep
=
" "
))
%>%
mutate
(
nombre_es
=
as.factor
(
toupper
(
nombre_es
)))
%>%
mutate
(
nombre_es_full
=
paste
(
tipovia_es
,
traducnooficial
,
sep
=
" "
))
%>%
mutate
(
nombre_es_full
=
as.factor
(
toupper
(
nombre_es_full
)))
%>%
mutate
(
nombre_ca_full
=
paste
(
tipovia_ca
,
nomoficial
,
sep
=
" "
))
%>%
mutate
(
nombre_ca_full
=
as.factor
(
toupper
(
nombre_ca_full
)))
# Load dataset and manipulate addresses.
df
=
read.csv
(
"data/original/190302_viviendas-turisticas-comunidad-valenciana_valencia.csv"
)
%>%
...
...
@@ -42,8 +56,20 @@ record.linkage.names = function(names,
df
=
df
%>%
mutate
(
nombre_es_raw
=
gsub
(
"C LA REINA"
,
"C REINA"
,
nombre_es_raw
))
%>%
mutate
(
nombre_es_raw
=
gsub
(
"C DE LA REINA"
,
"C REINA"
,
nombre_es_raw
))
%>%
mutate
(
nombre_es_raw
=
gsub
(
"DR. WAKSMAN"
,
"DOCTOR WAKSMAN"
,
nombre_es_raw
))
%>%
mutate
(
nombre_es_raw
=
gsub
(
"DR MONSERRAT"
,
"MONSERRAT"
,
nombre_es_raw
))
%>%
mutate
(
nombre_es_raw
=
gsub
(
"GOS-GUSS"
,
"GOS GUSS"
,
nombre_es_raw
))
%>%
mutate
(
nombre_es_raw
=
gsub
(
"L'ALGUER"
,
"ALGUER"
,
nombre_es_raw
))
%>%
mutate
(
nombre_es_raw
=
gsub
(
"HIGINIO NOJA PROFESOR"
,
"HIGINIO NOJA (PROFESOR)"
,
nombre_es_raw
))
%>%
mutate
(
nombre_es_raw
=
gsub
(
"C MARIANO BENLLIURE"
,
"PL MARIANO BENLLIURE"
,
nombre_es_raw
))
%>%
mutate
(
nombre_es_raw
=
gsub
(
"LA SAFOR"
,
"SAFOR"
,
nombre_es_raw
))
%>%
mutate
(
nombre_es_raw
=
gsub
(
"DELS XIPRERS"
,
"XIPRERS"
,
nombre_es_raw
))
%>%
mutate
(
nombre_es_raw
=
gsub
(
"DR. J.J. DOMINE"
,
"DOCTOR J.J. DOMINE"
,
nombre_es_raw
))
%>%
mutate
(
nombre_es_raw
=
gsub
(
"FERNANDO ABRIL MARTO"
,
"FERNANDO ABRIL MARTORELL"
,
nombre_es_raw
))
%>%
mutate
(
nombre_es
=
record.linkage.names
(
nombre_es_raw
))
%>%
left_join
(
calles_valencia
)
left_join
(
calles_valencia
,
by
=
c
(
"nombre_es"
=
"nombre_es"
)
)
# Geocoding with Photon ---------------------------------------------------
...
...
@@ -51,9 +77,10 @@ df = df %>%
df2
=
df
%>%
select
(
Signatura
,
Municipio
,
tipovia_ca
,
nomoficial
,
num
)
%>%
mutate
(
full_address_ca
=
paste
(
tipovia_ca
,
nomoficial
,
num
,
Municipio
,
sep
=
", "
))
sep
=
" "
))
%>%
filter
(
!
is.na
(
nomoficial
))
geocoded.df
=
photon
::
geocode
(
head
(
df2
$
full_address_ca
)
,
limit
=
1
,
geocoded.df
=
photon
::
geocode
(
df2
$
full_address_ca
,
limit
=
1
,
# lang = "es",
key
=
"highway"
,
locbias
=
c
(
-0.3766
,
39.4665
))
...
...
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