-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdditional_file_map.R
43 lines (32 loc) · 974 Bytes
/
Additional_file_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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# ----- Carga de paquetes -----
library(readr)
library(dplyr)
library(rgdal)
library(leaflet)
library(rgeos)
library(htmlwidgets)
# ----- Importación de ficheros -----
train <- read.csv(file = "Data/training_set_values.csv")
labels <- read.csv(file = "Data/training_set_labels.csv")
train <- cbind(train, status_group = labels$status_group)
# ----- Se eliminan casos con longitud 0 -----
nrow(train)
train <- train %>% filter(train$longitude != 0)
nrow(train)
# ----- Creación de código de colores -----
color <- ifelse(train$status_group == "functional",
"green",
ifelse(train$status_group == "non functional",
"red",
"orange"
)
)
# ----- Mapa en leaflet -----
leaflet() %>%
addProviderTiles(providers$OpenStreetMap) %>%
addCircles(lng = train$longitude,
lat = train$latitude,
fillColor = color,
stroke = FALSE, radius = 5000) -> mapa
# ----- Exportación de mapa -----
saveWidget(mapa, "mapa.html")