geoT <- "WFS:https://ide.transporte.gob.ar/geoserver/ows?service=wfs&version=1.3.0&request=GetCapabilities"
st_layers(geoT)
## Driver: WFS 
## Available layers:
##                                                 layer_name     geometry_type
## 1                              idera:111213OpSubeColectivo     Multi Surface
## 2                   idera:111213OpSubeColectivoFerrocarril     Multi Surface
## 3                         idera:111213OpSubeColectivoSubte     Multi Surface
## 4              idera:111213OpSubeColectivoSubteFerrocarril     Multi Surface
## 5                            idera:111213OpSubeFerrocarril     Multi Surface
## 6                            idera:16_17_18OpSubeColectivo     Multi Surface
## 7                       idera:16_17_18OpSubeColectivoSubte     Multi Surface
## 8                        idera:16_17_18OpSubeColectivoTren     Multi Surface
## 9                   idera:16_17_18OpSubeColectivoTrenSubte     Multi Surface
## 10                                idera:16_17_18OpSubeTren     Multi Surface
## 11                                idera:678OpSubeColectivo     Multi Surface
## 12                           idera:678OpSubeColectivoSubte     Multi Surface
## 13                idera:678OpSubeColectivoSubteFerrocarril     Multi Surface
## 14                            idera:678opSubeColectivoTren     Multi Surface
## 15                                         idera:678opTren     Multi Surface
## 16             observ:_3.6.1.9_Asig_vial_total_grupos.view Multi Line String
## 17             observ:_3.6.1.5.Industrializados_Total.view Multi Line String
## 18                      observ:_3.6.1.6.Mineria_Total.view Multi Line String
## 19                   observ:_3.6.1.7.Regionales_Total.view Multi Line String
## 20               observ:_3.6.1.8.Semiterminados_Total.view Multi Line String
## 21                 observ:_3.6.1.3.Combustibles_Total.view Multi Line String
## 22                     observ:_3.6.1.9.asig_mineria_t.view Multi Line String
## 23                           orsna:_3.4.4.5_SNA_jun17.view       Multi Point
## 24                                       idera:Aeropuertos       Multi Point
## 25                 observ:_3.4.4.1.2.aerodromos_ont_a_view             Point
## 26             observ:_3.4.4.1.5_aerodromos_anac_2018.view             Point
## 27                       observ:conteotransito_dnv_19_view       Multi Point
## 28                           observ:_3.4.1.4.1.tmda_a_view Multi Line String
## 29                        observ:_3.4.1.4.1.tmda_2016_view Multi Line String
## 30                       observ:_3.4.1.4.1.tmda_17_18_view                  
## 31           observ:_3.4.2.2.4.boletos_vend_fc_cnrt_a_view             Point
## 32                                 idera:cas_usg_2024.view             Point
## 33                            idera:cas_ugs_amba_2024.view             Point
## 34            observ:_3.4.1.7.red_vial_ign_ont_b_terc_view Multi Line String
## 35                        c_rurales_6:caminos_rurales.view       Line String
## 36       idera:Carga transportada grupo  ganado en pie2018                  
## 37              idera:Carga transportada grupo carnes 2018 Multi Line String
## 38        idera:Carga transportada grupo combustibles 2018 Multi Line String
## 39              idera:Carga transportada grupo granos 2018 Multi Line String
## 40    idera:Carga transportada grupo industrializados 2018 Multi Line String
## 41             idera:Carga transportada grupo mineria 2018 Multi Line String
## 42          idera:Carga transportada grupo regionales 2018 Multi Line String
## 43            idera:Carga transportada semiterminados 2018 Multi Line String
## 44                     idera:Carga transportada total 2018 Multi Line String
## 45                       observ:_3.6.1.1.Carnes_total.view Multi Line String
## 46                       observ:_3.6.1.4.Granos_Total.view Multi Line String
## 47             observ:_3.6.1.9.Asig_vial_granos_total.view Multi Line String
## 48                  observ:_3.6.1.9.asig_vial_carne_t.view Multi Line String
## 49                   observ:_3.6.1.9.red_simplificada.view Multi Line String
## 50                       observ:centrales_y_proyectos.view       Multi Point
## 51                         observ:_3.6.1.2.Centroides.view       Multi Point
## 52                        observ:sube_op_bus_11_12_13_view     Multi Surface
## 53                        observ:sube_op_bus_16_17_18_view     Multi Surface
## 54                           observ:sube_op_bus_6_7_8_view     Multi Surface
## 55                      observ:sube_op_bus_ffcc_6_7_8_view     Multi Surface
## 56                   observ:sube_op_bus_ffcc_11_12_13_view     Multi Surface
## 57                   observ:sube_op_bus_ffcc_16_17_18_view     Multi Surface
## 58                  observ:sube_op_bus_subte_11_12_13_view     Multi Surface
## 59                  observ:sube_op_bus_subte_16_17_18_view     Multi Surface
## 60                     observ:sube_op_bus_subte_6_7_8_view     Multi Surface
## 61             observ:sube_op_bus_ffcc_subte_11_12_13_view     Multi Surface
## 62             observ:sube_op_bus_ffcc_subte_16_17_18_view     Multi Surface
## 63                observ:sube_op_bus_ffcc_subte_6_7_8_view     Multi Surface
## 64                         observ:red_vial_idecorr_19_view Multi Line String
## 65           observ:_3.4.1.1.5.cruces_fc_sigvial_2019_view       Multi Point
## 66              observ:_3.4.1.1.5.cruces_fc_sigvial_a_view             Point
## 67                         observ:ductos_proyectasdos.view Multi Line String
## 68           observ:_3.4.2.2.6.estaciones_adif_032019.view       Multi Point
## 69                              idera:Estacion_Ferroviaria       Multi Point
## 70         observ:_3.4.2.2.7.estaciones_fc_rmba_ont_a_view             Point
## 71      observ:_3.4.2.2.6.estaciones_adif_ont_11_2017.view       Multi Point
## 72     observ:_3.2.3.4.premetro_estaciones_usig_ont_a_view             Point
## 73        observ:_3.2.3.2.subte_estaciones_usig_ont_a_view             Point
## 74            observ:_3.2.3.2.subte_est_usig_31082018.view       Multi Point
## 75            observ:_3.4.2.2.6.estaciones_adif_ont_a_view             Point
## 76         observ:_3.2.3.4.premetro_est_usig_31082018.view       Multi Point
## 77                        idera:Estacion_ffcc_serv_22.view             Point
## 78                       observ:sube_op_ffcc_11_12_13_view     Multi Surface
## 79                       observ:sube_op_ffcc_16_17_18_view     Multi Surface
## 80                          observ:sube_op_ffcc_6_7_8_view     Multi Surface
## 81       observ:_3.6.1.9.asig_vial_combustibles_total.view Multi Line String
## 82                   observ:_3.6.1.9.asig_industria_t.view Multi Line String
## 83              observ:_3.6.1.9.asig_vialregionales_t.view Multi Line String
## 84         observ:_3.6.1.9.asig_vial_semiterminados_t.view Multi Line String
## 85                  dpyct:dpyct_franjas_territoriales_view     Multi Surface
## 86      observ:3.2.3.4.premetro_estaciones_usig_ont_b_view             Point
## 87        observ:_3.2.3.2.subte_estaciones_usig_ont_b_view             Point
## 88                 observ:instalaciones_hidrocarburos.view       Multi Point
## 89                              observ:lineas_un_cnrt_view Multi Line String
## 90           idera:Lineas_colectivos _nacionales_RMBA_2019 Multi Line String
## 91                        observ:_3.1.5.1.intrupuba_c_view Multi Line String
## 92                        observ:_3.1.5.1.intrupuba_a_view Multi Line String
## 93                        observ:_3.1.5.1.intrupuba_b_view Multi Line String
## 94           observ:lineas_de_colectivos_nacionales_a_view Multi Line String
## 95           observ:lineas_de_colectivos_nacionales_b_view Multi Line String
## 96  dpyct:dpyct_micrrorregiones_complejos_productivos_view     Multi Surface
## 97                     dpyct:dpyct_deptos_megalopolis_view     Multi Surface
## 98                 dpyct:dpyct_jerarq_ciudades_transp_view             Point
## 99     observ:_3.4.4.3.pasajeros_transp_aeropuertos_a_view             Point
## 100           observ:_3.4.1.5.pasos_fronterizos_ont_a_view             Point
## 101         observ:_3.4.1.1.3.pavimento_ont_sigvial_b_view Multi Line String
## 102               observ:_3.4.1.1.3.pavimento_dnv2018.view Multi Line String
## 103              observ:_3.4.1.6.peajes_ont_sigvial_a_view             Point
## 104                   observ:_3.4.1.6.peajes_dnv_2017.view       Multi Point
## 105                      observ:_3.4.1.1.4.poste_25km_2018       Multi Point
## 106       orsna:_3.4.4.6.Predios_Aeroportuarios_jun17.view     Multi Surface
## 107                      orsna:Predios_Aeroportuarios_2021     Multi Surface
## 108                observ:_3.4.1.1.7.puentes_DNV_2018.view             Point
## 109                     observ:_3.4.3.4.puertos_ont_a_view             Point
## 110                                          idera:Puertos             Point
## 111                                      idera:Ferrocarril Multi Line String
## 112            observ:_3.4.2.2.5.red_adif_ont_11_2017.view Multi Line String
## 113           observ:_3.2.3.3.premetro_red_usig_ont_a_view Multi Line String
## 114              observ:_3.2.3.1.subte_red_usig_ont_a_view Multi Line String
## 115           observ:_3.2.3.1.subte_red_usig_31082018.view Multi Line String
## 116                  observ:_3.4.2.2.5.red_adif_ont_a_view Multi Line String
## 117                observ:_3.4.2.2.5.red_adif_11.2018.view Multi Line String
## 118        observ:_3.2.3.3.premetro_red_usig_31082018.view Multi Line String
## 119             observ:_3.4.2.2.5.red_adif_20.11.2018.view Multi Line String
## 120          observ:_3.4.1.1.6.rutas_nacionales_dnv18.view Multi Line String
## 121                                 idera:Rutas_Nacionales Multi Line String
## 122           observ:_3.4.1.7.red_vial_ign_ont_a_prov_view Multi Line String
## 123               observ:_3.4.4.8.rutas_cabotaje_2017.view Multi Line String
## 124     observ:_3.4.4.2.2.rutas_aer_nac_sigplan_ont_a_view Multi Line String
## 125          observ:_3.4.1.1.1.rutas_nacionales_ont_a_view Multi Line String
## 126                              orsna:SNA_abril_2021.view       Multi Point
## 127                             observ:salta_vialidad_view Multi Line String
## 128                           idera:Servicios_ffcc_22.view Multi Line String
## 129          observ:_3.4.2.2.8.red_fc_rmba_adif_ont_a_view Multi Line String
## 130             observ:_3.4.3.1.terminales_portuarias_view             Point
## 131                            idera:Terminales_Portuarias             Point
## 132          observ:_3.4.1.4.2.var_tmda_ont_sigplan_a_view Multi Line String
## 133                         observ:_3.1.5.2.CNRT_2016.view Multi Line String
## 134           observ:_3.2.3.1.subte_red_usig_05072019_view Multi Line String
## 135           observ:_3.2.3.2.subte_est_usig_05072019_view             Point
## 136          observ:_3.4.1.1.6.rutas_nacionales_dnv17.view Multi Line String
## 137        observ:_3.4.4.3.pasajeros_trans_2016_orsna_view       Multi Point
## 138                             observ:_3.4.6.3_ign_deptos                  
## 139                            observ:_3.6.1.10.zonas.view     Multi Surface
## 140                     observ:_3.4.1.1.4.postes_km_a_view             Point
## 141                    observ:_3.4.1.1.4.postes_km_10_view             Point
## 142                   observ:_3.4.1.1.4.postes_km_100_view             Point
## 143                     observ:_3.4.1.1.4.poste_km_25_view             Point
## 144                  observ:amba_servicios_estaciones.view             Point
## 145                           observ:amba_servicios_lineas Multi Line String
## 146                            observ:barrios_renabap_view     Multi Surface
## 147                     observ:centros_educativos_hab_view       Multi Point
## 148                              c_rurales_6:grid_prueba_v       Line String
## 149                                       observ:hexa.view     Multi Surface
## 150                   c_rurales_6:idera_planta_urbana_view     Multi Surface
## 151                            observ:pbn_berazategui_view             Point
## 152                                observ:pbn_lomas_z_view             Point
## 153                     observ:_3.4.1.1.4.poste_100km_2018       Multi Point
## 154                      observ:_3.4.1.1.4.poste_10km_2018       Multi Point
## 155                       observ:_3.4.1.1.4.poste_1km_2018       Multi Point
## 156                           observ:red_vial_mendoza_view Multi Line String
## 157                            observ:registros_salud_view             Point
## 158    observ:_3.4.4.7_sup_limitadora_obstaculos_2018.view     Multi Surface
## 159                                         publico:tmda_p     Curve Polygon
## 160                     observ:vulnerabilidad_3p_2016_view     Multi Surface
## 161                           observ:zonas_horticolas_view     Multi Surface
##     features fields crs_name
## 1       7822     10   WGS 84
## 2        232     10   WGS 84
## 3         68     10   WGS 84
## 4          5     10   WGS 84
## 5         14     10   WGS 84
## 6       7915      9   WGS 84
## 7         67      9   WGS 84
## 8        237      9   WGS 84
## 9          6      9   WGS 84
## 10        18      9   WGS 84
## 11      7928      9   WGS 84
## 12        68      9   WGS 84
## 13         5      9   WGS 84
## 14       234      9   WGS 84
## 15        11      9   WGS 84
## 16       878      5   WGS 84
## 17      7503     10   WGS 84
## 18      7503     10   WGS 84
## 19      7503     10   WGS 84
## 20      7503     10   WGS 84
## 21      7503     10   WGS 84
## 22       878      5   WGS 84
## 23        55     18   WGS 84
## 24        55     13   WGS 84
## 25      1248      7   WGS 84
## 26       693      8   WGS 84
## 27       603      8   WGS 84
## 28      1374      9   WGS 84
## 29      1412     11   WGS 84
## 30      1234      8   WGS 84
## 31       282     26   WGS 84
## 32       269      6   WGS 84
## 33       162      6   WGS 84
## 34    117127      5   WGS 84
## 35    126914     40   WGS 84
## 36      1731      0   WGS 84
## 37      1731     39   WGS 84
## 38      1731     39   WGS 84
## 39      1731     39   WGS 84
## 40      1731     39   WGS 84
## 41      1731     39   WGS 84
## 42      1731     39   WGS 84
## 43      1731     39   WGS 84
## 44      1731     39   WGS 84
## 45      7503     10   WGS 84
## 46      7503     10   WGS 84
## 47       878      5   WGS 84
## 48       878      8   WGS 84
## 49       878      4   WGS 84
## 50       282     13   WGS 84
## 51       123      9   WGS 84
## 52      8506      3   WGS 84
## 53      8565      3   WGS 84
## 54      8634      3   WGS 84
## 55       176      3   WGS 84
## 56       177      3   WGS 84
## 57       176      3   WGS 84
## 58        68      3   WGS 84
## 59        68      3   WGS 84
## 60        68      3   WGS 84
## 61         4      3   WGS 84
## 62         4      3   WGS 84
## 63         4      3   WGS 84
## 64      6028     16   WGS 84
## 65       207      9   WGS 84
## 66       338      6   WGS 84
## 67        34      3   WGS 84
## 68      2218     11   WGS 84
## 69      2218     11   WGS 84
## 70       282      6   WGS 84
## 71      2635      8   WGS 84
## 72        19     10   WGS 84
## 73        85      4   WGS 84
## 74        87      4   WGS 84
## 75      3255      7   WGS 84
## 76        18      4   WGS 84
## 77       487     11   WGS 84
## 78         4      3   WGS 84
## 79         5      3   WGS 84
## 80         5      3   WGS 84
## 81       878      5   WGS 84
## 82       878      5   WGS 84
## 83       878      5   WGS 84
## 84       878      5   WGS 84
## 85        24      7   WGS 84
## 86        19     10   WGS 84
## 87        85     11   WGS 84
## 88    114455      7   WGS 84
## 89        76     11   WGS 84
## 90      1148      8   WGS 84
## 91       459     15   WGS 84
## 92       951     15   WGS 84
## 93       600     15   WGS 84
## 94       586      6   WGS 84
## 95       578      6   WGS 84
## 96        52     10   WGS 84
## 97        83      5   WGS 84
## 98        69      5   WGS 84
## 99        59      8   WGS 84
## 100      143     13   WGS 84
## 101     2831      7   WGS 84
## 102     2349     11   WGS 84
## 103       78      8   WGS 84
## 104       78      8   WGS 84
## 105     1062     11   WGS 84
## 106       78     10   WGS 84
## 107       80     12   WGS 84
## 108     3129     17   WGS 84
## 109      104      5   WGS 84
## 110      101      5   WGS 84
## 111      318     20   WGS 84
## 112      301      5   WGS 84
## 113        3      4   WGS 84
## 114       79      3   WGS 84
## 115       81      3   WGS 84
## 116     1767     15   WGS 84
## 117      318     20   WGS 84
## 118        3      4   WGS 84
## 119      318     20   WGS 84
## 120      272     12   WGS 84
## 121      272     12   WGS 84
## 122    22316      5   WGS 84
## 123      119      7   WGS 84
## 124      145      7   WGS 84
## 125      220      3   WGS 84
## 126       55     13   WGS 84
## 127      294      6   WGS 84
## 128       53     10   WGS 84
## 129      103      3   WGS 84
## 130      126      8   WGS 84
## 131      184     18   WGS 84
## 132     1334     14   WGS 84
## 133     1164      9   WGS 84
## 134        7     24   WGS 84
## 135       90     17   WGS 84
## 136      544      3   WGS 84
## 137       55      9   WGS 84
## 138        0      9   WGS 84
## 139      123      7   WGS 84
## 140    24118      9   WGS 84
## 141     2443     14   WGS 84
## 142      219     14   WGS 84
## 143      953     14   WGS 84
## 144      302      9   WGS 84
## 145       49     11   WGS 84
## 146     4416     22   WGS 84
## 147    62399     48   WGS 84
## 148   448002      2   WGS 84
## 149   293056      6   WGS 84
## 150     3029      8   WGS 84
## 151        2     36   WGS 84
## 152        3     36   WGS 84
## 153      226     11   WGS 84
## 154     2703     11   WGS 84
## 155    27143     11   WGS 84
## 156       50     10   WGS 84
## 157    26333      7   WGS 84
## 158      134      4   WGS 84
## 159   426200     20   WGS 84
## 160    12416     16   WGS 84
## 161      126      4   WGS 84
capa <- "idera:Rutas_Nacionales"

