Skip to contents

Read a project from disk.

Usage

read_project(
  path,
  spatial_path = NULL,
  attribute_path = NULL,
  boundary_path = NULL,
  mode = "project"
)

Arguments

path

character file path for the configuration file.

spatial_path

character file path for spatial data. Defaults to NULL such that the file path is determined using the argument to path.

attribute_path

character file path for attribute data. Defaults to NULL such that the file path is determined using the argument to path.

boundary_path

character file path for boundary data. Defaults to NULL such that the file path is determined using the argument to path.

mode

character mode for importing the objects. Defaults to "project" such that the mode is determined based on the contents of path. If the mode is "advanced", then goal limits and mandatory include settings are disabled.

Value

A list containing the following elements:

name

A character value indicating the name.

dataset

A Dataset object.

themes

A list of Theme objects.

weights

A list of Weight objects.

includes

A list of Include objects.

excludes

A list of Exclude objects.

mode

A character value indicating the mode.

Details

Note that the status field for themes and weights will automatically be set to FALSE if the goal/weight values are zero. This is to ensure that the application starts with a sensible combination of settings.

Examples

# find data file paths
f1 <- system.file(
  "extdata", "projects", "sim_raster", "sim_raster_data.yaml",
  package = "wheretowork"
)
f2 <- system.file(
  "extdata", "projects", "sim_raster", "sim_raster_spatial.tif",
  package = "wheretowork"
)
f3 <- system.file(
  "extdata",  "projects", "sim_raster", "sim_raster_attribute.csv.gz",
  package = "wheretowork"
)
f4 <- system.file(
  "extdata",  "projects", "sim_raster", "sim_raster_boundary.csv.gz",
  package = "wheretowork"
)

# read project
x <- read_project(f1, f2, f3, f4)

# print project
print(x)
#> $name
#> [1] "Example GeoTIFF dataset"
#> 
#> $author_name
#> [1] "Richard Schuster"
#> 
#> $author_email
#> [1] "richard.schuster@natureconservancy.ca"
#> 
#> $dataset
#> Dataset
#>   paths:
#>     spatial: C:/Users/Daniel Wismer/AppData/Local/Temp/Rtmpchjhef/temp_libpath6006e153c6b/wheretowork/extdata/projects/sim_raster/sim_raster_spatial.tif
#>     attribute: C:/Users/Daniel Wismer/AppData/Local/Temp/Rtmpchjhef/temp_libpath6006e153c6b/wheretowork/extdata/projects/sim_raster/sim_raster_attribute.csv.gz
#>     boundary: C:/Users/Daniel Wismer/AppData/Local/Temp/Rtmpchjhef/temp_libpath6006e153c6b/wheretowork/extdata/projects/sim_raster/sim_raster_boundary.csv.gz
#> 
#> $themes
#> $themes[[1]]
#> Theme
#>   id:        e365128d-32d7-4490-9317-fc7901d11e8a
#>   name:      Brown-necked Parrot (Brown-necked)
#>   feature: 
#>     Brown-necked Parrot (Brown-necked) habitat [status: TRUE, current: 0.81, goal: 0.62]
#>     
  variable: .../sim_raster_spatial.tif#Brown_necked_Parrot_Brown_necked_ [total: 483 ha]
#> 
#> $themes[[2]]
#> Theme
#>   id:        6578e3ce-0a81-4c64-8db2-109268fcf034
#>   name:      Gough Island Finch
#>   feature: 
#>     Gough Island Finch habitat [status: TRUE, current: 0.83, goal: 0.54]
#>     
  variable: .../sim_raster_spatial.tif#Gough_Island_Finch [total: 25747.97 ha]
#> 
#> $themes[[3]]
#> Theme
#>   id:        826f1211-9497-48ec-8179-0ca1afa94dd0
#>   name:      Manus Boobook
#>   feature: 
#>     Manus Boobook habitat [status: TRUE, current: 0.79, goal: 0.5]
#>     
  variable: .../sim_raster_spatial.tif#Manus_Boobook [total: 23474.88 ha]
#> 
#> $themes[[4]]
#> Theme
#>   id:        4118f1af-f952-4346-87e0-182f047640bd
#>   name:      Flufftails
#>   feature: 
#>     Red-chested Flufftail [status: TRUE, current: 0.81, goal: 0.7]
#>     
  variable: .../sim_raster_spatial.tif#White_spotted_Flufftail_Northern_ [total: 16872.87 ha]
#>     Chestnut-headed Flufftail [status: TRUE, current: 0.81, goal: 0.7]
#>     
  variable: .../sim_raster_spatial.tif#White_spotted_Flufftail_Northern_ [total: 16872.87 ha]
#>     Tsingy Wood-Rail [status: TRUE, current: 0.81, goal: 0.73]
#>     
  variable: .../sim_raster_spatial.tif#White_spotted_Flufftail_Northern_ [total: 16872.87 ha]
