Servicios turismo OSM

Author

Diego J. Lizcano,

Published

April 16, 2023

Hoteles

Descarga de OpenStreetMap con API

Code
library(osmdata)
library(mapview)
library(tidyverse)
library(sf)
Code
# C:/CodigoR/Municipios_DN/shp/DNA/DNA.shp"
pdet1 <- st_read("C:/CodigoR/Municipios_DN/shp/PDET/PDET.shp",
                quiet = TRUE)
dna <- st_read("C:/CodigoR/Municipios_DN/shp/DNA/DNA.shp",
                quiet = TRUE)
Code
hoteles <- opq(bbox=c(-77.4, 7.64, -72, 12.5)) %>%
    add_osm_feature ("tourism", c("hotel", "guest_house", "hostel", "motel", "chalet")) %>%  osmdata_sf()

hoteles_caribe <- hoteles$osm_points %>% select("name", "addr:street", "addr:city", "internet_access")

# magdalena_hotel <- opq(bbox = 'Magdalena, Colombia')  %>%
#     add_osm_feature ("tourism", c("hotel", "guest_house", "hostel", "motel", "chalet")) %>%  osmdata_sf ()
#   
# cesar_hotel <- opq(bbox = 'Cesar, Colombia')  %>%
#     add_osm_feature ("tourism", c("hotel", "guest_house", "hostel", "motel", "chalet")) %>%  osmdata_sf ()
# 
# bolivar_hotel <- opq(bbox = 'Bolivar, Colombia')  %>%
#     add_osm_feature ("tourism", c("hotel", "guest_house", "hostel", "motel", "chalet")) %>%  osmdata_sf ()
# 
# sucre_hotel <- opq(bbox = 'Sucre, Colombia')  %>%
#     add_osm_feature ("tourism", c("hotel", "guest_house", "hostel", "motel", "chalet")) %>%  osmdata_sf ()
# 
# hotel_1 <- st_union(magdalena_hotel$osm_points, 
#                         cesar_hotel$osm_points,  by_feature =osm_id)
# hotel_2 <- st_union(bolivar_hotel$osm_points,
#                         sucre_hotel$osm_points, by_feature =osm_id)
# hotel_points <- st_join(hotel_1, hotel_2)

# # merge in one file
# hotel_points <- dplyr::bind_rows(list(magdalena_hotel$osm_points, 
#                         cesar_hotel$osm_points,
#                         bolivar_hotel$osm_points,
#                         sucre_hotel$osm_points))  %>% st_combine() 


hoteles_dna <- st_join (hoteles_caribe, dna, left = FALSE) 

mapview(hoteles_caribe, alpha=0, cex=2,  col.regions ="lightgreen") + 
  mapview(hoteles_dna, alpha=0, cex=2,  zcol ="dprtmnt") 
Code
# library(ggmap)
# library(googleway)
# register_google(key = "AIzaSyDJmcl2kNxd_-qbmajoHobxa6G-RFR_f8s", write = TRUE)
# drone.map <- get_map(location = c(-77.4, 7.64), zoom = 9, scale = 2)
# ## Convert into ggmap object
# drone.map <- ggmap(drone.map, extent="device", legend="none")
Code
library(ggmap)

hoteles_df <- as.data.frame(as_Spatial(hoteles_dna))
hoteles_dful <- as.data.frame(as_Spatial(hoteles_caribe))


qmplot(coords.x1, coords.x2, data = hoteles_dful, size = I(1), alpha = I(.1)) + 
  #stat_density2d(aes(coords.x1, coords.x2), data = hoteles_dful, bins = 5) + 
geom_point(aes(coords.x1, coords.x2, colour = internet_access), data = hoteles_df, alpha = .6, size = I(2)) + facet_wrap(~ dprtmnt)