0

I am trying to plot an isochrone map based on the locations of some convenience stores. Been searching on different methods (and I'm open to changing it) but for now I am working with dodgr.

q = opq(bbox = c(-103.78,19.2, -103.65, 19.31 )) %>% 
add_osm_feature(key = "highway")
osm_sc <- osmdata_sc(q = q)

I am not sure on how to share the points layer but it is a class sf

class(kiosko_sf) [1] "sf" "data.frame"

graph_motorcar <- weight_streetnet(osm_sc, wt_profile = "motorcar")

tlim <- c (5, 10, 20, 30, 60) * 60 
x <- dodgr_isochrones (graph_motorcar, from = kiosko_sf, tlim)

I am pretty sure my mistake is with that layer, as I don't fully understand what type of object should be passed to the from argument. I get the following error:

Error in get_pts_index(graph, gr_cols, vert_map, pts) : Unable to determine geographical coordinates in from/to

How could I fix this? or could you recommend an alternative to using dodgr_isochrones?

Pep
  • 33
  • 6
  • Would you share the part how you create kiosko_sf object? – Grzegorz Sapijaszko Jan 22 '22 at 21:47
  • I downloaded it from this site https://www.inegi.org.mx/app/mapa/denue/default.aspx and the transformed to a more suitable crs (EPSG: 4486) `kiosko_sf <- st_read("data/shp/INEGI_DENUE_kiosko.shp", options="ENCODING=latin1")` – Pep Jan 23 '22 at 01:02
  • 1
    as `dodgr_isochrones` expects a matrix instead of `geometry`, you can convert geometry points with `st_coordinates` like `x <- dodgr_isochrones (graph, from = sf::st_coordinates(kiosko_sf$geometry), tlim)` – Grzegorz Sapijaszko Jan 23 '22 at 12:12
  • I ended up doing this `from <- kiosko_sf %>% ` ` select(longitud, latitud) %>% ` ` st_drop_geometry()` But obviously your approach is cleaner. Now I have another problem... how to map the results? I tried with: `iso <- st_as_sf(x, coords=c("x","y")) ` `polys <- iso %>% dplyr::group_by(tlim) %>% dplyr::summarise() %>% st_cast("POLYGON") %>% st_convex_hull()` But the hull is created with all the points taken into account so when I have very far apart points, the area in between ends up being filled also. – Pep Jan 23 '22 at 19:13

0 Answers0