myGithub.

The following is a collection Caracas maps.

First the dependencies only four libraries

#install the osmdata, sf, tidyverse and ggmap package
if(!require("osmdata")) install.packages("osmdata")
## Loading required package: osmdata
## Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
if(!require("tidyverse")) install.packages("tidyverse")
## Loading required package: tidyverse
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.8     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
if(!require("sf")) install.packages("sf")
## Loading required package: sf
## Linking to GEOS 3.9.1, GDAL 3.4.3, PROJ 7.2.1; sf_use_s2() is TRUE
if(!require("ggmap")) install.packages("ggmap")
## Loading required package: ggmap
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
#load needed packages
library(osmdata)
library(tidyverse)
library(sf)
library(ggmap)

Display base map

bbox_caracas <- getbb("Caracas, Venezuela")
caracas_map <- get_stamenmap(bbox=bbox_caracas, zoom=12)
## Source : http://tile.stamen.com/terrain/12/1283/1927.png
## Source : http://tile.stamen.com/terrain/12/1284/1927.png
## Source : http://tile.stamen.com/terrain/12/1285/1927.png
## Source : http://tile.stamen.com/terrain/12/1286/1927.png
## Source : http://tile.stamen.com/terrain/12/1287/1927.png
## Source : http://tile.stamen.com/terrain/12/1288/1927.png
## Source : http://tile.stamen.com/terrain/12/1289/1927.png
## Source : http://tile.stamen.com/terrain/12/1283/1928.png
## Source : http://tile.stamen.com/terrain/12/1284/1928.png
## Source : http://tile.stamen.com/terrain/12/1285/1928.png
## Source : http://tile.stamen.com/terrain/12/1286/1928.png
## Source : http://tile.stamen.com/terrain/12/1287/1928.png
## Source : http://tile.stamen.com/terrain/12/1288/1928.png
## Source : http://tile.stamen.com/terrain/12/1289/1928.png
## Source : http://tile.stamen.com/terrain/12/1283/1929.png
## Source : http://tile.stamen.com/terrain/12/1284/1929.png
## Source : http://tile.stamen.com/terrain/12/1285/1929.png
## Source : http://tile.stamen.com/terrain/12/1286/1929.png
## Source : http://tile.stamen.com/terrain/12/1287/1929.png
## Source : http://tile.stamen.com/terrain/12/1288/1929.png
## Source : http://tile.stamen.com/terrain/12/1289/1929.png
ggmap(caracas_map)

Caracas map showing the streets

caracas_street<- opq(bbox=bbox_caracas)%>%add_osm_feature(key="highway")

caracas_street<- osmdata_sf(caracas_street)

caracas_street
## Object of class 'osmdata' with:
##                  $bbox : 10.3404973,-67.16228,10.5641499,-66.690883
##         $overpass_call : The call submitted to the overpass API
##                  $meta : metadata including timestamp and version numbers
##            $osm_points : 'sf' Simple Features Collection with 304326 points
##             $osm_lines : 'sf' Simple Features Collection with 29168 linestrings
##          $osm_polygons : 'sf' Simple Features Collection with 401 polygons
##        $osm_multilines : NULL
##     $osm_multipolygons : 'sf' Simple Features Collection with 9 multipolygons
caracas_street<-caracas_street$osm_lines

ggmap(caracas_map)+ geom_sf(data = caracas_street, inherit.aes = FALSE)
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

Caracas map with Avenues

ggmap(caracas_map)+
  geom_sf(data = filter(caracas_street, str_detect(name, "Avenue")), color="red", inherit.aes = FALSE)+
  scale_color_viridis_c()+
  labs(title="CARACAS",
       subtitle="Avenues",
       caption="Source: Open Street Map")+
  theme_void()
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

Caracas map with max speed range

 ggmap(caracas_map)+
  geom_sf(data= caracas_street, aes(color=maxspeed),inherit.aes = FALSE)+
  labs(title="CARACAS speed limit",
       caption="Source: Open Street Map")+
  theme_void() 
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

Caracas map with ordered speed range

caracas_street<- caracas_street %>% 
  mutate(maxspeed =  as.numeric(maxspeed))
ggmap(caracas_map)+
    geom_sf(data = caracas_street, aes(color=maxspeed), inherit.aes = FALSE)+
  scale_color_viridis_c()+
  labs(title="Cracas City",
       subtitle="Ordered by speed limit",
       caption="Source: Open Street Map")+
  theme_void()
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

Search for what to see at Caracas tourist visit

head(available_features(), n=30)
##  [1] "4wd_only"                "abandoned"              
##  [3] "abutters"                "access"                 
##  [5] "addr"                    "addr:city"              
##  [7] "addr:conscriptionnumber" "addr:country"           
##  [9] "addr:district"           "addr:flats"             
## [11] "addr:full"               "addr:hamlet"            
## [13] "addr:housename"          "addr:housenumber"       
## [15] "addr:inclusion"          "addr:interpolation"     
## [17] "addr:place"              "addr:postbox"           
## [19] "addr:postcode"           "addr:province"          
## [21] "addr:state"              "addr:street"            
## [23] "addr:subdistrict"        "addr:suburb"            
## [25] "addr:unit"               "admin_level"            
## [27] "aeroway"                 "agricultural"           
## [29] "alt_name"                "amenity"
head(available_tags("amenity"), n=30)
##  [1] "animal_boarding"        "animal_breeding"        "animal_shelter"        
##  [4] "arts_centre"            "atm"                    "baby_hatch"            
##  [7] "baking_oven"            "bank"                   "bar"                   
## [10] "bbq"                    "bench"                  "bicycle_parking"       
## [13] "bicycle_rental"         "bicycle_repair_station" "biergarten"            
## [16] "boat_rental"            "boat_sharing"           "brothel"               
## [19] "bureau_de_change"       "bus_station"            "cafe"                  
## [22] "car_rental"             "car_sharing"            "car_wash"              
## [25] "casino"                 "charging_station"       "childcare"             
## [28] "cinema"                 "clinic"                 "clock"