rutas <- st_read(geoT, capa)
## Reading layer `idera:Rutas_Nacionales' from data source 
##   `WFS:https://ide.transporte.gob.ar/geoserver/ows?service=wfs&version=1.3.0&request=GetCapabilities' 
##   using driver `WFS'
## Simple feature collection with 272 features and 12 fields
## Geometry type: MULTILINESTRING
## Dimension:     XY
## Bounding box:  xmin: -72.2988 ymin: -54.97218 xmax: -53.64077 ymax: -22.05302
## Geodetic CRS:  WGS 84
leaflet() %>% 
  addTiles() %>%
  addPolylines(data=rutas)
geoS <- 'WFS:https://wms.ign.gob.ar/geoserver/ows?service=wfs&version=1.1.0&request=GetCapabilities'
capaDeptos <- 'ign:departamento'

dptos <- st_read(geoS, capaDeptos)
## Reading layer `ign:departamento' from data source 
##   `WFS:https://wms.ign.gob.ar/geoserver/ows?service=wfs&version=1.1.0&request=GetCapabilities' 
##   using driver `WFS'
## Simple feature collection with 529 features and 9 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -74 ymin: -90 xmax: -25 ymax: -21.78086
## Geodetic CRS:  WGS 84
#leaflet() %>% 
#  addTiles() %>%
#  addPolygons(data = dptos, color = "blue") %>%
#  addPolylines(data=rutas, color = "red")


