Skip to content

Commit fd59f5e

Browse files
committed
readmeup
1 parent ff3942c commit fd59f5e

File tree

2 files changed

+65
-32
lines changed

2 files changed

+65
-32
lines changed

README.md

Lines changed: 65 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ You can install the development version of GreenExp from [GitHub](https://github
3838
For Windows installation, please install R-tools from (https://cran.r-project.org/bin/windows/Rtools/) before running the code below
3939

4040
``` r
41-
# install.packages("devtools")
41+
# install.packages("devtools") # do it once
4242
devtools::install_github("Spatial-Data-Science-and-GEO-AI-Lab/GreenExp_R", dependencies = TRUE)
4343

4444
```
@@ -65,6 +65,7 @@ library(GreenExp) # If not loaded yet
6565
library(magrittr) # If not loaded yet (used for piping %>%)
6666
library (sf) #Need for most spatial operation
6767
library (sfheaders) #for additional functions to work with sf package
68+
library(tmaptools) #do some geo-coding for OSM
6869

6970
```
7071
Please note that the examples based on this data serves as an illustration, and you may need to adapt the parameters and function usage to match your specific scenario.
@@ -330,58 +331,92 @@ In this example, the accessibility function is applied using the default setting
330331

331332
``` r
332333
#Get the location bounding box to extrat data from OSM
333-
getcityboudingbox <- tmaptools::geocode_OSM("Centrum, Amsterdam", as.sf = T, geometry = c("bbox"))
334+
getcityboudingbox <- tmaptools::geocode_OSM("Centrum, Amsterdam", as.sf = T, geometry = c("bbox"))
334335

335-
#download building data, it may take 2-3 min, as there are about 25k buildings in this area
336+
#download building data, it may take 1-2 min, as there are about 25k buildings in this area
336337
buildings <- osmdata::opq(sf::st_bbox(getcityboudingbox)) %>%
337338
osmdata::add_osm_feature(key = "building") %>%
338339
osmdata::osmdata_sf()
339340

340341
#get the building footprint
341342
buildings <- buildings$osm_polygons
342343

343-
#select random 1000 building, as distance calcuation is takes longer time, we first test on smaller smaple
344-
randombuildings <- buildings %>% dplyr::sample_n (1000)
345-
346-
#let us run the Euclidan distance based accessibility
347-
348-
building_access_E <- GreenExp::greenspace_access(randombuildings, buffer_distance = 300)
344+
#let us run the Euclidan distance based accessibility, here we are only considering greenspace with size at least 400 m2 or 0.4 ha (based on WHO guideline)
345+
building_access_E <- GreenExp::greenspace_access(buildings, buffer_distance = 300, epsg_code= 28992, minimum_greenspace_size = 400)
349346

347+
#join the access calcuation result to building polygons for mapping
348+
#First reproject to match the projection with random building projection
349+
building_access_E <- sf::st_transform(building_access_E, sf::st_crs(buildings))
350350

351-
#if buildings take a long time for your study area try the function using random points
352-
#generate random points within the bounding box
353-
#RandomPoints <- sf::st_sample(getcityboudingbox, size = 1000) %>% st_as_sf()
354-
#use these points to run the access function
351+
#spatially join them
352+
building_access_Ej <- sf::st_join (buildings, building_access_E, join= st_intersects) %>% dplyr::select(closest_greenspace, UID, greenspace_in_300m_buffer)
355353

356-
```
357-
<img src="man/figures/access_euc_cen.png" alt="Image" width="500" />
354+
#map the result
355+
mapview::mapview(building_access_Ej, zcol = "closest_greenspace")
358356

357+
#aslo can check the summary statistics
358+
summary(building_access_Ej$closest_greenspace)
359+
#the result in this case:
360+
# Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
361+
# 0.0001 55.6769 95.7925 115.9649 154.5281 518.5266 251
362+
363+
#for summary of how many building has greenspace within 300m of Euclidian distance
364+
summary(building_access_Ej$greenspace_in_300m_buffer)
365+
#the result in this case was
366+
#Mode FALSE TRUE NA's
367+
#logical 2756 22884 251
359368

369+
#out of 25891 building 22884 (about 90%) has access to greenspace (size 0.4 ha/ 400m2) within 300m!
360370

371+
```
372+
The outcome map shows in the figure below. Clearly most buildings has greenspace nearly within 100m
373+
<img src="man/figures/3_Access_Eucld.png" alt="Image" width="1000" />
361374

362375
---
363376

364-
365377
---
366378

367379
**Example 2: Network Distance to Pseudo Entrances**
368380

369-
In this example, the accessibility function considers network distance to the pseudo entrances of the greenspaces. The pseudo entrances are created by buffering the greenspace polygons and intersecting them with the network nodes. The function calculates the network distance from the address location to the nearest pseudo entrance point. The figure below presents an example in Amsterdam, where the parks are shown as green polygons. The blue lines indicate the euclidean distance from the address location to the nearest park centroid. The park centroids are depicted as black points, and the address location is represented by a red point. Additionally, you may observe multiple pseudo entrances within the parks, as roads passing through the parks can also serve as potential entrance points.
381+
In this example, the accessibility function considers network distance to the pseudo entrances of the greenspaces. The pseudo entrances are created by buffering the greenspace polygons and intersecting them with the network nodes. The function calculates the network distance from the address location to the nearest pseudo entrance point.
370382

371383
```r
372-
GreenExp::greenspace_access(df_point_access, buffer_distance=300,
373-
euclidean = F, pseudo_entrance = T)
374-
375-
# Simple feature collection with 1 feature and 3 fields
376-
# Geometry type: POINT
377-
# Dimension: XY
378-
# Bounding box: xmin: 123603.6 ymin: 487073.4 xmax: 123603.6 ymax: 487073.4
379-
# Projected CRS: Amersfoort / RD New
380-
# UID closest_greenspace greenspace_in_300m_buffer geometry
381-
# 1 1 230.747 TRUE POINT (123603.6 487073.4)
384+
385+
#let us run the Street network distance based accessibility for same building, keep in mind this will take more time to run
386+
# while running the function will show how much time will be needed to complate the calculation!
387+
# The following line takes about 1 hr to complete On a Windows i7 laptop, with 32GB ram
388+
# to test the function, we recommend you use a small smaple locations (e.g., around 1000 buildings)
389+
390+
#for road network distance
391+
building_access_Net <- GreenExp::greenspace_access(buildings, buffer_distance = 300, euclidean = FALSE, pseudo_entrance = T, epsg_code= 28992, minimum_greenspace_size = 400)
392+
393+
#join the access calcuation result to building polygons for mapping
394+
#First reproject to match the projection with random building projection
395+
building_access_Net <- sf::st_transform(building_access_Net, sf::st_crs(buildings))
396+
397+
#spatially join them
398+
building_access_Netj <- sf::st_join (buildings, building_access_Net, join= st_intersects) %>% dplyr::select(closest_greenspace, UID, greenspace_in_300m_buffer)
399+
400+
#map the results of both if you want to see together
401+
mapview::mapview(building_access_Netj, zcol = "closest_greenspace") + mapview::mapview(building_access_Ej, zcol = "closest_greenspace")
402+
403+
404+
#the summary statistics for shortest network distance
405+
summary(building_access_Netj$closest_greenspace)
406+
407+
#in this case the result was:
408+
#Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
409+
# 0.00 48.17 139.81 183.46 250.11 27532.22 2454
410+
411+
#for summary of how many building has greenspace within 300m of Euclidian distance
412+
summary(building_access_Netj$greenspace_in_300m_buffer)
413+
414+
#in this case the result was:
415+
#Mode FALSE TRUE NA's
416+
#logical 2203 23437 251
417+
382418
```
383419

384-
<img src="man/figures/access_net_pse.png" alt="Image" width="500" />
385420

386421

387422

@@ -401,8 +436,6 @@ no-visible and 1 = visible area.
401436
For a better explanation, go to the [GVI](https://github.com/STBrinkmann/GVI) package.
402437

403438

404-
405-
406439
```r
407440
# Read in the digital eleveation model
408441
GS <- terra::rast('data/GS_AMS.tif')
@@ -608,14 +641,14 @@ FLIBS = -L/opt/homebrew/Cellar/gcc/13.1.0/lib/gcc/13
608641
| [**tidyr**](https://cran.r-project.org/package=tidyr) | Changing the shape and hierarchy of a dataset |
609642
| [**Rcpp**](https://cran.r-project.org/package=Rcpp) | R and C++ integration |
610643
| [**progress**](https://cran.r-project.org/package=progress) | Make a progress bar in loops |
611-
| [**GVI**](https://doi.org/10.1016/j.scitotenv.2020.143050) | information about the calculation of the visiblity |
644+
| [**GVI**](https://doi.org/10.1016/j.scitotenv.2020.143050) | information about the calculation of the visibility |
612645

613646

614647

615648

616649
## Acknowledgements and contact
617650

618-
Project made in collaboration with Dr. SM Labib from the Department of Human Geography and Spatial Planning at Utrecht University. This is a project of the Spatial Data Science and Geo-AI Lab.
651+
Project conducted user the supervision and in collaboration with Dr. SM Labib from the Department of Human Geography and Spatial Planning at Utrecht University. This is a project of the Spatial Data Science and Geo-AI Lab at Utrecht University.
619652

620653
| Name | Email |
621654
|-------------|-----------------------------|

man/figures/3_Access_Eucld.png

11.4 MB
Loading

0 commit comments

Comments
 (0)