GoooooD ! lets see “arts_centre” in Carasas city

caracas_arts_centre<- opq(bbox_caracas) %>%
  add_osm_feature(key= "amenity", value = "arts_centre")
caracas_arts_centre<- osmdata_sf(caracas_arts_centre)
caracas_arts_centre
## Object of class 'osmdata' with:
##                  $bbox : 10.3404973,-67.16228,10.5641499,-66.690883
##         $overpass_call : The call submitted to the overpass API
##                  $meta : metadata including timestamp and version numbers
##            $osm_points : 'sf' Simple Features Collection with 34 points
##             $osm_lines : NULL
##          $osm_polygons : 'sf' Simple Features Collection with 5 polygons
##        $osm_multilines : NULL
##     $osm_multipolygons : NULL
caracas_arts_centre<- caracas_arts_centre$osm_points
ggmap(caracas_map)+
  geom_sf(data=caracas_arts_centre, aes(color=amenity), inherit.aes = FALSE)+
  labs(title="Caracas city arts centre locations",
       subtitle="Arts Centres",
       
       caption="Source: Open Street Map")+
  theme_void()
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

Ehere to find an ATM(ca$h search!!!!) in Carasas city

caracas_atm<- opq(bbox_caracas) %>%
  add_osm_feature(key= "amenity", value = "atm")
caracas_atm<- osmdata_sf(caracas_atm)
caracas_atm
## Object of class 'osmdata' with:
##                  $bbox : 10.3404973,-67.16228,10.5641499,-66.690883
##         $overpass_call : The call submitted to the overpass API
##                  $meta : metadata including timestamp and version numbers
##            $osm_points : 'sf' Simple Features Collection with 107 points
##             $osm_lines : NULL
##          $osm_polygons : 'sf' Simple Features Collection with 0 polygons
##        $osm_multilines : NULL
##     $osm_multipolygons : NULL
caracas_atm<- caracas_atm$osm_points
ggmap(caracas_map)+
  geom_sf(data=caracas_atm, aes(color=amenity), inherit.aes = FALSE)+
  labs(title="Caracas city ATM locations",
       subtitle="ATMs",
       
       caption="Source: Open Street Map")+
  theme_void()
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

Where are cinemas in Caracas City?

building the query

q <- getbb("Caracas,Venezuela") %>%
      opq() %>%
       add_osm_feature(key="amenity",value="cinema")
str(q) #query structure
## List of 4
##  $ bbox    : chr "10.3404973,-67.16228,10.5641499,-66.690883"
##  $ prefix  : chr "[out:xml][timeout:25];\n(\n"
##  $ suffix  : chr ");\n(._;>;);\nout body;"
##  $ features: chr " [\"amenity\"=\"cinema\"]"
##  - attr(*, "class")= chr [1:2] "list" "overpass_query"
##  - attr(*, "nodes_only")= logi FALSE
cinema <- osmdata_sf(q)
cinema
## Object of class 'osmdata' with:
##                  $bbox : 10.3404973,-67.16228,10.5641499,-66.690883
##         $overpass_call : The call submitted to the overpass API
##                  $meta : metadata including timestamp and version numbers
##            $osm_points : 'sf' Simple Features Collection with 27 points
##             $osm_lines : NULL
##          $osm_polygons : 'sf' Simple Features Collection with 1 polygons
##        $osm_multilines : NULL
##     $osm_multipolygons : NULL
# the final map
ggmap(caracas_map)+
  geom_sf(data = cinema$osm_points,
          inherit.aes = FALSE,
          colour = "#238443",
          fill = "#004529",
          alpha = .5,
          size = 4,
          shape = 21)+
  labs(x = "", y = "")
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

x <- citation("ggmap")
toBibtex(x)
## @Article{,
##   author = {David Kahle and Hadley Wickham},
##   title = {ggmap: Spatial Visualization with ggplot2},
##   journal = {The R Journal},
##   year = {2013},
##   volume = {5},
##   number = {1},
##   pages = {144--161},
##   url = {https://journal.r-project.org/archive/2013-1/kahle-wickham.pdf},
## }
installed.packages()[names(sessionInfo()$otherPkgs), "Version"]
##     ggmap        sf   forcats   stringr     dplyr     purrr     readr     tidyr 
##   "3.0.0"   "1.0-8"   "0.5.1"   "1.4.0"   "1.0.9"   "0.3.4"   "2.1.2"   "1.2.0" 
##    tibble   ggplot2 tidyverse   osmdata 
##   "3.1.8"   "3.3.6"   "1.3.2"  "0.1.10"