VIS-2129-F2020 / svoorhees-vis

0 stars 0 forks source link

Stuck on Icochrone Error #4

Closed sage-grey-voorhees closed 3 years ago

sage-grey-voorhees commented 4 years ago

Hi! Im trying to use the tidyGeocoder to make an Isochrone around a point (trying to look at grocery stores In Mattapan).I've been using the Friday discussion code as an example. I keep getting the following error in lines of code 155-160:

Error in curl::curl_fetch_memory(url, handle = handle) : Failed to connect to localhost port 8080: Connection refused.

I've tried restarting R and Java is installed, all my other isocrhrones work. I've downloaded the Boston Street Maps, so I don't think it is an error of using Cambridge's data.

I know that this is an error that some people ran into during Friday's section, but I cant reach anyone and I cant seem to find the answer online.

https://ses-5215-f2020.github.io/svoorhees-quant/OpenTransitMap_ass5.Rmd

For various (but unimportant) reasons this file is in my Quant GitHub (that's accidentally where I put my OTP file structures), if you need me to move it over to VIS, I can move that over. I'm also thinking that this might be the source of my problems (but why would all the other isochrones work?)

bauranov commented 4 years ago

Hi Sage, The error arises because R lost connection to Open Trip Planner. In line 76, you close the connection by executing otp_stop(). When you try to get isochrones later in your code, functions otp_something don't work because R isn't connected to OTP anymore. Move otp_stop() to the end of your code and it should work.

sage-grey-voorhees commented 4 years ago

Okay! Great, I moved that to line 171. And now I am getting this error in the same chunk:

Failed to get isochrone with error: org.opentripplanner.routing.error.VertexNotFoundException: vertices not found: [from] vertices not found: [from]

bauranov commented 4 years ago

Try adding the coordinates manually c(number, number) instead of c(A$long, A$lat), or round A$long, A$lat to five decimal points. When I run the following code it works.

point_A_10min_walk <- otp_isochrone(otpcon = otpcon, fromPlace = c(-71.09512, 42.2682), mode = "WALK", cutoffSec = 600)

Something is wrong with the number of decimal points. Point_A$lat is saved as 42.268204 (print() rounds it to 5 decimal places, so you see it as 42.2682). When I add point_A$lat, or 42.268204 to fromPlace, it doesn't work. But when I try any of the following: 42.2682, 42.268201, 42.268202, 42.268203, 42.268205, 42.268206, they all work! You found a glitch in the matrix.

sage-grey-voorhees commented 3 years ago

Hmmm... I just tried this and it doesn't seem to fix the error.

It's not creating the variable/dataframe in my environment, and I'm still getting the message: "Failed to get isochrone with error: org.opentripplanner.routing.error.VertexNotFoundException: vertices not found: [from] vertices not found: [from]"

sage-grey-voorhees commented 3 years ago

Still stuck on same area of code. I think it has something to do with the Boston_Streets OSM file. I'm able to build isochrones with the cambridge data, but not with the boston_streets data. (I've tried from a KML file and from a geocoded address).

For both, I'm getting the error:

Failed to get isochrone with error: org.opentripplanner.routing.error.VertexNotFoundException: vertices not found: [from] vertices not found: [from]

bauranov commented 3 years ago

In line 151, it looks like you downloaded the Cambridge network and saved it as boston_streets, which could be the reason the Boston data doesn't work. Change bbox = 'Cambridge MA USA' to bbox = 'Boston MA USA') and see if it runs properly.

RAN ONCE: opq(bbox = 'Cambridge MA USA') %>% add_osm_feature(key = 'highway') %>% osmdata_xml(file = 'OTP/graphs/default/boston_streets.osm')

sage-grey-voorhees commented 3 years ago

Hi!

I tried the above fix and was still not able to get it to work. I worked with Marissa to try to figure out if I had a bug with Java or if it was coming from OTP (for example Julia and Marissa said they needed to Close OTP before opening a new one for a new geographic area). I haven't tried downloading Java again (because It says I have most recently updated and I dont know what I would download instead).

All to say, I'm still really stuck:

  1. When I'm using the Cambridge Data, I can't get my isochrones to work, but some (not all) of the isochrones from Carole's code seem to be working fine.

  2. When I'm using Boston Data, I can't get any isochrones to work. I'm trying both from geocoded addresses and a KML file. I can't seem to even get the roads to plot anymore (although they used to, so now I'm wierded out).

The errors I get seem to change a bit, but they generally are either: 2020-10-08 13:17:54 OTP is ready to use Go to localhost:8080 in your browser to view the OTP Router http://localhost:8080/otp/routers/default exists

OR

Error in curl::curl_fetch_memory(url, handle = handle): Operation was aborted by an application callback Request failed [ERROR]. Retrying in 1.7 seconds...

Could either of you take a look at what might be happening? Quite possible that it's obvious!

Thanks, Sage

c-voulgaris commented 3 years ago

A few issues with your Cambridge code (I started writing this before we spoke, just posting it here to close the issue.

Add this after line 118.

st_transform(crs = MA_state_plane) %>%
mutate(mode = "walk")` 

Change line 126 to iso_all_modes_school <- rbind(iso_5min_drive_school, iso_5min_walk_school)