dptos <- dptos%>%
  filter(fdc == "IDE Catamarca")

leaflet() %>% 
  addTiles() %>%
  addPolygons(data = dptos, color = "blue") %>%
  addPolylines(data=rutas, color = "red")
rutasCat <- st_intersection(dptos, rutas)

leaflet() %>% 
  addTiles() %>%
  addPolygons(data = dptos, color = "blue") %>%
  addPolylines(data=rutasCat, color = "red")
rutasCat$FNA <- factor(rutasCat$FNA)

levels(rutasCat$FNA)
## [1] "RN 0038" "RN 0040" "RN 0060" "RN 0064" "RN 0065" "RN 0079" "RN 0157"
## [8] "RN 2V40"
nlevels(rutasCat$FNA)
## [1] 8
pal1 <- colorFactor(
  palette = "Dark2", 
  domain = rutasCat$FNA
)

leaflet() %>% 
  addTiles() %>% 
  addPolylines(data = rutasCat, color = ~pal1(FNA), label = ~FNA)
table(rutasCat$FNA)
## 
## RN 0038 RN 0040 RN 0060 RN 0064 RN 0065 RN 0079 RN 0157 RN 2V40 
##       8       6      10       2       1       6       2       2
rutasCat$longitudTramo <- st_length(rutasCat$geom)

