From de42f72acbf8d0f9603e58f1aaab63fd0dd90ba7 Mon Sep 17 00:00:00 2001 From: Jonathan Bishop Date: Wed, 9 Aug 2023 19:32:38 +0100 Subject: [PATCH 1/4] Update function_export_AHgen.R Changed xlsx to writexl::write_xlsx --- R/function_export_AHgen.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/function_export_AHgen.R b/R/function_export_AHgen.R index 0a5ad9c..983afc6 100644 --- a/R/function_export_AHgen.R +++ b/R/function_export_AHgen.R @@ -89,10 +89,10 @@ export_AHgen <- function(output, filenameXLSX <- filenameTimestamp(prefix = prefixXLSX, extension = ".xlsx") - outputXLSX %>% xlsx::write.xlsx(filenameXLSX) + outputXLSX %>% writexl::write_xlsx(filenameXLSX) message(paste0("Files saved as: ")) message(paste0("\n\t", filenameXLSX)) } -} \ No newline at end of file +} From af8409aa5e156bd24bea87c584ad584d1cea8ceb Mon Sep 17 00:00:00 2001 From: Jonathan Bishop Date: Wed, 9 Aug 2023 19:33:17 +0100 Subject: [PATCH 2/4] Update DESCRIPTION --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 214f570..c769e74 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,5 +31,5 @@ Depends: sf, tidytext, vctrs, - xlsx, - R (>= 4.3.1) \ No newline at end of file + writexl, + R (>= 4.3.1) From 122c3ba74051816c78ab086162464d5f9820482f Mon Sep 17 00:00:00 2001 From: Jonathan Bishop Date: Wed, 9 Aug 2023 19:34:05 +0100 Subject: [PATCH 3/4] Update Vignette 7A - Application - Generate template Urban Systems Abstraction Hierarchy.Rmd --- ... Generate template Urban Systems Abstraction Hierarchy.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vignettes/Vignette 7A - Application - Generate template Urban Systems Abstraction Hierarchy.Rmd b/vignettes/Vignette 7A - Application - Generate template Urban Systems Abstraction Hierarchy.Rmd index 22249fe..7784528 100644 --- a/vignettes/Vignette 7A - Application - Generate template Urban Systems Abstraction Hierarchy.Rmd +++ b/vignettes/Vignette 7A - Application - Generate template Urban Systems Abstraction Hierarchy.Rmd @@ -181,7 +181,7 @@ USAH_template_baseline %>% # If subnetwork assignment has been updated, write out to .xlsx for future use USAH_template_baseline$vInfo %>% - write.xlsx( + writexl::write_xlsx( filenameTimestamp( prefix = paste0(directory, name, "_", version, "_", location, "_", scenario, @@ -195,4 +195,4 @@ Next in [Vignette 7B - Application - Apply OSMtidy data](Vignette-7B---Applicati ## Last updated -This vignette is associated with `AHgen` v1.0.0, and was last updated by Melissa Bedinger on `r Sys.Date()`. \ No newline at end of file +This vignette is associated with `AHgen` v1.0.0, and was last updated by Melissa Bedinger on `r Sys.Date()`. From 62614a2913435ad42b75507507c14b1fd089367d Mon Sep 17 00:00:00 2001 From: Jonathan Bishop Date: Wed, 9 Aug 2023 19:35:24 +0100 Subject: [PATCH 4/4] Update Vignette-7A---Application---Generate-template-Urban-Systems-Abstraction-Hierarchy.html --- ...e-Urban-Systems-Abstraction-Hierarchy.html | 3990 ++++++++--------- 1 file changed, 1995 insertions(+), 1995 deletions(-) diff --git a/vignettes/Vignette-7A---Application---Generate-template-Urban-Systems-Abstraction-Hierarchy.html b/vignettes/Vignette-7A---Application---Generate-template-Urban-Systems-Abstraction-Hierarchy.html index f1a5373..0420caf 100644 --- a/vignettes/Vignette-7A---Application---Generate-template-Urban-Systems-Abstraction-Hierarchy.html +++ b/vignettes/Vignette-7A---Application---Generate-template-Urban-Systems-Abstraction-Hierarchy.html @@ -1,1995 +1,1995 @@ - - - - - - - - - - - - - - -Application - Generate template Urban Systems Abstraction Hierarchy - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
-
-
-
- -
- - - - - - - - -
-

In this vignette, you will go through the steps of generating a -template Urban Systems Abstraction Hierarchy in AHgen:

-
    -
  1. Prepare the environment
  2. -
  3. Read in the data
  4. -
  5. Check the data
  6. -
  7. Generate the template Urban Systems Abstraction Hierarchy
  8. -
  9. Export
  10. -
-

To navigate to other vignettes, go to Vignette 0 - Welcome to -AHgen.

-
-

1. Prepare the environment

