User-provided spatial data
In most of the demonstrations, we have used the spatial data provided by {HydroBOT}. However, spatial data is an argument to multi_aggregate()
and read_and_agg()
, and so it is possible for the user to pass arbitrary spatial datasets. as {sf} objects. The only requirement is that they are sf
objects with a geometry
column. To demonstrate, we’ll download Australian states and aggregate into those. We do that here with read_and_agg()
, since that is the most common situation, but it also works with multi_aggregate.
As always, we need to point to the data.
New spatial units
We’ll set keepAllPolys = TRUE
since the data is all in NSW and we want to show that the other states are there.
aggseq_states <- list(
all_time = "all_time",
env_obj = c("ewr_code_timing", "env_obj"),
Target = c("env_obj", "Target"),
state = austates
)
funseq_states <- list(
all_time = "ArithmeticMean",
env_obj = "ArithmeticMean",
Target = "ArithmeticMean",
state = "ArithmeticMean"
)
state_agg <- read_and_agg(
datpath = ewr_results,
type = "achievement",
geopath = bom_basin_gauges,
causalpath = causal_ewr,
groupers = "scenario",
aggCols = "ewr_achieved",
group_until = list(
SWSDLName = is_notpoint,
planning_unit_name = is_notpoint,
gauge = is_notpoint
),
aggsequence = aggseq_states,
funsequence = funseq_states,
saveintermediate = TRUE,
namehistory = FALSE,
keepAllPolys = TRUE,
returnList = TRUE,
add_max = FALSE
)
state_agg
$agg_input
Simple feature collection with 2946 features and 13 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 144.8811 ymin: -33.8695 xmax: 148.6839 ymax: -30.4577
Geodetic CRS: GDA94
# A tibble: 2,946 × 14
scenario year date gauge planning_unit_name state SWSDLName ewr_code
* <chr> <dbl> <date> <chr> <chr> <chr> <chr> <chr>
1 base 2014 2014-07-01 421004 Baroona to Warren … NSW Macquari… BF1
2 base 2015 2015-07-01 421004 Baroona to Warren … NSW Macquari… BF1
3 base 2016 2016-07-01 421004 Baroona to Warren … NSW Macquari… BF1
4 base 2017 2017-07-01 421004 Baroona to Warren … NSW Macquari… BF1
5 base 2018 2018-07-01 421004 Baroona to Warren … NSW Macquari… BF1
6 base 2019 2019-07-01 421004 Baroona to Warren … NSW Macquari… BF1
7 base 2014 2014-07-01 421004 Baroona to Warren … NSW Macquari… BF1
8 base 2015 2015-07-01 421004 Baroona to Warren … NSW Macquari… BF1
9 base 2016 2016-07-01 421004 Baroona to Warren … NSW Macquari… BF1
10 base 2017 2017-07-01 421004 Baroona to Warren … NSW Macquari… BF1
# ℹ 2,936 more rows
# ℹ 6 more variables: ewr_code_timing <chr>, event_years <dbl>,
# frequency_achieved <dbl>, interevent_achieved <dbl>, ewr_achieved <dbl>,
# geometry <POINT [°]>
$all_time
Simple feature collection with 552 features and 9 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 144.8811 ymin: -33.8695 xmax: 148.6839 ymax: -30.4577
Geodetic CRS: GDA94
# A tibble: 552 × 10
scenario SWSDLName planning_unit_name gauge ewr_code_timing polyID
<chr> <chr> <chr> <chr> <chr> <chr>
1 MAX Lachlan Lachlan River - Lake Cargell… 4120… BF1_a r4pdr…
2 MAX Lachlan Lachlan River - Lake Cargell… 4120… BF1_b r4pdr…
3 MAX Lachlan Lachlan River - Lake Cargell… 4120… BF2_a r4pdr…
4 MAX Lachlan Lachlan River - Lake Cargell… 4120… BF2_b r4pdr…
5 MAX Lachlan Lachlan River - Lake Cargell… 4120… BK1_P r4pdr…
6 MAX Lachlan Lachlan River - Lake Cargell… 4120… BK1_S r4pdr…
7 MAX Lachlan Lachlan River - Lake Cargell… 4120… CF1_b r4pdr…
8 MAX Lachlan Lachlan River - Lake Cargell… 4120… CF1_c r4pdr…
9 MAX Lachlan Lachlan River - Lake Cargell… 4120… LF1_P r4pdr…
10 MAX Lachlan Lachlan River - Lake Cargell… 4120… LF1_S r4pdr…
# ℹ 542 more rows
# ℹ 4 more variables: geometry <POINT [°]>, ewr_achieved <dbl>, aggfun_1 <chr>,
# aggLevel_1 <chr>
$env_obj
Simple feature collection with 1008 features and 11 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 144.8811 ymin: -33.8695 xmax: 148.6839 ymax: -30.4577
Geodetic CRS: GDA94
# A tibble: 1,008 × 12
scenario SWSDLName planning_unit_name gauge polyID env_obj
<chr> <chr> <chr> <chr> <chr> <chr>
1 MAX Lachlan Lachlan River - Lake Cargelligo to W… 4120… r4pdr… EF1
2 MAX Lachlan Lachlan River - Lake Cargelligo to W… 4120… r4pdr… EF2
3 MAX Lachlan Lachlan River - Lake Cargelligo to W… 4120… r4pdr… EF3
4 MAX Lachlan Lachlan River - Lake Cargelligo to W… 4120… r4pdr… EF3a
5 MAX Lachlan Lachlan River - Lake Cargelligo to W… 4120… r4pdr… EF4
6 MAX Lachlan Lachlan River - Lake Cargelligo to W… 4120… r4pdr… EF5
7 MAX Lachlan Lachlan River - Lake Cargelligo to W… 4120… r4pdr… EF6
8 MAX Lachlan Lachlan River - Lake Cargelligo to W… 4120… r4pdr… EF7
9 MAX Lachlan Lachlan River - Lake Cargelligo to W… 4120… r4pdr… NF1
10 MAX Lachlan Lachlan River - Lake Cargelligo to W… 4120… r4pdr… NF2
# ℹ 998 more rows
# ℹ 6 more variables: geometry <POINT [°]>, ewr_achieved <dbl>, aggfun_1 <chr>,
# aggLevel_1 <chr>, aggfun_2 <chr>, aggLevel_2 <chr>
$Target
Simple feature collection with 176 features and 13 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 144.8811 ymin: -33.8695 xmax: 148.6839 ymax: -30.4577
Geodetic CRS: GDA94
# A tibble: 176 × 14
scenario SWSDLName planning_unit_name gauge polyID Target
<chr> <chr> <chr> <chr> <chr> <chr>
1 MAX Lachlan Lachlan River - Lake Cargelligo to Wi… 4120… r4pdr… Ecosy…
2 MAX Lachlan Lachlan River - Lake Cargelligo to Wi… 4120… r4pdr… Nativ…
3 MAX Lachlan Lachlan River - Lake Cargelligo to Wi… 4120… r4pdr… Nativ…
4 MAX Lachlan Lachlan River - Lake Cargelligo to Wi… 4120… r4pdr… Other…
5 MAX Lachlan Lachlan River - Lake Cargelligo to Wi… 4120… r4pdr… Water…
6 MAX Lachlan Merrimajeel Creek 4120… r1zp2… Ecosy…
7 MAX Lachlan Merrimajeel Creek 4120… r1zp2… Nativ…
8 MAX Lachlan Merrimajeel Creek 4120… r1zp2… Nativ…
9 MAX Lachlan Merrimajeel Creek 4120… r1zp2… Other…
10 MAX Lachlan Merrimajeel Creek 4120… r1zp2… Water…
# ℹ 166 more rows
# ℹ 8 more variables: geometry <POINT [°]>, ewr_achieved <dbl>, aggfun_1 <chr>,
# aggLevel_1 <chr>, aggfun_2 <chr>, aggLevel_2 <chr>, aggfun_3 <chr>,
# aggLevel_3 <chr>
$state
Simple feature collection with 220 features and 13 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 112.9194 ymin: -54.75042 xmax: 159.1065 ymax: -9.240167
Geodetic CRS: WGS 84
# A tibble: 220 × 14
scenario Target polyID state geometry ewr_achieved aggfun_1
<chr> <chr> <chr> <chr> <MULTIPOLYGON [°]> <dbl> <chr>
1 MAX Ecosys… r60v0… New … (((153.4723 -28.17528, 1… 1 Arithme…
2 MAX Native… r60v0… New … (((153.4723 -28.17528, 1… 1 Arithme…
3 MAX Native… r60v0… New … (((153.4723 -28.17528, 1… 1 Arithme…
4 MAX Other … r60v0… New … (((153.4723 -28.17528, 1… 1 Arithme…
5 MAX Waterb… r60v0… New … (((153.4723 -28.17528, 1… 1 Arithme…
6 base Ecosys… r60v0… New … (((153.4723 -28.17528, 1… 0.322 Arithme…
7 base Native… r60v0… New … (((153.4723 -28.17528, 1… 0.401 Arithme…
8 base Native… r60v0… New … (((153.4723 -28.17528, 1… 0.238 Arithme…
9 base Other … r60v0… New … (((153.4723 -28.17528, 1… 0.270 Arithme…
10 base Waterb… r60v0… New … (((153.4723 -28.17528, 1… 0.183 Arithme…
# ℹ 210 more rows
# ℹ 7 more variables: aggLevel_1 <chr>, aggfun_2 <chr>, aggLevel_2 <chr>,
# aggfun_3 <chr>, aggLevel_3 <chr>, aggfun_4 <chr>, aggLevel_4 <chr>
And a quick plot of that to see the different spatial units (though this example is all in New South Wales so other states have no data).
state_agg$state |>
plot_outcomes(
outcome_col = "ewr_achieved",
plot_type = "map",
colorgroups = NULL,
colorset = "ewr_achieved",
pal_list = list("scico::lapaz"),
pal_direction = -1,
facet_col = "scenario",
facet_row = "Target",
sceneorder = c("down4", "base", "up4")
)