#>     Streaky-breasted Flufftail [status: TRUE, current: 0.81, goal: 0.74]
#>     
  variable: .../sim_raster_spatial.tif#White_spotted_Flufftail_Northern_ [total: 16872.87 ha]
#>     Madagascar Flufftail [status: TRUE, current: 0.81, goal: 0.8]
#>     
  variable: .../sim_raster_spatial.tif#White_spotted_Flufftail_Northern_ [total: 16872.87 ha]
#>     Buff-spotted Flufftail [status: TRUE, current: 0.81, goal: 0.86]
#>     
  variable: .../sim_raster_spatial.tif#White_spotted_Flufftail_Northern_ [total: 16872.87 ha]
#>     White-winged Flufftail [status: TRUE, current: 0.81, goal: 0.76]
#>     
  variable: .../sim_raster_spatial.tif#White_spotted_Flufftail_Northern_ [total: 16872.87 ha]
#>     White-spotted Flufftail [status: TRUE, current: 0.81, goal: 0.64]
#>     
  variable: .../sim_raster_spatial.tif#White_spotted_Flufftail_Northern_ [total: 16872.87 ha]
#>     White-spotted Flufftail (Northern) [status: TRUE, current: 0.81, goal: 0.81]
#>     
  variable: .../sim_raster_spatial.tif#White_spotted_Flufftail_Northern_ [total: 16872.87 ha]
#> 
#> $themes[[5]]
#> Theme
#>   id:        d3a06f4e-3c8d-4b5c-b60e-9089ba835af2
#>   name:      Todies
#>   feature: 
#>     Puerto Rican Tody [status: TRUE, current: 0.79, goal: 0.6]
#>     
  variable: .../sim_raster_spatial.tif#Jamaican_Tody [total: 14614.97 ha]
#>     Jamaican Tody [status: TRUE, current: 0.79, goal: 0.73]
#>     
  variable: .../sim_raster_spatial.tif#Jamaican_Tody [total: 14614.97 ha]
#> 
#> 
#> $weights
#> $weights[[1]]
#> Weight
#>   id:       6cbf8a87-3f03-40c1-b31b-9a5c10b28f97
#>   name:     Population count
#>   variable: .../sim_raster_spatial.tif#Population_count [total: 174.9 ha]
#>   pane:  e54f3f80-7ce0-45c5-8637-0bff9a060caf-Population_count
#>   current:  0.8
#>   visible:  TRUE
#>   invisible:  NA
#>   loaded:  TRUE
#>   hidden:  FALSE
#>   downloadable:  TRUE
#>   status:   FALSE
#>   factor:   0
#> 
#> $weights[[2]]
#> Weight
#>   id:       cf19d6ae-effe-4615-91e1-3e6e69e91d05
#>   name:     Transportation network
#>   variable: .../sim_raster_spatial.tif#Transportation_network [total: 140.56 ha]
#>   pane:  5684c440-0758-41a8-a5f7-8d740ad8a039-Transportation_network
#>   current:  0.82
#>   visible:  TRUE
#>   invisible:  NA
#>   loaded:  TRUE
#>   hidden:  FALSE
#>   downloadable:  TRUE
#>   status:   FALSE
#>   factor:   0
#> 
#> $weights[[3]]
#> Weight
#>   id:       8329af81-ab2f-454b-a446-bbcd8ebd6f0c
#>   name:     Sea level rise
#>   variable: .../sim_raster_spatial.tif#Sea_level_rise [total: 144.44 ha]
#>   pane:  62f2f011-ee05-4db5-a852-5c0961aed91d-Sea_level_rise
#>   current:  0.79
#>   visible:  TRUE
#>   invisible:  NA
#>   loaded:  TRUE
#>   hidden:  FALSE
#>   downloadable:  TRUE
#>   status:   FALSE
#>   factor:   0
#> 
#> 
#> $includes
#> $includes[[1]]
#> Include
#>   id:       a2ada00d-8cb1-494f-9c32-fb2ec8323bbe
#>   name:     Protected landscapes
#>   variable: .../sim_raster_spatial.tif#Protected_landscapes [total: 182 ]
#>   pane:  23a23fa5-9848-47d7-8985-920e5c4d8544-Protected_landscapes
#>   visible:  TRUE
#>   invisible:  NA
#>   loaded:  TRUE
#>   hidden:  FALSE
#>   downloadable:  TRUE
#>   status:   TRUE
#>   overlap:   NA
#> 
#> $includes[[2]]
#> Include
#>   id:       d2a46dbf-7412-43fe-b634-a4f17c200c94
#>   name:     OECM areas
#>   variable: .../sim_raster_spatial.tif#OECM_areas [total: 157 ]
#>   pane:  fb3b1dbf-5b1a-4e2c-bb08-f515018f1d3e-OECM_areas
#>   visible:  TRUE
#>   invisible:  NA
#>   loaded:  TRUE
#>   hidden:  FALSE
#>   downloadable:  TRUE
#>   status:   TRUE
#>   overlap:   NA
#> 
#> 
#> $excludes
#> list()
#> 
#> $mode
#> [1] "advanced"
#>