From 083198f81ee4ffd2a6a394c2851e6644836ce070 Mon Sep 17 00:00:00 2001 From: jospueyo Date: Sat, 10 Dec 2022 07:42:19 +0100 Subject: [PATCH 1/2] create pkgdown --- .Rbuildignore | 3 +++ .github/workflows/pkgdown.yaml | 46 ++++++++++++++++++++++++++++++++++ .gitignore | 1 + DESCRIPTION | 3 ++- _pkgdown.yml | 4 +++ 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pkgdown.yaml create mode 100644 _pkgdown.yml diff --git a/.Rbuildignore b/.Rbuildignore index 5c4a4c5..bb39324 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -10,3 +10,6 @@ ^cran-comments\.md$ ^CRAN-SUBMISSION$ ^codecov\.yml$ +^_pkgdown\.yml$ +^docs$ +^pkgdown$ diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..087f0b0 --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,46 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + release: + types: [published] + workflow_dispatch: + +name: pkgdown + +jobs: + pkgdown: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website + + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.4.1 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.gitignore b/.gitignore index 2490473..fcd0e72 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ todo.txt unit_test.R inst/doc /Meta/ +docs diff --git a/DESCRIPTION b/DESCRIPTION index 29650a6..7499651 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,5 +29,6 @@ Suggests: testthat (>= 3.0.0) Config/testthat/edition: 3 VignetteBuilder: knitr -URL: https://github.com/icra/ediblecity +URL: https://github.com/icra/ediblecity, + https://icra.github.io/ediblecity/ BugReports: https://github.com/icra/ediblecity/issues diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000..8602116 --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,4 @@ +url: https://icra.github.io/ediblecity/ +template: + bootstrap: 5 + From 21ef4b949d162aa58fdb60000b0607b5011fa0b9 Mon Sep 17 00:00:00 2001 From: jospueyo Date: Sun, 11 Dec 2022 21:33:27 +0100 Subject: [PATCH 2/2] build pkgdown --- DESCRIPTION | 2 +- doc/index.html | 514 --------------------------- doc/{index.Rmd => zzz_index_old.Rmd} | 0 3 files changed, 1 insertion(+), 515 deletions(-) delete mode 100644 doc/index.html rename doc/{index.Rmd => zzz_index_old.Rmd} (100%) diff --git a/DESCRIPTION b/DESCRIPTION index 7499651..7efef65 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,7 +13,7 @@ Description: The purpose of this package is to estimate the potential of urban a License: MIT + file LICENSE Encoding: UTF-8 LazyData: true -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 Imports: sf (>= 0.9), dplyr (>= 1.0.6), diff --git a/doc/index.html b/doc/index.html deleted file mode 100644 index 0cb6dfa..0000000 --- a/doc/index.html +++ /dev/null @@ -1,514 +0,0 @@ - - - - - - - - - - - - - - -ediblecity - - - - - - - - - - - - - - - - - - - - - - - - - - -

ediblecity

- - - -
library(ediblecity)
-
-

Set scenarios of urban agriculture

-

The function set_scenario provides a convenient way to -create randomized scenarios for urban agriculture. We use the -city_example provided with the package that is meant to -serve as example to create a model for a city of interest.

-

We create one scenario, with 50% of normal gardens, vacant plot, -streets and 75% of rooftops converted to edible_gardens. And with 50% of -created gardens being for commercial purposes. To see the correspondence -between original and urban agriculture elements, see -?set_scenario.

-

-scenario <- set_scenario(city_example,
-                           pGardens = 0.5,
-                           pVacant = 0.5,
-                           pRooftop = 0.75,
-                           private_gardens_from = "Normal garden",
-                           vacant_from = c("Vacant", "Streets"),
-                           rooftop_from = "Rooftop",
-                           pCommercial = 0.5)
-#> Warning: Only 328 rooftops out of 453 assumed satisfy the 'min_area_rooftop'
-

The warnings are triggered when there are not elements enough to -fulfill the proportions provided to the function.

-

in this examples, we use the scenario created with -set_scenario, but all the indicators can be calculated -using an sf object with the same structure as -city_example.

-

Likewise, all the parameters used by the indicators are defined in -city_functions. However, all indicators provide an option -to override this an provide a customized dataframe with the parameters. -The structure of this dataframe is detailed in the documentation of each -function.

-
-
-