longitud <- rutasCat%>%
  group_by(FNA)%>%
  summarise( longitud = sum( longitudTramo ))

longitud
## Simple feature collection with 8 features and 2 fields
## Geometry type: GEOMETRY
## Dimension:     XY
## Bounding box:  xmin: -68.29858 ymin: -29.72005 xmax: -64.86588 ymax: -26.60038
## Geodetic CRS:  WGS 84
## # A tibble: 8 × 3
##   FNA         longitud                                                      geom
##   <fct>            [m]                                            <GEOMETRY [°]>
## 1 RN 0038  289026.     MULTILINESTRING ((-66.28208 -28.89079, -66.28157 -28.890…
## 2 RN 0040  542714.     MULTILINESTRING ((-67.08847 -28.28971, -67.08865 -28.289…
## 3 RN 0060 1045281.     MULTILINESTRING ((-65.71936 -29.32455, -65.71936 -29.324…
## 4 RN 0064  111972.     MULTILINESTRING ((-65.11213 -28.19262, -65.1122 -28.1926…
## 5 RN 0065       0.0272     LINESTRING (-65.97023 -27.34569, -65.97023 -27.34569)
## 6 RN 0079   29749.     MULTILINESTRING ((-65.58979 -29.72005, -65.58975 -29.719…
## 7 RN 0157  184904.     MULTILINESTRING ((-64.92045 -29.51093, -64.9248 -29.5053…
## 8 RN 2V40   13748.     MULTILINESTRING ((-67.15725 -27.71829, -67.15697 -27.718…
longitud <- st_drop_geometry(longitud)

