JuveYell

Fuente:foto es del HONDUSA TV.

PLUS: Los ÚLTIMOS DOS MAPAS SON INTERACTIVOS, POR FAVOR REVISAR.

Consultor en Data Science, ML y Sistemas de Información Geográfica

##Haga Click Aqui para ver Certificado Machine Learning MIT https://www.credential.net/4dd365ea-ea5a-46a2-a72e-539e70545c6e

##Haga Click Aqui para ver Certificado Columbia Python for Managers https://certificates.emeritus.org/0a2e1de7-add2-4710-ad49-417d1dadfb61#gs.4a92hv ##Contacto:

Algunos Dashboards elaborados son: Para Bolsa de Valores https://rchang.shinyapps.io/rchang-stock-exchange/

Para el Estado del Clima https://rchang.shinyapps.io/rchang-app_clima_ho/

Para Machine Learning https://rchang.shinyapps.io/rchang-app/

Para Empresariales e Industriales https://rchang.shinyapps.io/rchang-app_final_emp/

Para Dashboards con log in https://rchang.shinyapps.io/clase_3-shiny-2/_w_ae4e775f/_w_f249a9a1/?page=sign_in

y para Sistemas de Información Geográfica

https://wiki.openstreetmap.org/wiki/ES:Caracter%C3%ADsticas_del_mapa

available_features()
##   [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] "admin_level"             "aeroway"                
##  [27] "agricultural"            "alt_name"               
##  [29] "amenity"                 "area"                   
##  [31] "atv"                     "backward"               
##  [33] "barrier"                 "basin"                  
##  [35] "bdouble"                 "bicycle"                
##  [37] "bicycle_road"            "biergarten"             
##  [39] "boat"                    "border_type"            
##  [41] "boundary"                "bridge"                 
##  [43] "building"                "building:fireproof"     
##  [45] "building:flats"          "building:levels"        
##  [47] "building:min_level"      "building:soft_storey"   
##  [49] "bus_bay"                 "busway"                 
##  [51] "charge"                  "construction"           
##  [53] "covered"                 "craft"                  
##  [55] "crossing"                "crossing:island"        
##  [57] "cuisine"                 "cutting"                
##  [59] "cycleway"                "denomination"           
##  [61] "destination"             "diet"                   
##  [63] "direction"               "dispensing"             
##  [65] "disused"                 "disused:shop"           
##  [67] "drink"                   "drive_in"               
##  [69] "drive_through"           "ele"                    
##  [71] "electric_bicycle"        "electrified"            
##  [73] "embankment"              "embedded_rails"         
##  [75] "emergency"               "end_date"               
##  [77] "entrance"                "est_width"              
##  [79] "fee"                     "fire_object:type"       
##  [81] "fire_operator"           "fire_rank"              
##  [83] "foot"                    "footway"                
##  [85] "ford"                    "forestry"               
##  [87] "forward"                 "frequency"              
##  [89] "fuel"                    "gauge"                  
##  [91] "golf_cart"               "goods"                  
##  [93] "hazmat"                  "healthcare"             
##  [95] "healthcare:counselling"  "healthcare:speciality"  
##  [97] "height"                  "hgv"                    
##  [99] "highway"                 "historic"               
## [101] "horse"                   "ice_road"               
## [103] "incline"                 "industrial"             
## [105] "inline_skates"           "inscription"            
## [107] "internet_access"         "junction"               
## [109] "kerb"                    "landuse"                
## [111] "lanes"                   "lanes:bus"              
## [113] "lanes:psv"               "layer"                  
## [115] "leaf_cycle"              "leaf_type"              
## [117] "leisure"                 "lhv"                    
## [119] "lit"                     "location"               
## [121] "man_made"                "maxaxleload"            
## [123] "maxheight"               "maxlength"              
## [125] "maxspeed"                "maxstay"                
## [127] "maxweight"               "maxwidth"               
## [129] "military"                "minspeed"               
## [131] "mofa"                    "moped"                  
## [133] "motor_vehicle"           "motorboat"              
## [135] "motorcar"                "motorcycle"             
## [137] "motorroad"               "mountain_pass"          
## [139] "mtb:description"         "mtb:scale:imba"         
## [141] "mtb_scale"               "name"                   
## [143] "name:left"               "name:right"             
## [145] "narrow"                  "natural"                
## [147] "noexit"                  "non_existent_levels"    
## [149] "note"                    "nudism"                 
## [151] "office"                  "official_name"          
## [153] "old_name"                "oneway"                 
## [155] "opening_hours"           "operator"               
## [157] "organic"                 "oven"                   
## [159] "overtaking"              "parking:condition"      
## [161] "parking:lane"            "passing_places"         
## [163] "place"                   "power"                  
## [165] "priority_road"           "produce"                
## [167] "proposed"                "protected_area"         
## [169] "psv"                     "public_transport"       
## [171] "railway"                 "railway:preserved"      
## [173] "railway:track_ref"       "recycling_type"         
## [175] "ref"                     "religion"               
## [177] "residential"             "roadtrain"              
## [179] "route"                   "sac_scale"              
## [181] "service"                 "service_times"          
## [183] "shelter_type"            "shop"                   
## [185] "short_name"              "sidewalk"               
## [187] "site"                    "ski"                    
## [189] "smoothness"              "social_facility"        
## [191] "sorting_name"            "speed_pedelec"          
## [193] "start_date"              "step_count"             
## [195] "substation"              "surface"                
## [197] "tactile_paving"          "tank"                   
## [199] "tidal"                   "toilets:wheelchair"     
## [201] "toll"                    "tourism"                
## [203] "tracks"                  "tracktype"              
## [205] "traffic_calming"         "traffic_sign"           
## [207] "trail_visibility"        "trailblazed"            
## [209] "trailblazed:visibility"  "tunnel"                 
## [211] "turn"                    "type"                   
## [213] "usage"                   "vehicle"                
## [215] "vending"                 "voltage"                
## [217] "water"                   "wheelchair"             
## [219] "wholesale"               "width"                  
## [221] "winter_road"             "wood"
available_tags("amenity")
##   [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"                 
##  [31] "college"                "community_centre"       "conference_centre"     
##  [34] "courthouse"             "crematorium"            "dentist"               
##  [37] "dive_centre"            "doctors"                "dog_toilet"            
##  [40] "drinking_water"         "driving_school"         "embassy"               
##  [43] "events_venue"           "fast_food"              "ferry_terminal"        
##  [46] "fire_station"           "food_court"             "fountain"              
##  [49] "fuel"                   "funeral_hall"           "gambling"              
##  [52] "give_box"               "grave_yard"             "grit_bin"              
##  [55] "gym"                    "hospital"               "hunting_stand"         
##  [58] "ice_cream"              "internet_cafe"          "kindergarten"          
##  [61] "kitchen"                "kneipp_water_cure"      "language_school"       
##  [64] "library"                "lounger"                "love_hotel"            
##  [67] "marketplace"            "monastery"              "motorcycle_parking"    
##  [70] "music_school"           "nightclub"              "nursing_home"          
##  [73] "parking"                "parking_entrance"       "parking_space"         
##  [76] "pharmacy"               "photo_booth"            "place_of_mourning"     
##  [79] "place_of_worship"       "planetarium"            "police"                
##  [82] "post_box"               "post_depot"             "post_office"           
##  [85] "prison"                 "pub"                    "public_bath"           
##  [88] "public_bookcase"        "public_building"        "ranger_station"        
##  [91] "recycling"              "refugee_site"           "restaurant"            
##  [94] "sanitary_dump_station"  "school"                 "shelter"               
##  [97] "shower"                 "social_centre"          "social_facility"       
## [100] "stripclub"              "studio"                 "swingerclub"           
## [103] "taxi"                   "telephone"              "theatre"               
## [106] "toilets"                "townhall"               "toy_library"           
## [109] "university"             "vehicle_inspection"     "vending_machine"       
## [112] "veterinary"             "waste_basket"           "waste_disposal"        
## [115] "waste_transfer_station" "water_point"            "watering_place"

