Accessibility, in simple terms, is how fast/far one must go to get to a certain place
Accessibility impacts health since most things having to do with a healthy life style has to do with accessibility.
There are distinct differences in health and life expectancy between social groups, towns and neighborhoods in towns.
There is no clear sense of what measures accessibility.
The purpose of the study: creating a new holistic accessibility measure.
We aim to improve on previous measures by creating a holistic all-inclusive accessibility measure which will incorporate multiple variables which are normally analyzed separately
The study area is greater Boston:
The streets layer was pre-processed using the Planerize Lines tool in ArcGIS in order to split lines at all intersections.
The roads were further split to allow origin and destination nodes to connect with the network, using the Split Line at Point tool in ArcGIS.
To find where to split, we used the snapPointsToLines function (package maptools) in R, for example:
snapPointsToLines(
points = orig,
lines = sl,
withAttrs = FALSE
)
Origin and destination points that are >280 m from the nearest road were removed.
The processed line layer was converted to a “network” object (class SpatialLinesNetwork, package stplanr).
sl = as(sl, "Spatial")
sln = SpatialLinesNetwork(sl)
# Define weights
sln@sl$length_km = SpatialLinesLengths(sln@sl)
sln@sl$time_h = sln@sl$length_km / sln@sl$speed_kmh
E(sln@g)$weight = sln@sl$time_h
sln@weightfield = "time_h"
sln@sl
## Simple feature collection with 291196 features and 15 fields
## geometry type: LINESTRING
## dimension: XY
## bbox: xmin: -71.61874 ymin: 41.89704 xmax: -70.63903 ymax: 42.7226
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
## First 10 features:
## OBJECTID FULLNAME RTTYP MTFCC Shape_Leng speed_kmh
## 1 103007 State Rte 9 S S1200 0.26876997 104
## 2 111017 Boston Worcester Tpke M S1200 0.26763102 104
## 3 111536 Turnpike Rd M S1200 0.16620237 104
## 4 92620 Hundreds Rd M S1400 0.01432285 88
## 5 92620 Hundreds Rd M S1400 0.01432285 88
## 6 103007 State Rte 9 S S1200 0.26876997 104
## 7 111017 Boston Worcester Tpke M S1200 0.26763102 104
## 8 111536 Turnpike Rd M S1200 0.16620237 104
## 9 99017 State Rte 9 S S1200 0.26885250 104
## 10 103208 Turnpike Rd M S1200 0.16651601 104
## geometry id crime lan dens
## 1 LINESTRING (-71.59387 42.28... 1 0.03367609 0.01169225 0.0001769729
## 2 LINESTRING (-71.59387 42.28... 2 0.03367609 0.01169225 0.0001769729
## 3 LINESTRING (-71.59387 42.28... 3 0.03367609 0.01169225 0.0001769729
## 4 LINESTRING (-71.58981 42.28... 4 0.03367609 0.01169225 0.0001769729
## 5 LINESTRING (-71.59143 42.28... 5 0.03367609 0.01169225 0.0001769729
## 6 LINESTRING (-71.59116 42.28... 6 0.03367609 0.01169225 0.0001769729
## 7 LINESTRING (-71.59116 42.28... 7 0.03367609 0.01169225 0.0001769729
## 8 LINESTRING (-71.59116 42.28... 8 0.03367609 0.01169225 0.0001769729
## 9 LINESTRING (-71.59197 42.28... 9 0.03367609 0.01169225 0.0001769729
## 10 LINESTRING (-71.59197 42.28... 10 0.03367609 0.01169225 0.0001769729
## speed_kmh1 length length_km time_h time_h1
## 1 101.69527 237.2447 [m] 0.2372447 0.002281199 0.002332898
## 2 101.69527 237.2447 [m] 0.2372447 0.002281199 0.002332898
## 3 101.69527 237.2447 [m] 0.2372447 0.002281199 0.002332898
## 4 86.04985 152.6427 [m] 0.1526427 0.001734576 0.001773887
## 5 86.04985 262.3491 [m] 0.2623491 0.002981239 0.003048803
## 6 101.69527 178.4970 [m] 0.1784970 0.001716318 0.001755215
## 7 101.69527 178.4970 [m] 0.1784970 0.001716318 0.001755215
## 8 101.69527 178.4970 [m] 0.1784970 0.001716318 0.001755215
## 9 101.69527 527.0206 [m] 0.5270206 0.005067506 0.005182351
## 10 101.69527 527.0206 [m] 0.5270206 0.005067506 0.005182351
sln@g
## IGRAPH 89ac23c U-W- 209873 291196 --
## + attr: x (g/n), y (g/n), n (g/n), weight (e/n)
## + edges from 89ac23c:
## [1] 1-- 2 1-- 2 1-- 2 3-- 4 2-- 4 2-- 5 2-- 5 2-- 5 6-- 7 6-- 7
## [11] 6-- 7 8-- 9 9--10 11--12 10--12 5--13 5--13 5--13 13--14 12--14
## [21] 7--13 12--15 15--16 16--17 17--18 17--19 18--20 20--21 20--21 15--22
## [31] 16--22 19--23 23--24 18--24 13--25 13--25 13--25 22--25 25--26 25--26
## [41] 25--26 23--26 7--27 7--27 7--27 27--28 27--28 27--28 28--29 30--31
## [51] 20--31 26--32 26--32 26--32 30--33 33--34 30--35 35--36 35--37 32--38
## [61] 32--39 32--39 32--39 28--40 28--40 28--40 40--41 42--43 38--42 40--44
## [71] 40--44 40--44 45--46 44--47 48--49 47--50 51--52 53--54 51--55 39--55
## + ... omitted several edges
# Rescale
sl$crime = rescale(sl$crime, c(0, 0.1))
sl$lan = rescale(sl$lan, c(0, 0.1))
sl$dens = rescale(sl$dens, c(0, 0.1))
# 'speed_kmh' reduction
sl$speed_kmh1 = sl$speed_kmh +
(-sl$speed_kmh * sl$crime) +
(sl$speed_kmh * sl$lan) +
(-sl$speed_kmh * sl$dens)
orig_nodes = find_network_nodes(sln, coordinates(orig), maxdist = 1000)
dest_nodes = find_network_nodes(sln, coordinates(dest), maxdist = 1000)
# Current origin
i = 100
# Filter kNN
b = st_nn(orig[i, ], dest, k = 100)
sel = b[[1]]
dest_nodes1 = dest_nodes[sel]
dest_nodes1
## 585 586 590 584 10501 6156 4920 10508 6154 582
## 133246 133246 133226 133248 133238 133222 133229 132810 133266 133266
## 6155 583 581 9458 10498 10507 10503 10496 10490 10514
## 133266 133266 133274 133266 133272 133221 133221 133221 133221 133262
## 5047 10500 10512 10504 6153 595 10506 10502 10492 10493
## 133268 177349 133221 133221 133261 134786 177350 133261 133261 133260
## 10497 10510 10494 598 6159 4893 594 588 589 6160
## 133260 133260 133252 177140 177140 177140 177148 134567 134567 177122
## 10499 10511 596 9497 6151 579 5050 4850 580 6152
## 134616 134616 177149 134561 134613 134613 134605 133337 133338 133338
## 603 4620 10491 575 10987 610 572 571 14239 576
## 178186 178134 133830 133423 140749 178378 134721 133726 137404 137404
## 10509 573 10495 10513 578 6150 614 22660 10372 22604
## 134271 134269 134271 134269 137358 133719 178327 177973 178286 4498
## 10388 611 10373 617 619 618 10393 10386 10365 10361
## 4498 178073 177905 178058 4505 4505 4505 4505 4505 4505
## 6168 616 577 612 10363 6148 568 10371 569 620
## 4506 4266 134204 177948 3368 134029 134029 3369 134026 3402
## 613 10391 6169 621 1078 10505 560 6149 626 10385
## 178347 3362 4415 4237 178853 131999 132564 131988 4520 4520
# Get times
path = sum_network_routes(
sln = sln,
start = rep(orig_nodes[i], length(dest_nodes1)),
end = dest_nodes1,
sumvars = sln@weightfield
)
path = st_sf(as.data.frame(path))
path
## Simple feature collection with 100 features and 3 fields
## geometry type: LINESTRING
## dimension: XY
## bbox: xmin: -71.47423 ymin: 42.15713 xmax: -71.36765 ymax: 42.25576
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
## First 10 features:
## ID sum_time_h pathfound geometry
## 1 1 0.000557977 TRUE LINESTRING (-71.42518 42.20...
## 2 2 0.000557977 TRUE LINESTRING (-71.42518 42.20...
## 3 3 0.010180771 TRUE LINESTRING (-71.42518 42.20...
## 4 4 0.006286281 TRUE LINESTRING (-71.42518 42.20...
## 5 5 0.004489996 TRUE LINESTRING (-71.42518 42.20...
## 6 6 0.005034971 TRUE LINESTRING (-71.42518 42.20...
## 7 7 0.006620409 TRUE LINESTRING (-71.42518 42.20...
## 8 8 0.007795520 TRUE LINESTRING (-71.42518 42.20...
## 9 9 0.007365154 TRUE LINESTRING (-71.42518 42.20...
## 10 10 0.007365154 TRUE LINESTRING (-71.42518 42.20...
path[order(path$sum_time_h), ]
## Simple feature collection with 100 features and 3 fields
## geometry type: LINESTRING
## dimension: XY
## bbox: xmin: 295630.7 ymin: 4670034 xmax: 304608.5 ymax: 4681027
## epsg (SRID): 32619
## proj4string: +proj=utm +zone=19 +datum=WGS84 +units=m +no_defs
## First 10 features:
## ID sum_time_h pathfound geometry
## 1 1 0.000557977 TRUE LINESTRING (299791.8 467537...
## 2 2 0.000557977 TRUE LINESTRING (299791.8 467537...
## 5 5 0.004489996 TRUE LINESTRING (299791.8 467537...
## 6 6 0.005034971 TRUE LINESTRING (299791.8 467537...
## 13 13 0.006217200 TRUE LINESTRING (299791.8 467537...
## 4 4 0.006286281 TRUE LINESTRING (299791.8 467537...
## 7 7 0.006620409 TRUE LINESTRING (299791.8 467537...
## 15 15 0.007037070 TRUE LINESTRING (299791.8 467537...
## 9 9 0.007365154 TRUE LINESTRING (299791.8 467537...
## 10 10 0.007365154 TRUE LINESTRING (299791.8 467537...
Parallel processing using foreach:
min_time = foreach(i = 1:length(orig_nodes), .combine = c) %dopar% {
...
}