-
# Clear the RStudio environment
-rm(list = ls()); cat("/014"); gc(verbose = TRUE)
-
-# CTRL + SHIFT + F10 will detach any loaded packages and restart R
-
-# Set the working directory to the folder where this script is saved
-setwd(dirname(rstudioapi::getSourceEditorContext()$path)); getwd()
-
-# If you are doing this for the first time
-
-# install the package pacman which checks to see if a package is installed
-# and if not it attempts to install the package from CRAN 
-# and/or any other repository in the pacman repository list
-
-# and install the package devtools which will allow you to download a package straight from GitHub 
-# i.e. if they are not yet on CRAN and/or the pacman repository list
-
-install.packages("devtools")
-install.packages("pacman")
-
-# Ensure latest version of AHgen is installed
-devtools::install_github("avisserquinn/AHgen", dependencies = TRUE)
-
-# If package has 'non-zero exit status', try re-installing devtools & rlang
-install.packages("devtools")
-install.packages("rlang")
-
-# Load required packages
-pacman::p_load(tidyverse, readxl, installr, janitor, vctrs, AHgen)
-
-
-

2. Read in the data

-
# Set name, version, location, and scenario
-AH_name = "USAH"
-AH_version = "3.0"
-AH_location = "template"
-AH_scenario = "baseline"
-
-# Set directory for outputs
-directory = "outputs/"
-
-# Read in template USAH adjacency matrix
-adjMat_template = 
-  read_adjMat("inputs/USAH_3.0_template_baseline_adjMat_20230602.xlsx")
-
-adjMat_template
-
## # A tibble: 483 × 487
-##    level levelName_full               levelName Node      Cultural heritage an…¹
-##    <dbl> <chr>                        <chr>     <chr>                      <dbl>
-##  1     1 Functional purposes          Purposes  Cultural…                      0
-##  2     1 Functional purposes          Purposes  Economic…                      0
-##  3     1 Functional purposes          Purposes  Globalis…                      0
-##  4     1 Functional purposes          Purposes  Knowledg…                      0
-##  5     1 Functional purposes          Purposes  Physical…                      0
-##  6     1 Functional purposes          Purposes  Pooling …                      0
-##  7     1 Functional purposes          Purposes  Safety a…                      0
-##  8     1 Functional purposes          Purposes  Social o…                      0
-##  9     2 Values and priority measures Outcomes  Collecti…                      1
-## 10     2 Values and priority measures Outcomes  Comprehe…                      0
-## # ℹ 473 more rows
-## # ℹ abbreviated name: ¹​`Cultural heritage and sense of place`
-## # ℹ 482 more variables: `Economic opportunity` <dbl>,
-## #   `Globalised connectivity` <dbl>,
-## #   `Knowledge transfer and diffusion of innovation` <dbl>,
-## #   `Physical settlement` <dbl>, `Pooling of resources` <dbl>,
-## #   `Safety and security` <dbl>, `Social opportunity and care` <dbl>, …
-
# Create template USAH vInfo (basic)
-vInfo_template = 
-  adjMat_template %>% select(level, levelName_full, levelName, Node)
-
-vInfo_template
-
## # A tibble: 483 × 4
-##    level levelName_full               levelName Node                            
-##    <dbl> <chr>                        <chr>     <chr>                           
-##  1     1 Functional purposes          Purposes  Cultural heritage and sense of …
-##  2     1 Functional purposes          Purposes  Economic opportunity            
-##  3     1 Functional purposes          Purposes  Globalised connectivity         
-##  4     1 Functional purposes          Purposes  Knowledge transfer and diffusio…
-##  5     1 Functional purposes          Purposes  Physical settlement             
-##  6     1 Functional purposes          Purposes  Pooling of resources            
-##  7     1 Functional purposes          Purposes  Safety and security             
-##  8     1 Functional purposes          Purposes  Social opportunity and care     
-##  9     2 Values and priority measures Outcomes  Collective identity and communi…
-## 10     2 Values and priority measures Outcomes  Comprehensive security and rule…
-## # ℹ 473 more rows
-
# Read in template USAH vInfo (full)
-vInfo_template_full = 
-  read_xlsx("inputs/USAH_3.0_template_baseline_vInfo-full_20230621.xlsx")
-
-vInfo_template_full
-
## # A tibble: 483 × 72
-##    level levelName_full        levelName colour_level_default Node  abbreviation
-##    <dbl> <chr>                 <chr>     <chr>                <chr> <chr>       
-##  1     1 Functional purposes   Purposes  #CCB1B9              Cult… NA          
-##  2     1 Functional purposes   Purposes  #CCB1B9              Econ… NA          
-##  3     1 Functional purposes   Purposes  #CCB1B9              Glob… NA          
-##  4     1 Functional purposes   Purposes  #CCB1B9              Know… NA          
-##  5     1 Functional purposes   Purposes  #CCB1B9              Phys… NA          
-##  6     1 Functional purposes   Purposes  #CCB1B9              Pool… NA          
-##  7     1 Functional purposes   Purposes  #CCB1B9              Safe… NA          
-##  8     1 Functional purposes   Purposes  #CCB1B9              Soci… NA          
-##  9     2 Values and priority … Outcomes  #607EBC              Coll… CICS        
-## 10     2 Values and priority … Outcomes  #607EBC              Comp… CSRL        
-## # ℹ 473 more rows
-## # ℹ 66 more variables: colour_node_default <chr>, colour_node_archived2 <chr>,
-## #   colour_node_archived1 <chr>, definition <chr>, reference <chr>,
-## #   UKspecific <chr>, health_wellbeing <chr>, economy_society <chr>,
-## #   infrastructure_ecosystems <chr>, leadership_strategy <chr>,
-## #   subnetwork_hazard_biological <chr>, subnetwork_hazard_cyberAttack <chr>,
-## #   subnetwork_hazard_drought <chr>, subnetwork_hazard_earthquake <chr>, …
-
# Read in OSMtidy-AHgen key for allocating OSMtidy descs to AHgen objects
-key = 
-  read_csv("inputs/OSM-AH-key_3.0_20230717.csv", show_col_types = FALSE)
-
-key
-
## # A tibble: 653 × 5
-##    desc                     resource stage_OSMtidy category_OSMtidy category_mod
-##    <chr>                    <chr>    <chr>         <chr>            <chr>       
-##  1 Business and commerce; … Account… fromFilters   Business and co… Business an…
-##  2 Business and commerce; … Account… fromFilters   Business and co… Business an…
-##  3 Business and commerce; … Adverti… fromFilters   Business and co… Business an…
-##  4 Business and commerce; … Adverti… fromFilters   Business and co… Business an…
-##  5 Food production and hor… Agricul… fromFilters   Food production… Food produc…
-##  6 Food production and hor… Agricul… fromFilters   Food production… Food produc…
-##  7 Food production and hor… Agricul… fromFilters   Food production… Food produc…
-##  8 Food production and hor… Agricul… fromFilters   Food production… Food produc…
-##  9 Food production and hor… Agricul… fromFilters   Food production… Food produc…
-## 10 Food production and hor… Agricul… fromFilters   Food production… Food produc…
-## # ℹ 643 more rows
-
-
-