Aquí me traigo la caja de coordenadas

bbox_tegucigalpa <- getbb("Tegucigalpa", "Honduras")
mapa_tegucigalpa<- get_stamenmap(bbox=bbox_tegucigalpa,
                                 zoom=12)
## Source : http://tile.stamen.com/terrain/12/1054/1885.png
## Source : http://tile.stamen.com/terrain/12/1055/1885.png
## Source : http://tile.stamen.com/terrain/12/1056/1885.png
## Source : http://tile.stamen.com/terrain/12/1054/1886.png
## Source : http://tile.stamen.com/terrain/12/1055/1886.png
## Source : http://tile.stamen.com/terrain/12/1056/1886.png
## Source : http://tile.stamen.com/terrain/12/1054/1887.png
## Source : http://tile.stamen.com/terrain/12/1055/1887.png
## Source : http://tile.stamen.com/terrain/12/1056/1887.png
ggmap(mapa_tegucigalpa)

Podemos poner el contorno y los bordes la ciudad

polygon_tegus <- getbb("Tegucigalpa", "Honduras",
                          format_out = "sf_polygon")
ggmap(mapa_tegucigalpa)+
  geom_sf(data=polygon_tegus, inherit.aes = FALSE, fill= NA, color="red", size= 2)
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

##        ggsave("mapa.jpg")
#st_write(polygon_tegus, "C:/Users/ladylee/Desktop/polygon_tegucigalpa.geojson")