Estimate the benefits of urban agriculture

-
-

Urban Heat Island

-

The urban heat island indicator can return a summary of values or a -stars object. It needs a raster representing the Sky view -factor. See ?UHI for more details. We use the -SVF object provided with the package.

-
UHI(scenario, SVF)
-#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-#>  0.0000  0.5317  0.8784  0.9656  1.2473  2.5867
-
plot(UHI(scenario, SVF, return_raster = TRUE))
-

-
-
-

Runoff prevention

-

The function runoff_prev returns an estimation of the -runoff in the city after a specific rain event (mm/day). It also -estimates the total rainfall and the rainwater harvested by urban -agriculture.

-
runoff_prev(scenario)
-#>       runoff     rainfall  rainharvest 
-#>     36.20026 108169.04500   1522.46592
-
-
-

Distance to closest green area

-

The function green_distance computes the distances from -each home in the city to its closest public green area larger than a -specific area. The homes must be identified using the column passed to -residence_col. The default values for minimal area (0.5 ha) -and for maximum distance (300 meters) follow the recommendations of -WHO.

-

-green_distance(scenario)
-#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-#>    6.12  155.08  251.70  249.72  347.42  465.73
-

If percent_out is set to TRUE, instead of a -summary of distances, it returns the percentage of homes that are -further than max_dist.

-
green_distance(scenario, percent_out = TRUE)
-#> [1] 36.92615
-
-
-

Green per capita

-

The function green_capita calculates the amount of -public and/or private green are per capita in the city. It can compute -the total of the city, the values for each neighbourhood or the ratio -between the neighbourhoods with minimum and maximum value (min / -max).

-
green_capita(scenario, inhabitants = 6000)
-#> [1] 10.791
-
-green_capita(scenario, 
-             neighbourhoods = neighbourhoods_example, 
-             inh_col = 'inhabitants',
-             name_col = 'name',
-             verbose = TRUE)
-#> # A tibble: 2 × 4
-#>   name              area inhabitants green_capita
-#>   <chr>            <dbl>       <dbl>        <dbl>
-#> 1 Sant Narcís nord 35044        1028        34.1 
-#> 2 Sant Narcís sud  35174        5290         6.65
-
-green_capita(scenario, 
-             neighbourhoods = neighbourhoods_example, 
-             inh_col = 'inhabitants',
-             name_col = 'name')
-#> [1] 0.1950498
-
-
-

Nitrogen dioxide (NO2) sequestered by urban green

-

The function no2_seq computes the amount of -NO2 sequestered by urban green in gr/s.

-

-no2_seq(scenario)
-#>     gr/s 
-#> 115.5802
-
-
-

Jobs created by commercial urban agriculture

-

The function edible_jobs estimates the number of jobs -potentially created by commercial urban agriculture. Since the number of -jobs / m2 is randomized, it computes a Monte Carlo simulation (n=1000) -to estimate the value and returns the confidence interval (unless -verbose = TRUE).

-
edible_jobs(scenario)
-#>        5%       50%       95% 
-#>  162.4316 1658.5263 3277.1482
-
-
-

Volunteers involved in community urban agriculture

-

The function edible_volunteers estimates the number of -volunteers potentially involved in community urban agriculture. Since -the number of volunteers / m2 is randomized, it computes a Monte Carlo -simulation (n=1000) to estimate the value and returns the confidence -interval (unless verbose = TRUE).

-
edible_volunteers(scenario)
-#>       5%      50%      95% 
-#>  274.195 2319.221 4412.050
-
-
-

Food production

-

The function food_production estimates the food produced -by urban agriculture (in kg/year). Since the productivity of each plot -is randomized, It computes a Monte Carlo simulation (n=1000) to estimate -the value and returns the confidence interval (unless -verbose = TRUE).

-
food_production(scenario)
-#>        5%       50%       95% 
-#>  671398.9  905388.1 1154224.4
-
-
-
-

Randomization

-

The construction of scenarios as well as some parameters in the -indicators are randomized to consider uncertainty. Our recommendation is -to run each scenario you want to simulate in a Monte Carlo simulation to -get the confidence interval for each indicator. You will find a -practical implementation here.

-
- - - - - - - - - - - diff --git a/doc/index.Rmd b/doc/zzz_index_old.Rmd similarity index 100% rename from doc/index.Rmd rename to doc/zzz_index_old.Rmd