3. Check the data

-
# Confirm adjMat has completely symmetrical edges i.e. there are no input errors
-adjMat_template %>% check_symmetry()
-
## [1] "All edges are symmetrical. Proceed!"
-
# If any edges are unsymmetrical check these
-# checkSymmetry = adjMat_template %>% check_symmetry()
-
-# Confirm adjMat has no vertices with redundant sets of edges i.e. no vertices
-# are connected to the same set of other vertices between two levels
-adjMat_template %>% check_redundancy()
-
## [1] "All edge sets are unique. Proceed!"
-
# Check node names from different data inputs are compatible
-check_names(adjMat_template, vInfo_template_full, key)
-
## [1] "Node names from inputs match. Proceed!"
-
# If some node names do not match
-# checkNames = check_names(adjMat_template, vInfo_template_full, key)
-# checkNames %>% write.csv("checkNames.csv")
-
-
-

4. Generate the Urban Systems Abstraction Hierarchy template

-
# Generate standard AHgen output for USAH baseline template
-USAH_template_baseline = 
-  gen_AH(vInfo = vInfo_template_full, 
-         vIncluded = vInfo_template,
-         adjMat = adjMat_template,
-         AH_name = AH_name, 
-         AH_version = AH_version, 
-         AH_location = AH_location, 
-         AH_scenario = AH_scenario)
-
-# Inspect elements
-USAH_template_baseline$vInfo
-
## # A tibble: 483 × 72
-##    level levelName levelName_full               Node        definition reference
-##    <dbl> <chr>     <chr>                        <chr>       <chr>      <chr>    
-##  1     1 Purposes  Functional purposes          Cultural h… "Cities s… Council …
-##  2     1 Purposes  Functional purposes          Economic o… "\"Agglom… World Ba…
-##  3     1 Purposes  Functional purposes          Globalised… "Cities p… Knox, P.…
-##  4     1 Purposes  Functional purposes          Knowledge … "Cities a… Commissi…
-##  5     1 Purposes  Functional purposes          Physical s… "Cities p… LeGrand,…
-##  6     1 Purposes  Functional purposes          Pooling of… "Cities p… Foster, …
-##  7     1 Purposes  Functional purposes          Safety and… "“Urban s… Roberts,…
-##  8     1 Purposes  Functional purposes          Social opp… "Cities h… Knapp, C…
-##  9     2 Outcomes  Values and priority measures Collective… "“This is… Arup (20…
-## 10     2 Outcomes  Values and priority measures Comprehens… "“This in… Arup (20…
-## # ℹ 473 more rows
-## # ℹ 66 more variables: colour_level_default <chr>, abbreviation <chr>,
-## #   colour_node_default <chr>, colour_node_archived2 <chr>,
-## #   colour_node_archived1 <chr>, UKspecific <chr>, health_wellbeing <chr>,
-## #   economy_society <chr>, infrastructure_ecosystems <chr>,
-## #   leadership_strategy <chr>, subnetwork_hazard_biological <chr>,
-## #   subnetwork_hazard_cyberAttack <chr>, subnetwork_hazard_drought <chr>, …
-
USAH_template_baseline$vIncluded
-
## # A tibble: 483 × 4
-##    level levelName_full               levelName Node                            
-##    <dbl> <chr>                        <chr>     <chr>                           
-##  1     1 Functional purposes          Purposes  Cultural heritage and sense of …
-##  2     1 Functional purposes          Purposes  Economic opportunity            
-##  3     1 Functional purposes          Purposes  Globalised connectivity         
-##  4     1 Functional purposes          Purposes  Knowledge transfer and diffusio…
-##  5     1 Functional purposes          Purposes  Physical settlement             
-##  6     1 Functional purposes          Purposes  Pooling of resources            
-##  7     1 Functional purposes          Purposes  Safety and security             
-##  8     1 Functional purposes          Purposes  Social opportunity and care     
-##  9     2 Values and priority measures Outcomes  Collective identity and communi…
-## 10     2 Values and priority measures Outcomes  Comprehensive security and rule…
-## # ℹ 473 more rows
-
USAH_template_baseline$vExcluded
-
## list()
-
USAH_template_baseline$adjMat
-
## # A tibble: 483 × 487
-##    level levelName_full               levelName Node      Cultural heritage an…¹
-##    <dbl> <chr>                        <chr>     <chr>                      <dbl>
-##  1     1 Functional purposes          Purposes  Cultural…                      0
-##  2     1 Functional purposes          Purposes  Economic…                      0
-##  3     1 Functional purposes          Purposes  Globalis…                      0
-##  4     1 Functional purposes          Purposes  Knowledg…                      0
-##  5     1 Functional purposes          Purposes  Physical…                      0
-##  6     1 Functional purposes          Purposes  Pooling …                      0
-##  7     1 Functional purposes          Purposes  Safety a…                      0
-##  8     1 Functional purposes          Purposes  Social o…                      0
-##  9     2 Values and priority measures Outcomes  Collecti…                      1
-## 10     2 Values and priority measures Outcomes  Comprehe…                      0
-## # ℹ 473 more rows
-## # ℹ abbreviated name: ¹​`Cultural heritage and sense of place`
-## # ℹ 482 more variables: `Economic opportunity` <dbl>,
-## #   `Globalised connectivity` <dbl>,
-## #   `Knowledge transfer and diffusion of innovation` <dbl>,
-## #   `Physical settlement` <dbl>, `Pooling of resources` <dbl>,
-## #   `Safety and security` <dbl>, `Social opportunity and care` <dbl>, …
-
USAH_template_baseline$edgelist
-
## # A tibble: 4,505 × 4
-##    layer      from                                 to                     weight
-##    <chr>      <chr>                                <chr>                   <dbl>
-##  1 l1FP_l2VPM Cultural heritage and sense of place Collective identity a…      1
-##  2 l1FP_l2VPM Cultural heritage and sense of place Environmental sustain…      1
-##  3 l1FP_l2VPM Cultural heritage and sense of place Integrated developmen…      1
-##  4 l1FP_l2VPM Cultural heritage and sense of place Socio-economic equali…      1
-##  5 l1FP_l2VPM Economic opportunity                 Diverse livelihoods a…      1
-##  6 l1FP_l2VPM Economic opportunity                 Reliable communicatio…      1
-##  7 l1FP_l2VPM Economic opportunity                 Socio-economic equali…      1
-##  8 l1FP_l2VPM Economic opportunity                 Sustainable economy         1
-##  9 l1FP_l2VPM Globalised connectivity              Diverse livelihoods a…      1
-## 10 l1FP_l2VPM Globalised connectivity              Effective leadership …      1
-## # ℹ 4,495 more rows
-
USAH_template_baseline$igraph
-
## IGRAPH a47a9af UNW- 483 4505 -- 
-## + attr: name (v/c), level (v/n), levelName_full (v/c), levelName (v/c),
-## | weight (e/n), layer (e/c)
-## + edges from a47a9af (vertex names):
-## [1] Cultural heritage and sense of place--Collective identity and community support
-## [2] Cultural heritage and sense of place--Environmental sustainability             
-## [3] Cultural heritage and sense of place--Integrated development and planning      
-## [4] Cultural heritage and sense of place--Socio-economic equality and equity       
-## [5] Economic opportunity                --Diverse livelihoods and employment       
-## [6] Economic opportunity                --Reliable communications and mobility     
-## + ... omitted several edges
-
USAH_template_baseline$results
-
## # A tibble: 9,177 × 11
-##    name  version location scenario level levelName_full   levelName Node  metric
-##    <chr> <chr>   <chr>    <chr>    <dbl> <fct>            <fct>     <chr> <fct> 
-##  1 USAH  3.0     template baseline     1 Functional purp… Purposes  Cult… EC    
-##  2 USAH  3.0     template baseline     1 Functional purp… Purposes  Econ… EC    
-##  3 USAH  3.0     template baseline     1 Functional purp… Purposes  Glob… EC    
-##  4 USAH  3.0     template baseline     1 Functional purp… Purposes  Know… EC    
-##  5 USAH  3.0     template baseline     1 Functional purp… Purposes  Phys… EC    
-##  6 USAH  3.0     template baseline     1 Functional purp… Purposes  Pool… EC    
-##  7 USAH  3.0     template baseline     1 Functional purp… Purposes  Safe… EC    
-##  8 USAH  3.0     template baseline     1 Functional purp… Purposes  Soci… EC    
-##  9 USAH  3.0     template baseline     2 Values and prio… Outcomes  Coll… EC    
-## 10 USAH  3.0     template baseline     2 Values and prio… Outcomes  Comp… EC    
-## # ℹ 9,167 more rows
-## # ℹ 2 more variables: value <dbl>, rank_byLevel <int>
-
USAH_template_baseline$summary
-
## $vertices
-##  level               levelName_full levelName n_vertices
-##      1          Functional purposes  Purposes          8
-##      2 Values and priority measures  Outcomes         14
-##      3        Generalised functions     Tasks         37
-##      4     Object-related processes Processes        170
-##      5             Physical objects Resources        254
-##  Total                            -         -        483
-## 
-## $edges
-##       layer n_edges
-##  l1FP_l2VPM      48
-##  l2VPM_l3GF     147
-##  l3GF_l4ORP     717
-##  l4ORP_l5PO    3593
-##       Total    4505
-
-
-