Y si queres cambiarle el tamaño podes usar las variables width y height (ancho y alto en ingles) pdf(“el titulo que quieras.pdf”,width = 10, height = 10) ggmap(mapa_montevideo) dev.off()

Vamos a bajar líneas, calles Esta linea es para consulta

calles_tegucigalpa <- opq(bbox=bbox_tegucigalpa) %>%
                      add_osm_feature(key="highway")

Ahora para bajar las calles

calles_tegucigalpa
## Object of class 'osmdata' with:
##                  $bbox : 14.0068238,-87.2790971,14.1422032,-87.1327733
##         $overpass_call : The call submitted to the overpass API
##                  $meta : metadata including timestamp and version numbers
##            $osm_points : 'sf' Simple Features Collection with 77987 points
##             $osm_lines : 'sf' Simple Features Collection with 13592 linestrings
##          $osm_polygons : 'sf' Simple Features Collection with 87 polygons
##        $osm_multilines : NULL
##     $osm_multipolygons : NULL
ggmap(mapa_tegucigalpa)+
  geom_sf(data=polygon_tegus, inherit.aes = FALSE, fill=NA, color="red", size=1.5)+
  geom_sf(data=calles_tegucigalpa, inherit.aes = FALSE)
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

Para salvar imagenes: También funcionaría con p <- ggplot(mtcars, aes(mpg, wt)) + geom_point() ggsave(“nombre.png”, plot = p)

Ahora intersectemos calles con poligonos de Tegucigalpa

calles_tegucigalpa<- st_intersection(calles_tegucigalpa, polygon_tegus)
## Warning: attribute variables are assumed to be spatially constant throughout all
## geometries
ggmap(mapa_tegucigalpa)+
    geom_sf(data = calles_tegucigalpa, aes(color=as.numeric(maxspeed)), inherit.aes = FALSE)+
  scale_color_viridis_c()+
  labs(title="Tegucigalpa, Honduras",
       subtitle="Velocidad Máxima Permitida",
       color= "Máxima Velocidad",
       caption="Fuente: Open Street Map")+
  theme_void()
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

ggmap(mapa_tegucigalpa)+
    geom_sf(data = calles_tegucigalpa, aes(color=maxspeed), inherit.aes = FALSE)+
  scale_color_viridis_d()+
  labs(title="Tegucigalpa, Honduras",
       subtitle="Velocidad Máxima Permitida",
       caption="Fuente: Open Street Map")+
  theme_void()
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

#Parques de Tegucigalpa

Artículo respecto a los 17 tipos de “simple features” existentes : https://r-spatial.github.io/sf/articles/sf1.html

ggmap(mapa_tegucigalpa)+
  geom_sf(data=polygon_tegus, inherit.aes = FALSE, color="red", fill=NA)+
  geom_sf(data=park_tegucigalpa, inherit.aes = FALSE, fill="green")
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

Gastronomía en Tegucigalpa

MAPA DE TEGUCIGALPA CON LOS PARQUE Y GASTRONOMÍA

ggmap(mapa_tegucigalpa)+
  geom_sf(data=polygon_tegus, inherit.aes = FALSE, color="red", fill=NA)+
  geom_sf(data=park_tegucigalpa, inherit.aes = FALSE, fill="green")+
  geom_sf(data=gastronomia_tegucigalpa, inherit.aes = FALSE, fill = "blue")
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

DEPURANDO LOS VALORES FALTANTES

gastronomia_tegucigalpa <- gastronomia_tegucigalpa %>%
  dplyr::filter(!is.na(amenity))
ggmap(mapa_tegucigalpa)+
  geom_sf(data=polygon_tegus, inherit.aes = FALSE, color="red", fill=NA)+
  geom_sf(data=park_tegucigalpa, inherit.aes = FALSE, fill="green")+
  geom_sf(data=gastronomia_tegucigalpa, inherit.aes = FALSE, aes(color=amenity))
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

#MAPAS INTERACTIVOS DE LA CIUDAD

leaflet(gastronomia_tegucigalpa) %>%
  addTiles() %>%
  addMarkers(clusterOptions = markerClusterOptions())
leaflet(gastronomia_tegucigalpa) %>%
  addTiles() %>%
  addMarkers(clusterOptions = markerClusterOptions(),
             popup = paste("Tipo:", gastronomia_tegucigalpa$amenity, "<br>",
                           "Nombre:", gastronomia_tegucigalpa$name)) %>% 
  addMarkers(clusterOptions = markerClusterOptions(),
             popup = paste("Tipo:", park_tegucigalpa$amenity, "<br>",
                           "Nombre:", park_tegucigalpa$name))