longitud
## # A tibble: 8 × 2
##   FNA         longitud
## * <fct>            [m]
## 1 RN 0038  289026.    
## 2 RN 0040  542714.    
## 3 RN 0060 1045281.    
## 4 RN 0064  111972.    
## 5 RN 0065       0.0272
## 6 RN 0079   29749.    
## 7 RN 0157  184904.    
## 8 RN 2V40   13748.
arrange(longitud, -longitud )
## # A tibble: 8 × 2
##   FNA         longitud
##   <fct>            [m]
## 1 RN 0060 1045281.    
## 2 RN 0040  542714.    
## 3 RN 0038  289026.    
## 4 RN 0157  184904.    
## 5 RN 0064  111972.    
## 6 RN 0079   29749.    
## 7 RN 2V40   13748.    
## 8 RN 0065       0.0272
pr <- st_union(dptos)

leaflet() %>% 
  addTiles() %>% 
  addPolylines(data = rutasCat, color = ~pal1(FNA), label = ~FNA) %>%
  addPolygons(data = pr)
geoIGN <- "WFS:https://wms.ign.gob.ar/geoserver/ows?service=wfs&version=1.1.0&request=GetCapabilities"
layer1 <- "ign:localidad_bahra"

ciudades <- st_read(geoIGN, layer1)
## Reading layer `ign:localidad_bahra' from data source 
##   `WFS:https://wms.ign.gob.ar/geoserver/ows?service=wfs&version=1.1.0&request=GetCapabilities' 
##   using driver `WFS'
## Simple feature collection with 3528 features and 18 fields
## Geometry type: MULTIPOINT
## Dimension:     XY
## Bounding box:  xmin: -72.88591 ymin: -54.8074 xmax: -53.64673 ymax: -21.8768
## Geodetic CRS:  WGS 84
ciudades <- ciudades%>%
  filter(nom_pcia == "Catamarca")

ej <- st_intersection(ciudades, pr)


bufR <- st_buffer(rutasCat, 1000)


leaflet() %>% 
  addTiles() %>% 
  addPolylines(data = rutasCat, color = ~pal1(FNA), label = ~FNA) %>%
  addPolygons(data = bufR, color = "red")%>%
  addPolygons(data = pr)%>%
  addMarkers(data = ej)
ciudadesRutas <- st_intersection(bufR, ej)


leaflet() %>% 
  addTiles() %>% 
  addPolylines(data = rutasCat, color = ~pal1(FNA), label = ~FNA) %>%
  addPolygons(data = bufR, color = "red")%>%
  addPolygons(data = pr)%>%
  addMarkers(data = ciudadesRutas)