5. Export

-
# Write output to RDS file
-USAH_template_baseline %>% 
-  export_AHgen(
-    type = "USAH",
-    directory = directory,
-    AH_version = AH_version, 
-    AH_location = AH_location, 
-    AH_scenario = AH_scenario)
-
-# If subnetwork assignment has been updated, write out to .xlsx for future use
-USAH_template_baseline$vInfo %>% 
- write.xlsx(
-   filenameTimestamp(
-     prefix = paste0(directory,
-                     name, "_", version, "_", location, "_", scenario, 
-                    "_vInfo-full"),
- extension = ".xlsx"))
-
- -
-

Last updated

-

This vignette is associated with AHgen v1.0.0, and was -last updated by Melissa Bedinger on 2023-07-26.

-
- - - -
-
- -
- - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +Application - Generate template Urban Systems Abstraction Hierarchy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+
+
+
+ +
+ + + + + + + + +
+

In this vignette, you will go through the steps of generating a +template Urban Systems Abstraction Hierarchy in AHgen:

+
    +
  1. Prepare the environment
  2. +
  3. Read in the data
  4. +
  5. Check the data
  6. +
  7. Generate the template Urban Systems Abstraction Hierarchy
  8. +
  9. Export
  10. +
+

To navigate to other vignettes, go to Vignette 0 - Welcome to +AHgen.

