temospena / Rnotebook

a compilation of R chunks
http://web.tecnico.ulisboa.pt/~rosamfelix/r/COMPILACAO.html
1 stars 0 forks source link

Geocode e routing com Gmaps #5

Open temospena opened 4 years ago

temospena commented 4 years ago

melhorar o capítulo do geocoding

acrescentar o geocode do DV

alerta para remover os que têm O=D quando se exporta a shp para correr o ORS tools no QGIS!

temospena commented 4 years ago

Adicionar o Cyclestreets na parte da bicicleta, com um exemplo do tipo de resultados que retribui https://www.rdocumentation.org/packages/cyclestreets/versions/0.1.5

temospena commented 4 years ago

Adicionar link para a comparação entre o HereR e o Google Maps http://web.tecnico.ulisboa.pt/~rosamfelix/gis/geocode/geocodeHereGmaps.html

temospena commented 1 year ago

Example with ors_directions()

ROUTES = data.frame() # initial empty data frame

# loop - the origin (i) is the survey location, and the IST is always the same destination
for (i in 1:nrow(SURVEYsample)){
ROUTES1 = ors_directions(
  data.frame(lon = c(SURVEYsample$coordinates[i,1], IST$coordinates[1,1]),
             lat = c(SURVEYsample$coordinates[i,2], IST$coordinates[1,2])),
  profile = "foot-walking", # driving-car or other
  preference = "fastest",
  output = "sf"
)
ROUTES = rbind(ROUTES, ROUTES1) # to keep adding in the same df
}
temospena commented 11 months ago

example of ors_isochrones(), but ignoring the ones with errors:

ISOCist = data.frame() # initial empty data frame

for (i in 1:nrow(coor)) {
  ISOCist_i =
  tryCatch(
  ors_isochrones(
    coor[i, ],
    profile = "foot-walking",
    range_type = "time", # or distance
    range = 20*60, # 20 minutes in seconds
    interval = 5*60, # to have intervals of 5 minutes
    output = "sf"
  ), 
  error=function(e){cat("Error: Openrouteservice API request failed")} # trick to ignore the ones that return errors
  )
  ISOCist = rbind(ISOCist, ISOCist_i)
}