+
+

1. Prepare the environment

+
# Clear the RStudio environment
+rm(list = ls()); cat("/014"); gc(verbose = TRUE)
+
+# CTRL + SHIFT + F10 will detach any loaded packages and restart R
+
+# Set the working directory to the folder where this script is saved
+setwd(dirname(rstudioapi::getSourceEditorContext()$path)); getwd()
+
+# If you are doing this for the first time
+
+# install the package pacman which checks to see if a package is installed
+# and if not it attempts to install the package from CRAN 
+# and/or any other repository in the pacman repository list
+
+# and install the package devtools which will allow you to download a package straight from GitHub 
+# i.e. if they are not yet on CRAN and/or the pacman repository list
+
+install.packages("devtools")
+install.packages("pacman")
+
+# Ensure latest version of AHgen is installed
+devtools::install_github("avisserquinn/AHgen", dependencies = TRUE)
+
+# If package has 'non-zero exit status', try re-installing devtools & rlang
+install.packages("devtools")
+install.packages("rlang")
+
+# Load required packages
+pacman::p_load(tidyverse, readxl, installr, janitor, vctrs, AHgen)
+
+
+

2. Read in the data

+
# Set name, version, location, and scenario
+AH_name = "USAH"
+AH_version = "3.0"
+AH_location = "template"
+AH_scenario = "baseline"
+
+# Set directory for outputs
+directory = "outputs/"
+
+# Read in template USAH adjacency matrix
+adjMat_template = 
+  read_adjMat("inputs/USAH_3.0_template_baseline_adjMat_20230602.xlsx")
+
+adjMat_template
+
## # A tibble: 483 × 487
+##    level levelName_full               levelName Node      Cultural heritage an…¹
+##    <dbl> <chr>                        <chr>     <chr>                      <dbl>
+##  1     1 Functional purposes          Purposes  Cultural…                      0
+##  2     1 Functional purposes          Purposes  Economic…                      0
+##  3     1 Functional purposes          Purposes  Globalis…                      0
+##  4     1 Functional purposes          Purposes  Knowledg…                      0
+##  5     1 Functional purposes          Purposes  Physical…                      0
+##  6     1 Functional purposes          Purposes  Pooling …                      0
+##  7     1 Functional purposes          Purposes  Safety a…                      0
+##  8     1 Functional purposes          Purposes  Social o…                      0
+##  9     2 Values and priority measures Outcomes  Collecti…                      1
+## 10     2 Values and priority measures Outcomes  Comprehe…                      0
+## # ℹ 473 more rows
+## # ℹ abbreviated name: ¹​`Cultural heritage and sense of place`
+## # ℹ 482 more variables: `Economic opportunity` <dbl>,
+## #   `Globalised connectivity` <dbl>,
+## #   `Knowledge transfer and diffusion of innovation` <dbl>,
+## #   `Physical settlement` <dbl>, `Pooling of resources` <dbl>,
+## #   `Safety and security` <dbl>, `Social opportunity and care` <dbl>, …
+
# Create template USAH vInfo (basic)
+vInfo_template = 
+  adjMat_template %>% select(level, levelName_full, levelName, Node)
+
+vInfo_template
+
## # A tibble: 483 × 4
+##    level levelName_full               levelName Node                            
+##    <dbl> <chr>                        <chr>     <chr>                           
+##  1     1 Functional purposes          Purposes  Cultural heritage and sense of …
+##  2     1 Functional purposes          Purposes  Economic opportunity            
+##  3     1 Functional purposes          Purposes  Globalised connectivity         
+##  4     1 Functional purposes          Purposes  Knowledge transfer and diffusio…
+##  5     1 Functional purposes          Purposes  Physical settlement             
+##  6     1 Functional purposes          Purposes  Pooling of resources            
+##  7     1 Functional purposes          Purposes  Safety and security             
+##  8     1 Functional purposes          Purposes  Social opportunity and care     
+##  9     2 Values and priority measures Outcomes  Collective identity and communi…
+## 10     2 Values and priority measures Outcomes  Comprehensive security and rule…
+## # ℹ 473 more rows
+
# Read in template USAH vInfo (full)
+vInfo_template_full = 
+  read_xlsx("inputs/USAH_3.0_template_baseline_vInfo-full_20230621.xlsx")
+
+vInfo_template_full
+
## # A tibble: 483 × 72
+##    level levelName_full        levelName colour_level_default Node  abbreviation
+##    <dbl> <chr>                 <chr>     <chr>                <chr> <chr>       
+##  1     1 Functional purposes   Purposes  #CCB1B9              Cult… NA          
+##  2     1 Functional purposes   Purposes  #CCB1B9              Econ… NA          
+##  3     1 Functional purposes   Purposes  #CCB1B9              Glob… NA          
+##  4     1 Functional purposes   Purposes  #CCB1B9              Know… NA          
+##  5     1 Functional purposes   Purposes  #CCB1B9              Phys… NA          
+##  6     1 Functional purposes   Purposes  #CCB1B9              Pool… NA          
+##  7     1 Functional purposes   Purposes  #CCB1B9              Safe… NA          
+##  8     1 Functional purposes   Purposes  #CCB1B9              Soci… NA          
+##  9     2 Values and priority … Outcomes  #607EBC              Coll… CICS        
+## 10     2 Values and priority … Outcomes  #607EBC              Comp… CSRL        
+## # ℹ 473 more rows
+## # ℹ 66 more variables: colour_node_default <chr>, colour_node_archived2 <chr>,
+## #   colour_node_archived1 <chr>, definition <chr>, reference <chr>,
+## #   UKspecific <chr>, health_wellbeing <chr>, economy_society <chr>,
+## #   infrastructure_ecosystems <chr>, leadership_strategy <chr>,
+## #   subnetwork_hazard_biological <chr>, subnetwork_hazard_cyberAttack <chr>,
+## #   subnetwork_hazard_drought <chr>, subnetwork_hazard_earthquake <chr>, …
+
# Read in OSMtidy-AHgen key for allocating OSMtidy descs to AHgen objects
+key = 
+  read_csv("inputs/OSM-AH-key_3.0_20230717.csv", show_col_types = FALSE)
+
+key
+
## # A tibble: 653 × 5
+##    desc                     resource stage_OSMtidy category_OSMtidy category_mod
+##    <chr>                    <chr>    <chr>         <chr>            <chr>       
+##  1 Business and commerce; … Account… fromFilters   Business and co… Business an…
+##  2 Business and commerce; … Account… fromFilters   Business and co… Business an…
+##  3 Business and commerce; … Adverti… fromFilters   Business and co… Business an…
+##  4 Business and commerce; … Adverti… fromFilters   Business and co… Business an…
+##  5 Food production and hor… Agricul… fromFilters   Food production… Food produc…
+##  6 Food production and hor… Agricul… fromFilters   Food production… Food produc…
+##  7 Food production and hor… Agricul… fromFilters   Food production… Food produc…
+##  8 Food production and hor… Agricul… fromFilters   Food production… Food produc…
+##  9 Food production and hor… Agricul… fromFilters   Food production… Food produc…
+## 10 Food production and hor… Agricul… fromFilters   Food production… Food produc…
+## # ℹ 643 more rows
+
+
+

3. Check the data

+
# Confirm adjMat has completely symmetrical edges i.e. there are no input errors
+adjMat_template %>% check_symmetry()
+
## [1] "All edges are symmetrical. Proceed!"
+
# If any edges are unsymmetrical check these
+# checkSymmetry = adjMat_template %>% check_symmetry()
+
+# Confirm adjMat has no vertices with redundant sets of edges i.e. no vertices
+# are connected to the same set of other vertices between two levels
+adjMat_template %>% check_redundancy()
+
## [1] "All edge sets are unique. Proceed!"
+
# Check node names from different data inputs are compatible
+check_names(adjMat_template, vInfo_template_full, key)
+
## [1] "Node names from inputs match. Proceed!"
+
# If some node names do not match
+# checkNames = check_names(adjMat_template, vInfo_template_full, key)
+# checkNames %>% write.csv("checkNames.csv")
+
+
+

4. Generate the Urban Systems Abstraction Hierarchy template

+
# Generate standard AHgen output for USAH baseline template
+USAH_template_baseline = 
+  gen_AH(vInfo = vInfo_template_full, 
+         vIncluded = vInfo_template,
+         adjMat = adjMat_template,
+         AH_name = AH_name, 
+         AH_version = AH_version, 
+         AH_location = AH_location, 
+         AH_scenario = AH_scenario)
+
+# Inspect elements
+USAH_template_baseline$vInfo
+
## # A tibble: 483 × 72
+##    level levelName levelName_full               Node        definition reference
+##    <dbl> <chr>     <chr>                        <chr>       <chr>      <chr>    
+##  1     1 Purposes  Functional purposes          Cultural h… "Cities s… Council …
+##  2     1 Purposes  Functional purposes          Economic o… "\"Agglom… World Ba…
+##  3     1 Purposes  Functional purposes          Globalised… "Cities p… Knox, P.…
+##  4     1 Purposes  Functional purposes          Knowledge … "Cities a… Commissi…
+##  5     1 Purposes  Functional purposes          Physical s… "Cities p… LeGrand,…
+##  6     1 Purposes  Functional purposes          Pooling of… "Cities p… Foster, …
+##  7     1 Purposes  Functional purposes          Safety and… "“Urban s… Roberts,…
+##  8     1 Purposes  Functional purposes          Social opp… "Cities h… Knapp, C…
+##  9     2 Outcomes  Values and priority measures Collective… "“This is… Arup (20…
+## 10     2 Outcomes  Values and priority measures Comprehens… "“This in… Arup (20…
+## # ℹ 473 more rows
+## # ℹ 66 more variables: colour_level_default <chr>, abbreviation <chr>,
+## #   colour_node_default <chr>, colour_node_archived2 <chr>,
+## #   colour_node_archived1 <chr>, UKspecific <chr>, health_wellbeing <chr>,
+## #   economy_society <chr>, infrastructure_ecosystems <chr>,
+## #   leadership_strategy <chr>, subnetwork_hazard_biological <chr>,
+## #   subnetwork_hazard_cyberAttack <chr>, subnetwork_hazard_drought <chr>, …
+
USAH_template_baseline$vIncluded
+
## # A tibble: 483 × 4
+##    level levelName_full               levelName Node                            
+##    <dbl> <chr>                        <chr>     <chr>                           
+##  1     1 Functional purposes          Purposes  Cultural heritage and sense of …
+##  2     1 Functional purposes          Purposes  Economic opportunity            
+##  3     1 Functional purposes          Purposes  Globalised connectivity         
+##  4     1 Functional purposes          Purposes  Knowledge transfer and diffusio…
+##  5     1 Functional purposes          Purposes  Physical settlement             
+##  6     1 Functional purposes          Purposes  Pooling of resources            
+##  7     1 Functional purposes          Purposes  Safety and security             
+##  8     1 Functional purposes          Purposes  Social opportunity and care     
+##  9     2 Values and priority measures Outcomes  Collective identity and communi…
+## 10     2 Values and priority measures Outcomes  Comprehensive security and rule…
+## # ℹ 473 more rows
+
USAH_template_baseline$vExcluded
+
## list()
+
USAH_template_baseline$adjMat
+
## # A tibble: 483 × 487
+##    level levelName_full               levelName Node      Cultural heritage an…¹
+##    <dbl> <chr>                        <chr>     <chr>                      <dbl>
+##  1     1 Functional purposes          Purposes  Cultural…                      0
+##  2     1 Functional purposes          Purposes  Economic…                      0
+##  3     1 Functional purposes          Purposes  Globalis…                      0
+##  4     1 Functional purposes          Purposes  Knowledg…                      0
+##  5     1 Functional purposes          Purposes  Physical…                      0
+##  6     1 Functional purposes          Purposes  Pooling …                      0
+##  7     1 Functional purposes          Purposes  Safety a…                      0
+##  8     1 Functional purposes          Purposes  Social o…                      0
+##  9     2 Values and priority measures Outcomes  Collecti…                      1
+## 10     2 Values and priority measures Outcomes  Comprehe…                      0
+## # ℹ 473 more rows
+## # ℹ abbreviated name: ¹​`Cultural heritage and sense of place`
+## # ℹ 482 more variables: `Economic opportunity` <dbl>,
+## #   `Globalised connectivity` <dbl>,
+## #   `Knowledge transfer and diffusion of innovation` <dbl>,
+## #   `Physical settlement` <dbl>, `Pooling of resources` <dbl>,
+## #   `Safety and security` <dbl>, `Social opportunity and care` <dbl>, …
+
USAH_template_baseline$edgelist
+
## # A tibble: 4,505 × 4
+##    layer      from                                 to                     weight
+##    <chr>      <chr>                                <chr>                   <dbl>
+##  1 l1FP_l2VPM Cultural heritage and sense of place Collective identity a…      1
+##  2 l1FP_l2VPM Cultural heritage and sense of place Environmental sustain…      1
+##  3 l1FP_l2VPM Cultural heritage and sense of place Integrated developmen…      1
+##  4 l1FP_l2VPM Cultural heritage and sense of place Socio-economic equali…      1
+##  5 l1FP_l2VPM Economic opportunity                 Diverse livelihoods a…      1
+##  6 l1FP_l2VPM Economic opportunity                 Reliable communicatio…      1
+##  7 l1FP_l2VPM Economic opportunity                 Socio-economic equali…      1
+##  8 l1FP_l2VPM Economic opportunity                 Sustainable economy         1
+##  9 l1FP_l2VPM Globalised connectivity              Diverse livelihoods a…      1
+## 10 l1FP_l2VPM Globalised connectivity              Effective leadership …      1
+## # ℹ 4,495 more rows
+
USAH_template_baseline$igraph
+
## IGRAPH a47a9af UNW- 483 4505 -- 
+## + attr: name (v/c), level (v/n), levelName_full (v/c), levelName (v/c),
+## | weight (e/n), layer (e/c)
+## + edges from a47a9af (vertex names):
+## [1] Cultural heritage and sense of place--Collective identity and community support
+## [2] Cultural heritage and sense of place--Environmental sustainability             
+## [3] Cultural heritage and sense of place--Integrated development and planning      
+## [4] Cultural heritage and sense of place--Socio-economic equality and equity       
+## [5] Economic opportunity                --Diverse livelihoods and employment       
+## [6] Economic opportunity                --Reliable communications and mobility     
+## + ... omitted several edges
+
USAH_template_baseline$results
+
## # A tibble: 9,177 × 11
+##    name  version location scenario level levelName_full   levelName Node  metric
+##    <chr> <chr>   <chr>    <chr>    <dbl> <fct>            <fct>     <chr> <fct> 
+##  1 USAH  3.0     template baseline     1 Functional purp… Purposes  Cult… EC    
+##  2 USAH  3.0     template baseline     1 Functional purp… Purposes  Econ… EC    
+##  3 USAH  3.0     template baseline     1 Functional purp… Purposes  Glob… EC    
+##  4 USAH  3.0     template baseline     1 Functional purp… Purposes  Know… EC    
+##  5 USAH  3.0     template baseline     1 Functional purp… Purposes  Phys… EC    
+##  6 USAH  3.0     template baseline     1 Functional purp… Purposes  Pool… EC    
+##  7 USAH  3.0     template baseline     1 Functional purp… Purposes  Safe… EC    
+##  8 USAH  3.0     template baseline     1 Functional purp… Purposes  Soci… EC    
+##  9 USAH  3.0     template baseline     2 Values and prio… Outcomes  Coll… EC    
+## 10 USAH  3.0     template baseline     2 Values and prio… Outcomes  Comp… EC    
+## # ℹ 9,167 more rows
+## # ℹ 2 more variables: value <dbl>, rank_byLevel <int>
+
USAH_template_baseline$summary
+
## $vertices
+##  level               levelName_full levelName n_vertices
+##      1          Functional purposes  Purposes          8
+##      2 Values and priority measures  Outcomes         14
+##      3        Generalised functions     Tasks         37
+##      4     Object-related processes Processes        170
+##      5             Physical objects Resources        254
+##  Total                            -         -        483
+## 
+## $edges
+##       layer n_edges
+##  l1FP_l2VPM      48
+##  l2VPM_l3GF     147
+##  l3GF_l4ORP     717
+##  l4ORP_l5PO    3593
+##       Total    4505
+
+
+

5. Export

+
# Write output to RDS file
+USAH_template_baseline %>% 
+  export_AHgen(
+    type = "USAH",
+    directory = directory,
+    AH_version = AH_version, 
+    AH_location = AH_location, 
+    AH_scenario = AH_scenario)
+
+# If subnetwork assignment has been updated, write out to .xlsx for future use
+USAH_template_baseline$vInfo %>% 
+ writexl::write_xlsx(
+   filenameTimestamp(
+     prefix = paste0(directory,
+                     name, "_", version, "_", location, "_", scenario, 
+                    "_vInfo-full"),
+ extension = ".xlsx"))
+
+ +
+

Last updated

+

This vignette is associated with AHgen v1.0.0, and was +last updated by Melissa Bedinger on 2023-07-26.

+
+ + + +
+
+ +
+ + + + + + + + + + + + + + + +