├── .Rbuildignore ├── .github └── workflows │ └── rhub.yaml ├── .gitignore ├── DESCRIPTION ├── NAMESPACE ├── NEWS.md ├── R ├── RcppExports.R ├── concentration.R ├── data_Groningen.R ├── data_insurance.R ├── data_knmi_historic.R ├── data_nl_gemeente.R ├── deprecated.R ├── deprecated_highest_concentration.R ├── haversine.R ├── highest_concentration_terra.R ├── map_choropleth.R ├── map_ggplot2.R ├── map_plot_points.R ├── points_in_circle.R ├── points_to_polygon.R ├── smooth_sphere.R ├── utils.R └── zzz.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── cran-comments.md ├── data ├── Groningen.rda ├── insurance.rda ├── knmi_stations.rda ├── nl_corop.rda ├── nl_gemeente.rda ├── nl_postcode2.rda ├── nl_postcode3.rda ├── nl_postcode4.rda └── nl_provincie.rda ├── docs ├── 404.html ├── apple-touch-icon-120x120.png ├── apple-touch-icon-152x152.png ├── apple-touch-icon-180x180.png ├── apple-touch-icon-60x60.png ├── apple-touch-icon-76x76.png ├── apple-touch-icon.png ├── authors.html ├── bootstrap-toc.css ├── bootstrap-toc.js ├── deps │ ├── Open_Sans-0.4.10 │ │ ├── font.css │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4gaVI.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4iaVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4jaVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4kaVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4saVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4taVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4uaVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4vaVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5OaVIGxA.woff2 │ │ └── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5caVIGxA.woff2 │ ├── Open_Sans-0.4.9 │ │ ├── font.css │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4gaVI.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4iaVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4jaVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4kaVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4saVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4taVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4uaVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4vaVIGxA.woff2 │ │ ├── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5OaVIGxA.woff2 │ │ └── memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5caVIGxA.woff2 │ ├── bootstrap-5.3.1 │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ └── bootstrap.min.css │ ├── bootstrap-toc-1.0.1 │ │ └── bootstrap-toc.min.js │ ├── clipboard.js-2.0.11 │ │ └── clipboard.min.js │ ├── data-deps.txt │ ├── font-awesome-6.4.2 │ │ ├── css │ │ │ ├── all.css │ │ │ ├── all.min.css │ │ │ ├── v4-shims.css │ │ │ └── v4-shims.min.css │ │ └── webfonts │ │ │ ├── fa-brands-400.ttf │ │ │ ├── fa-brands-400.woff2 │ │ │ ├── fa-regular-400.ttf │ │ │ ├── fa-regular-400.woff2 │ │ │ ├── fa-solid-900.ttf │ │ │ ├── fa-solid-900.woff2 │ │ │ ├── fa-v4compatibility.ttf │ │ │ └── fa-v4compatibility.woff2 │ ├── font-awesome-6.5.2 │ │ ├── css │ │ │ ├── all.css │ │ │ ├── all.min.css │ │ │ ├── v4-shims.css │ │ │ └── v4-shims.min.css │ │ └── webfonts │ │ │ ├── fa-brands-400.ttf │ │ │ ├── fa-brands-400.woff2 │ │ │ ├── fa-regular-400.ttf │ │ │ ├── fa-regular-400.woff2 │ │ │ ├── fa-solid-900.ttf │ │ │ ├── fa-solid-900.woff2 │ │ │ ├── fa-v4compatibility.ttf │ │ │ └── fa-v4compatibility.woff2 │ ├── headroom-0.11.0 │ │ ├── headroom.min.js │ │ └── jQuery.headroom.min.js │ ├── jquery-3.6.0 │ │ ├── jquery-3.6.0.js │ │ ├── jquery-3.6.0.min.js │ │ └── jquery-3.6.0.min.map │ └── search-1.0.0 │ │ ├── autocomplete.jquery.min.js │ │ ├── fuse.min.js │ │ └── mark.min.js ├── docsearch.css ├── docsearch.js ├── favicon-16x16.png ├── favicon-32x32.png ├── favicon.ico ├── index.html ├── katex-auto.js ├── lightswitch.js ├── link.svg ├── logo.png ├── news │ └── index.html ├── package-logo.png ├── pkgdown.css ├── pkgdown.js ├── pkgdown.yml ├── reference │ ├── Groningen.html │ ├── cells_above_threshold.html │ ├── choropleth-1.png │ ├── choropleth.html │ ├── choropleth_ggplot2-1.png │ ├── choropleth_ggplot2.html │ ├── conc_per_cell_new.html │ ├── concentration.html │ ├── convert_crs_df.html │ ├── convert_df_to_sf.html │ ├── figures │ │ ├── example3a-1.png │ │ ├── nl_choro1.png │ │ ├── nl_choro2.png │ │ ├── unnamed-chunk-11-1.png │ │ └── unnamed-chunk-9-1.png │ ├── find_highest_concentration.html │ ├── haversine.html │ ├── highest_conc.html │ ├── highest_concentration.html │ ├── index.html │ ├── insurance.html │ ├── interpolate_spline.html │ ├── knmi_historic_data.html │ ├── knmi_stations.html │ ├── map_points_to_cells.html │ ├── mw_create.html │ ├── neighborhood_gh_search.html │ ├── nl_corop.html │ ├── nl_gemeente.html │ ├── nl_postcode2.html │ ├── nl_postcode3.html │ ├── nl_postcode4.html │ ├── nl_provincie.html │ ├── plot.conc.html │ ├── plot.concentration.html │ ├── plot.html │ ├── plot_points.html │ ├── points_in_circle.html │ ├── points_in_circle_vec.html │ ├── points_to_polygon.html │ ├── top_n_focals.html │ ├── update_db.html │ ├── update_focal.html │ └── update_rasterize.html ├── search.json └── sitemap.xml ├── logo.png ├── man ├── Groningen.Rd ├── cells_above_threshold.Rd ├── choropleth.Rd ├── choropleth_ggplot2.Rd ├── conc_per_cell_new.Rd ├── concentration.Rd ├── convert_crs_df.Rd ├── convert_df_to_sf.Rd ├── figures │ ├── example3a-1.png │ ├── nl_choro1.png │ ├── nl_choro2.png │ ├── unnamed-chunk-11-1.png │ └── unnamed-chunk-9-1.png ├── find_highest_concentration.Rd ├── haversine.Rd ├── highest_conc.Rd ├── highest_concentration.Rd ├── insurance.Rd ├── interpolate_spline.Rd ├── knmi_historic_data.Rd ├── knmi_stations.Rd ├── map_points_to_cells.Rd ├── mw_create.Rd ├── neighborhood_gh_search.Rd ├── nl_corop.Rd ├── nl_gemeente.Rd ├── nl_postcode2.Rd ├── nl_postcode3.Rd ├── nl_postcode4.Rd ├── nl_provincie.Rd ├── plot.Rd ├── plot.conc.Rd ├── plot.concentration.Rd ├── plot_points.Rd ├── points_in_circle.Rd ├── points_in_circle_vec.Rd ├── points_to_polygon.Rd ├── top_n_focals.Rd ├── update_db.Rd ├── update_focal.Rd └── update_rasterize.Rd ├── pkgdown └── favicon │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ ├── apple-touch-icon-180x180.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ └── favicon.ico ├── spatialrisk.Rproj ├── src ├── .gitignore ├── RcppExports.cpp ├── RcppExports.o ├── haversine_cpp.cpp ├── haversine_cpp.o └── spatialrisk.so └── tests ├── testthat.R └── testthat ├── test_concentration.R ├── test_haversine.R └── test_pointsincircle.R /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^CRAN-RELEASE$ 2 | ^.*\.Rproj$ 3 | ^\.Rproj\.user$ 4 | ^packrat/ 5 | ^\.Rprofile$ 6 | ^README\.Rmd$ 7 | ^README\.md$ 8 | ^README-.*\.png$ 9 | ^cran-comments\.md$ 10 | ^_pkgdown\.yml$ 11 | ^docs$ 12 | ^pkgdown$ 13 | ^logo.png 14 | ^CRAN-SUBMISSION$ 15 | ^\.github$ 16 | -------------------------------------------------------------------------------- /.github/workflows/rhub.yaml: -------------------------------------------------------------------------------- 1 | # R-hub's generic GitHub Actions workflow file. It's canonical location is at 2 | # https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml 3 | # You can update this file to a newer version using the rhub2 package: 4 | # 5 | # rhub::rhub_setup() 6 | # 7 | # It is unlikely that you need to modify this file manually. 8 | 9 | name: R-hub 10 | run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" 11 | 12 | on: 13 | workflow_dispatch: 14 | inputs: 15 | config: 16 | description: 'A comma separated list of R-hub platforms to use.' 17 | type: string 18 | default: 'linux,windows,macos' 19 | name: 20 | description: 'Run name. You can leave this empty now.' 21 | type: string 22 | id: 23 | description: 'Unique ID. You can leave this empty now.' 24 | type: string 25 | 26 | jobs: 27 | 28 | setup: 29 | runs-on: ubuntu-latest 30 | outputs: 31 | containers: ${{ steps.rhub-setup.outputs.containers }} 32 | platforms: ${{ steps.rhub-setup.outputs.platforms }} 33 | 34 | steps: 35 | # NO NEED TO CHECKOUT HERE 36 | - uses: r-hub/actions/setup@v1 37 | with: 38 | config: ${{ github.event.inputs.config }} 39 | id: rhub-setup 40 | 41 | linux-containers: 42 | needs: setup 43 | if: ${{ needs.setup.outputs.containers != '[]' }} 44 | runs-on: ubuntu-latest 45 | name: ${{ matrix.config.label }} 46 | strategy: 47 | fail-fast: false 48 | matrix: 49 | config: ${{ fromJson(needs.setup.outputs.containers) }} 50 | container: 51 | image: ${{ matrix.config.container }} 52 | 53 | steps: 54 | - uses: r-hub/actions/checkout@v1 55 | - uses: r-hub/actions/platform-info@v1 56 | with: 57 | token: ${{ secrets.RHUB_TOKEN }} 58 | job-config: ${{ matrix.config.job-config }} 59 | - uses: r-hub/actions/setup-deps@v1 60 | with: 61 | token: ${{ secrets.RHUB_TOKEN }} 62 | job-config: ${{ matrix.config.job-config }} 63 | - uses: r-hub/actions/run-check@v1 64 | with: 65 | token: ${{ secrets.RHUB_TOKEN }} 66 | job-config: ${{ matrix.config.job-config }} 67 | 68 | other-platforms: 69 | needs: setup 70 | if: ${{ needs.setup.outputs.platforms != '[]' }} 71 | runs-on: ${{ matrix.config.os }} 72 | name: ${{ matrix.config.label }} 73 | strategy: 74 | fail-fast: false 75 | matrix: 76 | config: ${{ fromJson(needs.setup.outputs.platforms) }} 77 | 78 | steps: 79 | - uses: r-hub/actions/checkout@v1 80 | - uses: r-hub/actions/setup-r@v1 81 | with: 82 | job-config: ${{ matrix.config.job-config }} 83 | token: ${{ secrets.RHUB_TOKEN }} 84 | - uses: r-hub/actions/platform-info@v1 85 | with: 86 | token: ${{ secrets.RHUB_TOKEN }} 87 | job-config: ${{ matrix.config.job-config }} 88 | - uses: r-hub/actions/setup-deps@v1 89 | with: 90 | job-config: ${{ matrix.config.job-config }} 91 | token: ${{ secrets.RHUB_TOKEN }} 92 | - uses: r-hub/actions/run-check@v1 93 | with: 94 | job-config: ${{ matrix.config.job-config }} 95 | token: ${{ secrets.RHUB_TOKEN }} 96 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | packrat/lib*/ 2 | .Rproj.user 3 | 4 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: spatialrisk 2 | Type: Package 3 | Title: Calculating Spatial Risk 4 | Version: 0.7.2.9000 5 | Authors@R: c(person("Martin", "Haringa", role = c("aut", "cre"), 6 | email = "mtharinga@gmail.com")) 7 | Maintainer: Martin Haringa 8 | BugReports: https://github.com/mharinga/spatialrisk/issues 9 | Description: Methods for spatial risk calculations. It offers an efficient 10 | approach to determine the sum of all observations within a circle of a 11 | certain radius. This might be beneficial for insurers who are required (by 12 | a recent European Commission regulation) to determine the maximum value of 13 | insured fire risk policies of all buildings that are partly or fully located 14 | within a circle of a radius of 200m. See Church (1974) 15 | for a description of the problem. 16 | License: GPL (>= 2) 17 | URL: https://github.com/mharinga/spatialrisk, https://mharinga.github.io/spatialrisk/ 18 | LazyData: true 19 | LinkingTo: Rcpp, RcppProgress 20 | Imports: 21 | classInt, 22 | data.table, 23 | dplyr, 24 | fs, 25 | ggplot2, 26 | lifecycle, 27 | mapview, 28 | Rcpp, 29 | RcppProgress, 30 | rlang, 31 | sf, 32 | terra, 33 | tmap, 34 | units, 35 | viridis 36 | Depends: R (>= 4.1.0) 37 | Encoding: UTF-8 38 | RoxygenNote: 7.3.2 39 | Suggests: 40 | colourvalues, 41 | GenSA, 42 | geohashTools, 43 | knitr, 44 | leafem, 45 | leafgl, 46 | leaflet, 47 | mgcv, 48 | rmarkdown, 49 | testthat, 50 | vroom 51 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(plot,conc) 4 | S3method(plot,concentration) 5 | S3method(plot,neighborhood) 6 | S3method(print,concentration) 7 | export(choropleth) 8 | export(choropleth_ggplot2) 9 | export(concentration) 10 | export(convert_crs_df) 11 | export(find_highest_concentration) 12 | export(haversine) 13 | export(highest_concentration) 14 | export(interpolate_spline) 15 | export(knmi_historic_data) 16 | export(neighborhood_gh_search) 17 | export(plot_points) 18 | export(points_in_circle) 19 | export(points_in_circle_vec) 20 | export(points_to_polygon) 21 | import(RcppProgress) 22 | import(data.table) 23 | import(viridis) 24 | importFrom(Rcpp,evalCpp) 25 | importFrom(Rcpp,sourceCpp) 26 | importFrom(classInt,classIntervals) 27 | importFrom(data.table,data.table) 28 | importFrom(data.table,melt) 29 | importFrom(data.table,rbindlist) 30 | importFrom(data.table,setDT) 31 | importFrom(data.table,setkey) 32 | importFrom(data.table,setnames) 33 | importFrom(data.table,setorder) 34 | importFrom(dplyr,left_join) 35 | importFrom(fs,dir_create) 36 | importFrom(fs,dir_delete) 37 | importFrom(fs,dir_ls) 38 | importFrom(fs,file_create) 39 | importFrom(fs,file_size) 40 | importFrom(fs,file_temp) 41 | importFrom(fs,path) 42 | importFrom(ggplot2,aes) 43 | importFrom(ggplot2,coord_sf) 44 | importFrom(ggplot2,geom_sf) 45 | importFrom(ggplot2,ggplot) 46 | importFrom(ggplot2,labs) 47 | importFrom(ggplot2,scale_fill_viridis_c) 48 | importFrom(ggplot2,scale_fill_viridis_d) 49 | importFrom(ggplot2,theme_void) 50 | importFrom(grDevices,hcl.colors) 51 | importFrom(lifecycle,deprecate_warn) 52 | importFrom(mapview,mapview) 53 | importFrom(rlang,abort) 54 | importFrom(sf,st_as_sf) 55 | importFrom(sf,st_buffer) 56 | importFrom(sf,st_coordinates) 57 | importFrom(sf,st_drop_geometry) 58 | importFrom(sf,st_geometry) 59 | importFrom(sf,st_intersects) 60 | importFrom(sf,st_join) 61 | importFrom(sf,st_transform) 62 | importFrom(stats,as.formula) 63 | importFrom(terra,cellFromXY) 64 | importFrom(terra,cells) 65 | importFrom(terra,classify) 66 | importFrom(terra,crop) 67 | importFrom(terra,distance) 68 | importFrom(terra,ext) 69 | importFrom(terra,focal) 70 | importFrom(terra,merge) 71 | importFrom(terra,rast) 72 | importFrom(terra,rasterize) 73 | importFrom(terra,res) 74 | importFrom(terra,trim) 75 | importFrom(terra,values) 76 | importFrom(terra,vect) 77 | importFrom(terra,xres) 78 | importFrom(terra,xyFromCell) 79 | importFrom(tmap,tm_basemap) 80 | importFrom(tmap,tm_compass) 81 | importFrom(tmap,tm_layout) 82 | importFrom(tmap,tm_polygons) 83 | importFrom(tmap,tm_scale_bar) 84 | importFrom(tmap,tm_shape) 85 | importFrom(tmap,tmap_mode) 86 | importFrom(utils,capture.output) 87 | importFrom(utils,data) 88 | importFrom(utils,download.file) 89 | importFrom(utils,head) 90 | importFrom(utils,setTxtProgressBar) 91 | importFrom(utils,txtProgressBar) 92 | useDynLib(spatialrisk) 93 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # spatialrisk (development version) 2 | 3 | 4 | # spatialrisk 0.7.2 5 | 6 | * Introduced `find_highest_concentration()`: a faster and more accurate alternative to `highest_concentration()`, leveraging focal statistics for optimal results. 7 | * Deprecated `highest_concentration()` in favor of the new, improved function. 8 | * Updated `plot_points()` to utilize `mapview::mapview()` for enhanced interactive map visualizations. 9 | * Revised the README to reflect these new features and updates. 10 | 11 | # spatialrisk 0.7.1 12 | 13 | * `plot_points()` now returns a warning when a specific provider tile is not available. 14 | 15 | # spatialrisk 0.7.0 16 | 17 | * `neighborhood_gh_search()` now returns a more precise outcome when the radius of the circle is not equal to 200m. 18 | * `sf::st_crs()` is used for `sf` objects to not show the message that old crs is detected anymore. 19 | 20 | # spatialrisk 0.6.9 21 | 22 | * `highest_concentration()` now returns correct highest concentration when the circle of the highest concentration overlaps more than one geohash. 23 | * `plot.concentration()` now handles many lon/lat pairs better. 24 | 25 | # spatialrisk 0.6.8 26 | 27 | * `highest_concentration()` is added to do a fast search for the coordinates of the highest concentration. 28 | * `neighborhood_gh_search()` is added to look for even higher concentrations in the neighborhood of the coordinates found by `highest_concentration()`. 29 | 30 | # spatialrisk 0.6.7 31 | 32 | * A package website is added using pkgdown. 33 | * `concentration()` and `points_in_circle()` now return error messages when the data does not contain columns for `lon` and `lat`. 34 | * `concentration()` and `points_in_circle()` have updated documentation. 35 | * `haversine()` now returns NA when coordinates are missing. 36 | 37 | # spatialrisk 0.6.6 38 | 39 | * `points_to_polygon()` is updated to keep spatialrisk and a new version of dplyr working together smoothly. 40 | 41 | # spatialrisk 0.6.5 42 | 43 | * `knmi_historic_data()` and `knmi_stations()` are added to retrieve data from weather stations in the Netherlands. 44 | 45 | # spatialrisk 0.6.4 46 | 47 | * `interpolate_krige()` and `interpolate_spline()` are added for interpolation and smoothing on the sphere. 48 | 49 | # spatialrisk 0.6.3 50 | 51 | * Data sets `nl_corop()`, `nl_gemeente()`, `nl_postcode1()`, `nl_postcode2()`, `nl_postcode3()`, `nl_postcode4()`, and `nl_provincie()` now contain columns `longitude` and `latitude` for the centroid of the polygons. 52 | 53 | # spatialrisk 0.6.2 54 | 55 | * Non UTF-8 character removed from column `areaname` in data set `nl_gemeente()`. 56 | * In `choropleth()`, `n` specifies the number of clusters in a map. 57 | * In data sets `nl_corop()`, `nl_gemeente()`, `nl_postcode1()`, `nl_postcode2()`, `nl_postcode3()`, `nl_postcode4()`, and `nl_provincie`, column `areaname` now refers to the region. 58 | 59 | # spatialrisk 0.6.1 60 | 61 | * In `points_to_polygon()`, `outside_print` shows the points that are not within any polygon. 62 | 63 | # spatialrisk 0.6.0 64 | 65 | * `points_to_polygon()` is added. 66 | * Data sets `europe_countries()` and `world_countries()` are added. 67 | 68 | # spatialrisk 0.5.1 69 | 70 | * In `concentration()` the algorithm for testing if a point is inside a circle is updated by testing whether the point is inside a square diamond inside the square. 71 | 72 | # spatialrisk 0.3.1 73 | 74 | * `NEWS.md` is added to track changes to the package. 75 | -------------------------------------------------------------------------------- /R/RcppExports.R: -------------------------------------------------------------------------------- 1 | # Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | haversine_cpp_vec <- function(latFrom, lonFrom, latTo, lonTo, earth_radius) { 5 | .Call('_spatialrisk_haversine_cpp_vec', PACKAGE = 'spatialrisk', latFrom, lonFrom, latTo, lonTo, earth_radius) 6 | } 7 | 8 | haversine_loop_cpp <- function(x, lat_center, lon_center, radius = 200) { 9 | .Call('_spatialrisk_haversine_loop_cpp', PACKAGE = 'spatialrisk', x, lat_center, lon_center, radius) 10 | } 11 | 12 | concentration_loop_cpp <- function(sub, ref, radius = 200, display_progress = TRUE) { 13 | .Call('_spatialrisk_concentration_loop_cpp', PACKAGE = 'spatialrisk', sub, ref, radius, display_progress) 14 | } 15 | 16 | block_loop_cpp <- function(sub, ref, radius = 200, display_progress = TRUE) { 17 | .Call('_spatialrisk_block_loop_cpp', PACKAGE = 'spatialrisk', sub, ref, radius, display_progress) 18 | } 19 | 20 | concentration_loop_cpp2 <- function(sub, ref, radius = 200) { 21 | .Call('_spatialrisk_concentration_loop_cpp2', PACKAGE = 'spatialrisk', sub, ref, radius) 22 | } 23 | 24 | one_lon_in_meters <- function(lat0) { 25 | .Call('_spatialrisk_one_lon_in_meters', PACKAGE = 'spatialrisk', lat0) 26 | } 27 | 28 | add_cell_bounds_cpp <- function(df, size = 50, radius = 200) { 29 | .Call('_spatialrisk_add_cell_bounds_cpp', PACKAGE = 'spatialrisk', df, size, radius) 30 | } 31 | 32 | seq_cpp <- function(from, to, length_out) { 33 | .Call('_spatialrisk_seq_cpp', PACKAGE = 'spatialrisk', from, to, length_out) 34 | } 35 | 36 | expand_grid_cpp <- function(seq1, seq2) { 37 | .Call('_spatialrisk_expand_grid_cpp', PACKAGE = 'spatialrisk', seq1, seq2) 38 | } 39 | 40 | filter_full_cpp <- function(dffull, subb, i) { 41 | .Call('_spatialrisk_filter_full_cpp', PACKAGE = 'spatialrisk', dffull, subb, i) 42 | } 43 | 44 | highest_indices_cpp <- function(x, n) { 45 | .Call('_spatialrisk_highest_indices_cpp', PACKAGE = 'spatialrisk', x, n) 46 | } 47 | 48 | max_conc_per_cell_cpp <- function(dfsub, dffull, points = 50L, size = 50L, radius = 200) { 49 | .Call('_spatialrisk_max_conc_per_cell_cpp', PACKAGE = 'spatialrisk', dfsub, dffull, points, size, radius) 50 | } 51 | 52 | haversine_loop_cpp0 <- function(x, lat_centers, lon_centers, radius = 200) { 53 | .Call('_spatialrisk_haversine_loop_cpp0', PACKAGE = 'spatialrisk', x, lat_centers, lon_centers, radius) 54 | } 55 | 56 | -------------------------------------------------------------------------------- /R/concentration.R: -------------------------------------------------------------------------------- 1 | #' Concentration calculation 2 | #' 3 | #' @description Calculates the concentration, which is the sum of all 4 | #' observations within a circle of a certain radius. 5 | #' 6 | #' @param sub data.frame of target points to calculate concentration risk for, 7 | #' including at least columns for longitude and latitude. 8 | #' @param full data.frame containing reference points, where the function finds 9 | #' locations within a radius from the target points. Should include at least 10 | #' columns for longitude, latitude, and the value of interest to summarize. 11 | #' @param value column name with value of interest to summarize in \code{full}. 12 | #' @param lon_sub column name in \code{sub} for longitude 13 | #' (default is \code{lon}). 14 | #' @param lat_sub column name in \code{sub} for latitude 15 | #' (default is \code{lat}). 16 | #' @param lon_full column name in \code{full} for longitude in \code{full} 17 | #' (default is \code{lon}). 18 | #' @param lat_full column name in \code{full} for latitude in \code{full} 19 | #' (default is \code{lat}). 20 | #' @param radius numeric. Radius of the circle in meters (default is 200). 21 | #' @param display_progress boolean indicating whether to show progress bar 22 | #' (TRUE/FALSE). Defaults to TRUE. 23 | #' 24 | #' @return A data.frame equal to \code{sub} including an additional 25 | #' column \code{concentration}. 26 | #' 27 | #' @useDynLib spatialrisk 28 | #' @importFrom Rcpp sourceCpp 29 | #' @importFrom Rcpp evalCpp 30 | #' @import RcppProgress 31 | #' @importFrom rlang abort 32 | #' 33 | #' @author Martin Haringa 34 | #' 35 | #' @examples 36 | #' df <- data.frame(location = c("p1", "p2"), lon = c(6.561561, 6.561398), 37 | #' lat = c(53.21369, 53.21326)) 38 | #' concentration(df, Groningen, value = amount, radius = 100) 39 | #' 40 | #' @export 41 | concentration <- function(sub, full, value, 42 | lon_sub = lon, lat_sub = lat, 43 | lon_full = lon, lat_full = lat, 44 | radius = 200, display_progress = TRUE) { 45 | 46 | if (!is.numeric(radius) || radius <= 0) { 47 | msg <- paste0("Can't find concentrations with `radius = ", radius, "`.") 48 | error_msg <- paste0("`radius` is not a positive number.") 49 | rlang::abort(c(msg, "x" = error_msg), call = NULL) 50 | } 51 | 52 | # Turn into character vector 53 | sub_name <- deparse(substitute(sub)) 54 | full_name <- deparse(substitute(full)) 55 | lon_sub <- deparse(substitute(lon_sub)) 56 | lat_sub <- deparse(substitute(lat_sub)) 57 | lon_full <- deparse(substitute(lon_full)) 58 | lat_full <- deparse(substitute(lat_full)) 59 | value <- deparse(substitute(value)) 60 | 61 | if (!all(c(lon_sub, lat_sub) %in% names(sub))) { 62 | stop(paste0(sub_name, " does not contain columns ", lon_sub, " and ", 63 | lat_sub), call. = FALSE) 64 | } 65 | 66 | if (!all(c(lon_full, lat_full) %in% names(full))) { 67 | stop(paste0(full_name, " does not contain columns ", lon_full, " and ", 68 | lat_full), call. = FALSE) 69 | } 70 | 71 | if (!all(is.numeric(c(sub[[lon_sub]], sub[[lat_sub]], full[[lon_full]], 72 | full[[lat_full]], full[[value]])))) { 73 | stop(paste0("the following variables should be numeric: ", lon_sub, ", ", 74 | lat_sub, ", ", lon_full, ", ", lat_full, ", ", value), 75 | call. = FALSE) 76 | } 77 | 78 | sub_df <- data.frame("lon" = sub[[lon_sub]], "lat" = sub[[lat_sub]]) 79 | full_df <- data.frame("lon" = full[[lon_full]], "lat" = full[[lat_full]], 80 | "value" = full[[value]]) 81 | 82 | concentration_df <- concentration_loop_cpp(sub_df, full_df, radius, 83 | display_progress) 84 | 85 | sub$concentration <- concentration_df$cumulation 86 | sub 87 | } 88 | 89 | #' @keywords internal 90 | concentration_ <- function(sub, full, value, 91 | lon_sub = lon, lat_sub = lat, 92 | lon_full = lon, lat_full = lat, 93 | radius = 200, display_progress = TRUE) { 94 | 95 | if (!is.numeric(radius) || radius <= 0) { 96 | msg <- paste0("Can't find concentrations with `radius = ", radius, "`.") 97 | error_msg <- paste0("`radius` is not a positive number.") 98 | rlang::abort(c(msg, "x" = error_msg), call = NULL) 99 | } 100 | 101 | # Turn into character vector 102 | sub_name <- deparse(substitute(sub)) 103 | full_name <- deparse(substitute(full)) 104 | 105 | if (!all(c(lon_sub, lat_sub) %in% names(sub))) { 106 | stop(paste0(sub_name, " does not contain columns ", lon_sub, " and ", 107 | lat_sub), call. = FALSE) 108 | } 109 | 110 | if (!all(c(lon_full, lat_full) %in% names(full))) { 111 | stop(paste0(full_name, " does not contain columns ", lon_full, " and ", 112 | lat_full), call. = FALSE) 113 | } 114 | 115 | if (!all(is.numeric(c(sub[[lon_sub]], sub[[lat_sub]], full[[lon_full]], 116 | full[[lat_full]], full[[value]])))) { 117 | stop(paste0("the following variables should be numeric: ", lon_sub, ", ", 118 | lat_sub, ", ", lon_full, ", ", lat_full, ", ", value), 119 | call. = FALSE) 120 | } 121 | 122 | sub_df <- data.frame("lon" = sub[[lon_sub]], "lat" = sub[[lat_sub]]) 123 | full_df <- data.frame("lon" = full[[lon_full]], "lat" = full[[lat_full]], 124 | "value" = full[[value]]) 125 | 126 | concentration_df <- concentration_loop_cpp(sub_df, full_df, radius, 127 | display_progress) 128 | 129 | sub$concentration <- concentration_df$cumulation 130 | sub 131 | } 132 | -------------------------------------------------------------------------------- /R/data_Groningen.R: -------------------------------------------------------------------------------- 1 | #' Coordinates of houses in Groningen 2 | #' 3 | #' A dataset of postal codes and the corresponding spatial locations in terms of 4 | #' a latitude and a longitude. 5 | #' 6 | #' @format A data frame with 25000 rows and 8 variables: 7 | #' \describe{ 8 | #' \item{street}{Name of street} 9 | #' \item{number}{Number of house} 10 | #' \item{letter}{Letter of house} 11 | #' \item{suffix}{Suffix to number of house} 12 | #' \item{postal_code}{Postal code of house} 13 | #' \item{city}{The name of the city} 14 | #' \item{lon}{Longitude (in degrees)} 15 | #' \item{lat}{Latitude (in degrees)} 16 | #' \item{amount}{Random value} 17 | #' } 18 | #' @source The BAG is the Dutch registry for Buildings and adresses 19 | #' (Basisregistratie adressen en gebouwen). 20 | "Groningen" 21 | -------------------------------------------------------------------------------- /R/data_insurance.R: -------------------------------------------------------------------------------- 1 | #' Sum insured per postal code in the Netherlands 2 | #' 3 | #' @description A dataset of postal codes with their sum insured, population 4 | #' and the corresponding spatial locations in terms of a latitude and a 5 | #' longitude. 6 | #' 7 | #' @author Martin Haringa 8 | #' 9 | #' @format A data frame with 29,990 rows and 5 variables: 10 | #' \describe{ 11 | #' \item{postcode}{6-digit postal code} 12 | #' \item{population_pc4}{Population per 4-digit postal code} 13 | #' \item{amount}{Sum insured} 14 | #' \item{lon}{Longitude (in degrees) of the corresponding 6-digit postal code} 15 | #' \item{lat}{Latitude (in degrees) of the corresponding 6-digit postal code} 16 | #' } 17 | "insurance" 18 | -------------------------------------------------------------------------------- /R/data_knmi_historic.R: -------------------------------------------------------------------------------- 1 | #' Retrieve historic weather data for the Netherlands 2 | #' 3 | #' This function retrieves historic weather data collected by the official KNMI 4 | #' weather stations. See spatialrisk::knmi_stations for a list of the official 5 | #' KNMI weather stations. 6 | #' 7 | #' @param startyear start year for historic weather data. 8 | #' @param endyear end year for historic weather data. 9 | #' 10 | #' @return Data frame containing weather data and meta data for weather station 11 | #' locations. 12 | #' 13 | #' @format The returned data frame contains the following columns: 14 | #' \itemize{ 15 | #' \item station = ID of measurement station; 16 | #' \item date = Date; 17 | #' \item FH = Hourly mean wind speed (in 0.1 m/s); 18 | #' \item FX = Maximum wind gust (in 0.1 m/s) during the hourly division; 19 | #' \item DR = Precipitation duration (in 0.1 hour) during the hourly division; 20 | #' \item RH = Hourly precipitation amount (in 0.1 mm) (-1 for <0.05 mm); 21 | #' \item city = City where the measurement station is located; 22 | #' \item lon = Longitude of station (crs = 4326); 23 | #' \item lat = Latitude of station (crs = 4326). 24 | #' } 25 | #' 26 | #' @importFrom dplyr left_join 27 | #' @importFrom fs dir_create 28 | #' @importFrom fs file_temp 29 | #' @importFrom fs file_create 30 | #' @importFrom fs path 31 | #' @importFrom fs dir_ls 32 | #' @importFrom fs file_size 33 | #' @importFrom fs dir_delete 34 | #' @importFrom utils setTxtProgressBar 35 | #' @importFrom utils txtProgressBar 36 | #' @importFrom utils data 37 | #' @importFrom utils download.file 38 | #' 39 | #' @author Martin Haringa 40 | #' 41 | #' @examples 42 | #' \dontrun{ 43 | #' knmi_historic_data(2015, 2019) 44 | #' } 45 | #' 46 | #' @export 47 | knmi_historic_data <- function(startyear, endyear) { 48 | 49 | if (!requireNamespace("vroom", quietly = TRUE)) { 50 | stop("vroom is needed for this function to work. Install it via 51 | install.packages(\"vroom\")", call. = FALSE) 52 | } 53 | 54 | # get reference data 55 | utils::data("knmi_stations", envir = environment()) 56 | 57 | id_stations <- knmi_stations$station 58 | 59 | if (startyear < 1951) { 60 | stop("Historic weather data before the year 1951 is not available.", 61 | call. = FALSE) 62 | } 63 | 64 | 65 | if (endyear > as.POSIXlt(Sys.Date())$year + 1900) { 66 | stop("Year end should not be greater than the current year.", 67 | call. = FALSE) 68 | } 69 | 70 | historic_levels <- cut(startyear:endyear, 71 | breaks = c(1951, seq(1960, 2200, by = 10)), 72 | labels = paste0(seq(1951, 2191, by = 10), "-", 73 | seq(1960, 2200, by = 10)), 74 | include.lowest = TRUE, dig.lab = 5) 75 | 76 | periods <- unique(as.character(historic_levels)) 77 | 78 | # Create a new directory 79 | tmp <- fs::dir_create(fs::file_temp()) 80 | 81 | # Set progress bar 82 | pb <- utils::txtProgressBar(max = length(id_stations), style = 3) 83 | 84 | # create new files in the new directory 85 | for (i in seq_len(length(id_stations))){ 86 | 87 | utils::setTxtProgressBar(pb, i) 88 | 89 | for (j in seq_len(length(periods))) { 90 | new_file <- fs::file_create( 91 | fs::path(tmp, paste0("knmi_", id_stations[i], "_", periods[j], ".zip")) 92 | ) 93 | knmi_url <- paste0("https://cdn.knmi.nl/knmi/map/page/", 94 | "klimatologie/gegevens/uurgegevens/uurgeg_", 95 | id_stations[i], "_", periods[j], ".zip") 96 | tryCatch(utils::download.file(knmi_url, new_file, quiet = TRUE), 97 | error = function(e) print(paste(knmi_url, "is not found"))) 98 | } 99 | } 100 | 101 | files <- fs::dir_ls(tmp, glob = "*zip") 102 | 103 | # Select existing files 104 | files_exist <- files[as.logical(fs::file_size(files) > "50KB")] 105 | 106 | # Read files into R 107 | suppressMessages( 108 | df <- vroom::vroom(files_exist, skip = 31, delim = ",", 109 | col_select = list(station = 1, date = YYYYMMDD, HH, 110 | DD, FH, FF, FX, DR, RH, Y))[-1, ] 111 | ) 112 | 113 | # Delete directory 114 | fs::dir_delete(tmp) 115 | 116 | # Filter selected years 117 | df$year <- as.numeric(substr(as.character(df$date), start = 1, stop = 4)) 118 | df_selection <- subset(df, year >= startyear & year <= endyear) 119 | 120 | # Add metadata 121 | dplyr::left_join(df_selection, 122 | knmi_stations[, c("station", "city", "lon", "lat")], 123 | by = "station") 124 | } 125 | -------------------------------------------------------------------------------- /R/haversine.R: -------------------------------------------------------------------------------- 1 | #' Haversine great circle distance 2 | #' 3 | #' @description Calculates the shortest distance between two points on the 4 | #' Earth's surface using the Haversine formula, also known as the great-circle 5 | #' distance or "as the crow flies". 6 | #' 7 | #' @param lat_from Latitude of the starting point. 8 | #' @param lon_from Longitude of the starting point. 9 | #' @param lat_to Latitude of the destination point. 10 | #' @param lon_to Longitude of the destination point. 11 | #' @param r Radius of the Earth in meters (default = 6378137). 12 | #' 13 | #' @references Sinnott, R.W, 1984. Virtues of the Haversine. Sky and Telescope 14 | #' 68(2): 159. 15 | #' 16 | #' @return Vector of distances in the same unit as \code{r} (default in meters). 17 | #' 18 | #' @author Martin Haringa 19 | #' 20 | #' @details The Haversine ('half-versed-sine') formula was published by R.W. 21 | #' Sinnott in 1984, although it has been known for much longer. 22 | #' 23 | #' @examples 24 | #' haversine(53.24007, 6.520386, 53.24054, 6.520386) 25 | #' 26 | #' @export 27 | haversine <- function(lat_from, lon_from, lat_to, lon_to, r = 6378137) { 28 | 29 | if (!all(unlist(lapply(list(lat_from, lon_from, lat_to, lon_to), 30 | is.numeric)))) { 31 | stop("lat_from, lon_from, lat_to, lon_to should be numeric") 32 | } 33 | 34 | dist <- haversine_cpp_vec(lat_from, lon_from, lat_to, lon_to, r) 35 | 36 | na_output <- sum(is.na(dist)) 37 | 38 | if (na_output > 0) { 39 | message("Ignoring missing coordinates: ", sum(is.na(dist)), 40 | " NA's returned") 41 | } 42 | 43 | dist 44 | } 45 | -------------------------------------------------------------------------------- /R/map_choropleth.R: -------------------------------------------------------------------------------- 1 | #' Create choropleth map 2 | #' 3 | #' @description Takes an object produced by \code{points_to_polygon()}, and 4 | #' creates the corresponding choropleth map. The given clustering is according 5 | #' to the Fisher-Jenks algorithm. This commonly used method for choropleths 6 | #' seeks to reduce the variance within classes and maximize the variance 7 | #' between classes. 8 | #' 9 | #' @param sf_object object of class sf 10 | #' @param value column name to shade the polygons 11 | #' @param id_name column name of ids to plot 12 | #' @param mode choose between static ('plot' is default) and interactive 13 | #' map ('view') 14 | #' @param n number of clusters (default is 7) 15 | #' @param legend_title title of legend 16 | #' @param palette palette name or a vector of colors. See 17 | #' \code{tmaptools::palette_explorer()} for the named palettes. 18 | #' Use a \code{-} as prefix to reverse the palette. The default palette is 19 | #' "viridis". 20 | #' 21 | #' @return tmap 22 | #' 23 | #' @importFrom tmap tmap_mode 24 | #' @importFrom tmap tm_basemap 25 | #' @importFrom tmap tm_compass 26 | #' @importFrom tmap tm_layout 27 | #' @importFrom tmap tm_polygons 28 | #' @importFrom tmap tm_scale_bar 29 | #' @importFrom tmap tm_shape 30 | #' @import viridis 31 | #' 32 | #' @author Martin Haringa 33 | #' 34 | #' @examples 35 | #' test <- points_to_polygon(nl_provincie, insurance, sum(amount, na.rm = TRUE)) 36 | #' choropleth(test) 37 | #' choropleth(test, id_name = "areaname", mode = "view") 38 | #' 39 | #' @export 40 | choropleth <- function(sf_object, value = "output", id_name = "areaname", 41 | mode = "plot", n = 7, legend_title = "Clustering", 42 | palette = "viridis") { 43 | 44 | if (mode == "view") { 45 | suppressMessages({ 46 | tmap::tmap_mode("view") 47 | }) 48 | 49 | # tmap4 code 50 | output <- tmap::tm_shape(sf_object) + 51 | tmap::tm_polygons(value, 52 | id = id_name, 53 | fill.scale = tmap::tm_scale_intervals( 54 | style = "fisher", 55 | values = palette, 56 | n = n 57 | ), 58 | fill.legend = tmap::tm_legend(title = legend_title), 59 | fill_alpha = .5) + 60 | tmap::tm_basemap(c("OpenStreetMap", "Esri.WorldGrayCanvas", 61 | "Esri.WorldTopoMap")) 62 | 63 | # tmap3 code 64 | # output <- tmap::tm_shape(sf_object) + 65 | # tmap::tm_polygons(value, 66 | # id = id_name, 67 | # palette = palette, 68 | # style = "fisher", 69 | # n = n, 70 | # title = legend_title, 71 | # alpha = .5) + 72 | # tmap::tm_basemap(c("OpenStreetMap", "Esri.WorldGrayCanvas", 73 | # "Esri.WorldTopoMap")) 74 | 75 | } else { 76 | suppressMessages({ 77 | tmap::tmap_mode("plot") 78 | }) 79 | 80 | # tmap4 code 81 | output <- tmap::tm_shape(sf_object) + 82 | tmap::tm_polygons(value, 83 | id = id_name, 84 | fill.scale = tmap::tm_scale_intervals(style = "fisher", 85 | values = palette, 86 | n = n), 87 | fill.legend = tmap::tm_legend(title = legend_title), 88 | lwd = .1) + 89 | tmap::tm_compass(position = c("right", "bottom")) + 90 | tmap::tm_scalebar(position = c("left", "bottom")) + 91 | tmap::tm_layout(frame = FALSE) 92 | 93 | # tmap3 code 94 | # output <- tmap::tm_shape(sf_object) + 95 | # tmap::tm_polygons(value, 96 | # id = id_name, 97 | # palette = palette, 98 | # style = "fisher", 99 | # title = legend_title, 100 | # n = n, 101 | # lwd = .1) + 102 | # tmap::tm_compass(position = c("right", "bottom")) + 103 | # tmap::tm_scale_bar(position = c("left", "bottom")) + 104 | # tmap::tm_layout(frame = FALSE) 105 | } 106 | 107 | output 108 | } 109 | -------------------------------------------------------------------------------- /R/map_ggplot2.R: -------------------------------------------------------------------------------- 1 | #' Map object of class sf using ggplot2 2 | #' 3 | #' @description Takes an object produced by \code{choropleth_sf()}, and creates 4 | #' the correspoding choropleth map. 5 | #' 6 | #' @param sf_object object of class sf 7 | #' @param value column to shade the polygons 8 | #' @param n number of clusters (default is 7) 9 | #' @param dig.lab number of digits in legend (default is 2) 10 | #' @param legend_title title of legend 11 | #' @param option a character string indicating the colormap option to use. Four 12 | #' options are available: "magma" (or "A"), "inferno" (or "B"), "plasma" 13 | #' (or "C"), "viridis" (or "D", the default option) and "cividis" (or "E"). 14 | #' @param direction Sets the order of colors in the scale. If \code{1}, 15 | #' the default, colors are ordered from darkest to lightest. If \code{-1}, 16 | #' the order of colors is reversed. 17 | #' 18 | #' @return ggplot map 19 | #' 20 | #' @importFrom ggplot2 ggplot 21 | #' @importFrom ggplot2 geom_sf 22 | #' @importFrom ggplot2 coord_sf 23 | #' @importFrom ggplot2 scale_fill_viridis_d 24 | #' @importFrom ggplot2 theme_void 25 | #' @importFrom ggplot2 labs 26 | #' @importFrom ggplot2 scale_fill_viridis_c 27 | #' @importFrom ggplot2 aes 28 | #' @importFrom classInt classIntervals 29 | #' 30 | #' @author Martin Haringa 31 | #' 32 | #' @examples 33 | #' test <- points_to_polygon(nl_postcode2, insurance, sum(amount, na.rm = TRUE)) 34 | #' choropleth_ggplot2(test) 35 | #' 36 | #' @export 37 | choropleth_ggplot2 <- function(sf_object, value = output, n = 7, dig.lab = 2, 38 | legend_title = "Class", option = "D", 39 | direction = 1) { 40 | 41 | value <- deparse(substitute(value)) 42 | vector_value <- sf_object[[value]] 43 | 44 | result <- tryCatch( 45 | { 46 | suppressWarnings( 47 | { 48 | cluster <- classInt::classIntervals(vector_value, n = n, 49 | style = "fisher", 50 | intervalClosure = "right")[[2]] 51 | sf_object$clustering <- cut(vector_value, breaks = cluster, 52 | include.lowest = TRUE, dig.lab = dig.lab) 53 | } 54 | ) 55 | 56 | ggplot2::ggplot(sf_object) + 57 | ggplot2::geom_sf(ggplot2::aes(fill = clustering), size = .1, 58 | color = "grey85") + 59 | ggplot2::coord_sf(datum = NA) + 60 | ggplot2::scale_fill_viridis_d(direction = direction, option = option) + 61 | ggplot2::theme_void() + 62 | ggplot2::labs(fill = legend_title) 63 | }, 64 | error = function(e) { 65 | ggplot2::ggplot(sf_object) + 66 | ggplot2::geom_sf(ggplot2::aes(fill = vector_value), size = .1, 67 | color = "grey85") + 68 | ggplot2::coord_sf(datum = NA) + 69 | ggplot2::scale_fill_viridis_c(direction = direction, option = option) + 70 | ggplot2::theme_void() + 71 | ggplot2::labs(fill = legend_title) 72 | } 73 | ) 74 | 75 | result 76 | } 77 | -------------------------------------------------------------------------------- /R/map_plot_points.R: -------------------------------------------------------------------------------- 1 | #' Create map with points 2 | #' 3 | #' @description Create map for a data.frame containing points. 4 | #' 5 | #' @param df data.frame containing columns for longitude and latitude. 6 | #' @param value column in \code{df} to be visualized. 7 | #' @param lon column in \code{df} containing longitude values. 8 | #' @param lat column in \code{df} containing latitude values. 9 | #' @param crs crs code for the coordinate reference system (default is 4326). 10 | #' @param at the breakpoints used for visualisation. 11 | #' 12 | #' @importFrom mapview mapview 13 | #' @importFrom sf st_as_sf 14 | #' 15 | #' @examples \dontrun{ 16 | #' plot_points(Groningen, value = "amount") 17 | #' } 18 | #' 19 | #' @export 20 | plot_points <- function(df, value, lon = "lon", lat = "lat", 21 | crs = 4326, at = NULL) { 22 | 23 | if (value == "") { 24 | stop(df, 25 | " does not contain column specified in `value`. Specify with `value`.", 26 | call. = FALSE) 27 | } 28 | 29 | obj_sf <- sf::st_as_sf(df, coords = c(lon, lat), crs = crs) 30 | mapview::mapview(obj_sf, zcol = value, layer.name = value, at = at) 31 | } 32 | -------------------------------------------------------------------------------- /R/points_in_circle.R: -------------------------------------------------------------------------------- 1 | #' Filter observations within circle 2 | #' 3 | #' @description Filter all observations in a data.frame that fall within a 4 | #' circle of a specified radius drawn around a given latitude and longitude 5 | #' point. 6 | #' 7 | #' @param data data.frame with at least columns for longitude and latitude. 8 | #' @param lon_center numeric. Representing the longitude of the circle's center. 9 | #' @param lat_center numeric. Representing the latitude of the circle's center. 10 | #' @param lon column name in \code{data} containing longitudes 11 | #' (default is \code{lon}). 12 | #' @param lat column name in \code{data} containing latitudes 13 | #' (default is \code{lat}). 14 | #' @param radius radius of the circle in meters (default is 200m). 15 | #' 16 | #' @author Martin Haringa 17 | #' 18 | #' @importFrom Rcpp sourceCpp 19 | #' @import RcppProgress 20 | #' 21 | #' @examples 22 | #' points_in_circle(Groningen, lon_center = 6.571561, lat_center = 53.21326, 23 | #' radius = 60) 24 | #' 25 | #' @return A subset of the input data.frame containing only the observations 26 | #' that fall within the specified circle. 27 | #' 28 | #' @export 29 | points_in_circle <- function(data, lon_center, lat_center, lon = lon, lat = lat, 30 | radius = 200) { 31 | 32 | # Turn into character vector 33 | lon <- deparse(substitute(lon)) 34 | lat <- deparse(substitute(lat)) 35 | data_name <- deparse(substitute(data)) 36 | 37 | if (!all(c(lon, lat) %in% names(data))) { 38 | stop(paste0(data_name, " does not contain columns ", lon, " and ", lat), 39 | call. = FALSE) 40 | } 41 | 42 | if (!all(is.numeric(c(data[[lon]], data[[lat]])))) { 43 | stop(paste0(lon, ", ", lat, " should be numeric"), call. = FALSE) 44 | } 45 | 46 | df <- data.frame("lon" = data[[lon]], "lat" = data[[lat]]) 47 | 48 | incircle <- haversine_loop_cpp(df, lat_center, lon_center, radius) 49 | 50 | incircle_df <- data[incircle$id, ] 51 | incircle_df$distance_m <- incircle$distance_m 52 | incircle_df[order(incircle_df$distance_m), ] 53 | } 54 | 55 | 56 | #' @keywords internal 57 | points_in_circle_ <- function(data, lon_center, lat_center, lon = lon, 58 | lat = lat, radius = 200) { 59 | 60 | # Turn into character vector 61 | data_name <- deparse(substitute(data)) 62 | 63 | if (!all(c(lon, lat) %in% names(data))) { 64 | stop(paste0(data_name, " does not contain columns ", lon, " and ", lat), 65 | call. = FALSE) 66 | } 67 | 68 | if (!all(is.numeric(c(data[[lon]], data[[lat]])))) { 69 | stop(paste0(lon, ", ", lat, " should be numeric"), call. = FALSE) 70 | } 71 | 72 | df <- data.frame("lon" = data[[lon]], "lat" = data[[lat]]) 73 | 74 | incircle <- haversine_loop_cpp(df, lat_center, lon_center, radius) 75 | 76 | incircle_df <- data[incircle$id, ] 77 | incircle_df$distance_m <- incircle$distance_m 78 | incircle_df[order(incircle_df$distance_m), ] 79 | } 80 | 81 | 82 | 83 | #' Filter observations within circle (vectorized) 84 | #' 85 | #' @description Filter all observations in a data.frame that fall within a 86 | #' circle of a specified radius drawn around a given latitude and longitude 87 | #' point. 88 | #' 89 | #' @param data data.frame with at least columns for longitude and latitude. 90 | #' @param lon_center numeric. Representing the longitude of the circle's center. 91 | #' @param lat_center numeric. Representing the latitude of the circle's center. 92 | #' @param lon column name in \code{data} containing longitudes 93 | #' (default is \code{lon}). 94 | #' @param lat column name in \code{data} containing latitudes 95 | #' (default is \code{lat}). 96 | #' @param radius radius of the circle in meters (default is 200m). 97 | #' 98 | #' @author Martin Haringa 99 | #' 100 | #' @importFrom Rcpp sourceCpp 101 | #' @import RcppProgress 102 | #' 103 | #' @examples 104 | #' points_in_circle_vec(Groningen, lon_center = c(6.571561, 6.56561), 105 | #' lat_center = c(53.21326, 53.20326), radius = 60) 106 | #' 107 | #' @return A subset of the input data.frame containing only the observations 108 | #' that fall within the specified circle. 109 | #' 110 | #' @export 111 | points_in_circle_vec <- function(data, lon_center, lat_center, 112 | lon = lon, lat = lat, radius = 200) { 113 | 114 | # Turn into character vector 115 | lon <- deparse(substitute(lon)) 116 | lat <- deparse(substitute(lat)) 117 | data_name <- deparse(substitute(data)) 118 | 119 | if (!all(c(lon, lat) %in% names(data))) { 120 | stop(paste0(data_name, " does not contain columns ", lon, " and ", lat), 121 | call. = FALSE) 122 | } 123 | 124 | if (!all(is.numeric(c(data[[lon]], data[[lat]])))) { 125 | stop(paste0(lon, ", ", lat, " should be numeric"), call. = FALSE) 126 | } 127 | 128 | df <- data.frame("lon" = data[[lon]], "lat" = data[[lat]]) 129 | incircle <- haversine_loop_cpp0(df, lat_center, lon_center, radius) 130 | data$id <- seq.int(nrow(data)) 131 | df_join <- merge(x = incircle, y = data, by = "id", all.x = TRUE) 132 | x <- df_join[order(df_join$center_index, df_join$distance_m), ] 133 | rownames(x) <- NULL 134 | x 135 | } 136 | -------------------------------------------------------------------------------- /R/points_to_polygon.R: -------------------------------------------------------------------------------- 1 | #' Map points to polygons 2 | #' 3 | #' @description Join a data.frame containing coordinates (longitude and 4 | #' latitude) to polygon geometries. Arithmetic operations are then applied to 5 | #' the attributes of the joined coordinates to obtain aggregated values 6 | #' for each polygon. 7 | #' 8 | #' @param sf_map object of class sf representing the polygon geometries. 9 | #' @param df data.frame containing coordinates (column names should be 'lon' 10 | #' and 'lat') 11 | #' @param oper arithmetic operation to be applied on the polygon level. 12 | #' @param crs coordinate reference system (default is 4326). 13 | #' @param outside_print logical indicating whether to print points that are 14 | #' not within a polygon (default is FALSE). 15 | #' 16 | #' @importFrom sf st_transform 17 | #' @importFrom sf st_buffer 18 | #' @importFrom sf st_join 19 | #' @importFrom sf st_intersects 20 | #' @importFrom sf st_geometry 21 | #' @importFrom data.table data.table 22 | #' @importFrom utils capture.output 23 | #' 24 | #' @return An object of class \code{sf} 25 | #' 26 | #' @author Martin Haringa 27 | #' 28 | #' @examples 29 | #' points_to_polygon(nl_postcode2, insurance, sum(amount, na.rm = TRUE)) 30 | #' \dontrun{ 31 | #' shp_read <- sf::st_read("~/path/to/file.shp") 32 | #' points_to_polygon(shp_read, insurance, sum(amount, na.rm = TRUE)) 33 | #' } 34 | #' 35 | #' @export 36 | points_to_polygon <- function(sf_map, df, oper, crs = 4326, 37 | outside_print = FALSE) { 38 | 39 | shp_wgs84 <- tryCatch( 40 | { 41 | shp0 <- sf::st_transform(sf_map, crs = crs) # Convert coordinates to WGS84 42 | shp0$id <- seq.int(nrow(shp0)) 43 | shp0 44 | }, 45 | error = function(e) { 46 | shp0 <- sf::st_buffer(sf_map, 0) # Make invalid geometries valid 47 | shp0 <- sf::st_transform(shp0, crs = crs) 48 | shp0$id <- seq.int(nrow(shp0)) 49 | shp0 50 | } 51 | ) 52 | 53 | if (!all(c("lon", "lat") %in% names(df))) { 54 | stop("Data.frame should contain column names 'lon' and 'lat'.", 55 | call. = FALSE) 56 | } 57 | 58 | df_sf <- sf::st_as_sf(df, coords = c("lon", "lat"), crs = crs) 59 | 60 | suppressMessages({ 61 | df_map_sf <- sf::st_join(shp_wgs84, df_sf) 62 | outside <- df_sf[!lengths(sf::st_intersects(df_sf, shp_wgs84)), ] 63 | }) 64 | 65 | if (nrow(outside) > 0) { 66 | if (isTRUE(outside_print)) { 67 | message("Points that are not within a polygon:\n", 68 | paste0(capture.output(data.frame(outside)), collapse = "\n")) 69 | } else { 70 | message(nrow(outside), " points fall not within a polygon.") 71 | } 72 | } 73 | 74 | # Change sf to data.frame 75 | df_map <- df_map_sf 76 | sf::st_geometry(df_map) <- NULL 77 | 78 | # Aggregate 79 | oper <- substitute(oper) 80 | df_map_sf2 <- eval.parent(substitute( 81 | data.table::data.table(df_map)[, .(output = oper), by = "id"] 82 | )) 83 | 84 | merge(shp_wgs84, df_map_sf2, by = "id", all.x = TRUE) 85 | } 86 | -------------------------------------------------------------------------------- /R/smooth_sphere.R: -------------------------------------------------------------------------------- 1 | #' Splines on the sphere 2 | #' 3 | #' @description Spline interpolation and smoothing on the sphere. 4 | #' 5 | #' @param observations data.frame of observations. 6 | #' @param targets data.frame of locations to calculate the interpolated and 7 | #' smoothed values for (target points). 8 | #' @param value Column with values in \code{observations}. 9 | #' @param lon_obs Column in \code{observations} with longitude (lon is default). 10 | #' @param lat_obs Column in \code{observations} with latitude (lat is default). 11 | #' @param lon_targets Column in \code{targets} with longitude (lon is default). 12 | #' @param lat_targets Column in \code{targets} with latitude (lat is default). 13 | #' @param k (default 50) is the basis dimension. For small data sets reduce 14 | #' \code{k} manually rather than using default. 15 | #' 16 | #' @details \code{observations} should include at least columns for longitude 17 | #' and latitude. 18 | #' @details \code{targets} should include at least columns for longitude, 19 | #' latitude and value of interest to interpolate and smooth. 20 | #' @details A smooth of the general type discussed in Duchon (1977) is used: 21 | #' the sphere is embedded in a 3D Euclidean space, but smoothing employs a 22 | #' penalty based on second derivatives (so that locally as the smoothing 23 | #' parameter tends to zero we recover a "normal" thin plate spline on the 24 | #' tangent space). This is an unpublished suggestion of Jean Duchon. 25 | #' 26 | #' @return Object equal to object \code{targets} including an extra column 27 | #' with predicted values. 28 | #' 29 | #' @author Martin Haringa 30 | #' 31 | #' @importFrom stats as.formula 32 | #' 33 | #' @references \code{\link[mgcv:smooth.construct.sos.smooth.spec]{Splines on 34 | #' the sphere}} 35 | #' 36 | #' @examples 37 | #' \dontrun{ 38 | #' target <- sf::st_drop_geometry(nl_postcode3) 39 | #' obs <- dplyr::sample_n(insurance, 1000) 40 | #' pop_df <- interpolate_spline(obs, target, population_pc4, k = 20) 41 | #' pop_sf <- dplyr::left_join(nl_postcode3, pop_df) 42 | #' choropleth(pop_sf, value = "population_pc4_pred", n = 13) 43 | #' } 44 | #' 45 | #' @export 46 | interpolate_spline <- function(observations, targets, value, lon_obs = lon, 47 | lat_obs = lat, lon_targets = lon, 48 | lat_targets = lat, k = 50) { 49 | 50 | if (!requireNamespace("mgcv", quietly = TRUE)) { 51 | stop("mgcv is needed for this function to work. 52 | Install it via install.packages(\"mgcv\")", call. = FALSE) 53 | } 54 | 55 | lon_targets <- deparse(substitute(lon_targets)) 56 | lat_targets <- deparse(substitute(lat_targets)) 57 | lon_obs <- deparse(substitute(lon_obs)) 58 | lat_obs <- deparse(substitute(lat_obs)) 59 | value <- deparse(substitute(value)) 60 | sos <- deparse(substitute("sos")) 61 | 62 | # Rename columns 63 | names(observations)[names(observations) == lon_obs] <- "lon" 64 | names(observations)[names(observations) == lat_obs] <- "lat" 65 | names(targets)[names(targets) == lon_targets] <- "lon" 66 | names(targets)[names(targets) == lon_targets] <- "lon" 67 | 68 | f <- as.formula(paste0(value, "~ s(lat, lon,", "bs = ", sos, 69 | ", m = -1, k = ", k, ")")) 70 | pred_gam <- tryCatch( 71 | { mgcv::gam(f, data = observations) }, 72 | error = function(e) { 73 | stop("Error: dimension k is chosen too large (default k = 50). Reduce 74 | dimension k manually as argument in function call.", call. = FALSE) 75 | } 76 | ) 77 | 78 | response <- as.numeric(mgcv::predict.gam(pred_gam, targets, 79 | type = "response")) 80 | targets[, paste0(value, "_pred")] <- response 81 | targets 82 | } 83 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | globalVariables(c("lon", "lat", "value", "clustering", "output", "DD", "DR", 2 | "FF", "FH", "FX", "HH", "RH", "T10", "TD", 3 | "YYYYMMDD", "knmi_stations", "Y", "id", 4 | ".", "geohash_sum", "geohash", "longitude", "latitude", 5 | "delta_longitude", "delta_latitude", "gh_nghbrs_sum", 6 | "sum_bbox", "_sum_insured", "head", "valueconc", 7 | ":=", "north", "south", "west", "east", "geometry")) 8 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://mharinga.github.io/spatialrisk/ 2 | template: 3 | bootstrap: 5 4 | bslib: 5 | base_font: {google: "Open Sans"} 6 | navbar: 7 | structure: 8 | left: [home, reference, news] 9 | right: [github] 10 | reference: 11 | - title: "Spatial risk" 12 | contents: 13 | - concentration 14 | - find_highest_concentration 15 | - plot.concentration 16 | - points_in_circle 17 | - points_in_circle_vec 18 | - haversine 19 | - convert_crs_df 20 | - title: "Create maps" 21 | contents: 22 | - points_to_polygon 23 | - choropleth 24 | - choropleth_ggplot2 25 | - plot_points 26 | - title: "Spatial interpolation" 27 | contents: 28 | - interpolate_spline 29 | - title: "Maps" 30 | desc: > 31 | Objects of class sf 32 | contents: 33 | - matches("nl_") 34 | - matches("_countries") 35 | - title: "Weather data" 36 | contents: 37 | - knmi_historic_data 38 | - knmi_stations 39 | - title: "Other data sets" 40 | contents: 41 | - Groningen 42 | - insurance 43 | - title: "Deprecated" 44 | contents: 45 | - highest_concentration 46 | - neighborhood_gh_search 47 | - plot.neighborhood 48 | - plot.conc 49 | 50 | 51 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Resubmission 2 | This is a resubmission. In this version I have: 3 | 4 | * Introduced `find_highest_concentration()`: a faster and more accurate alternative to `highest_concentration()`, leveraging focal statistics for optimal results. 5 | * Deprecated `highest_concentration()` in favor of the new, improved function. 6 | * Updated `plot_points()` to utilize `mapview::mapview()` for enhanced interactive map visualizations. 7 | * Revised the README to reflect these new features and updates. 8 | 9 | ## Test environments 10 | * local OS X install, R 4.5.0 11 | * win-builder (devel and release) 12 | 13 | ## R CMD check results 14 | There were no ERRORs, WARNINGs or NOTEs. 15 | 16 | ## Downstream dependencies 17 | I have also run R CMD check on downstream dependencies of spatialrisk. 18 | All packages that I could install passed. 19 | 20 | 21 | -------------------------------------------------------------------------------- /data/Groningen.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/data/Groningen.rda -------------------------------------------------------------------------------- /data/insurance.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/data/insurance.rda -------------------------------------------------------------------------------- /data/knmi_stations.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/data/knmi_stations.rda -------------------------------------------------------------------------------- /data/nl_corop.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/data/nl_corop.rda -------------------------------------------------------------------------------- /data/nl_gemeente.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/data/nl_gemeente.rda -------------------------------------------------------------------------------- /data/nl_postcode2.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/data/nl_postcode2.rda -------------------------------------------------------------------------------- /data/nl_postcode3.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/data/nl_postcode3.rda -------------------------------------------------------------------------------- /data/nl_postcode4.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/data/nl_postcode4.rda -------------------------------------------------------------------------------- /data/nl_provincie.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/data/nl_provincie.rda -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Page not found (404) • spatialrisk 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Skip to contents 24 | 25 | 26 |
50 |
51 |
55 | 56 | Content not found. Please use links in the navbar. 57 | 58 |
59 |
60 | 61 | 62 |
65 | 66 | 69 | 70 |
71 |
72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /docs/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /docs/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/apple-touch-icon.png -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | Authors and Citation • spatialrisk 3 | Skip to contents 4 | 5 | 6 |
26 |
27 |
30 | 31 |
32 |

Authors

33 | 34 |
  • 35 |

    Martin Haringa. Author, maintainer. 36 |

    37 |
  • 38 |
39 | 40 |
41 |

Citation

42 |

Source: DESCRIPTION

43 | 44 |

Haringa M (2025). 45 | spatialrisk: Calculating Spatial Risk. 46 | R package version 0.7.2, https://github.com/mharinga/spatialrisk. 47 |

48 |
@Manual{,
49 |   title = {spatialrisk: Calculating Spatial Risk},
50 |   author = {Martin Haringa},
51 |   year = {2025},
52 |   note = {R package version 0.7.2},
53 |   url = {https://github.com/mharinga/spatialrisk},
54 | }
55 |
56 | 57 |
59 | 60 | 61 |
64 | 65 | 68 | 69 |
70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | (function() { 6 | 'use strict'; 7 | 8 | window.Toc = { 9 | helpers: { 10 | // return all matching elements in the set, or their descendants 11 | findOrFilter: function($el, selector) { 12 | // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ 13 | // http://stackoverflow.com/a/12731439/358804 14 | var $descendants = $el.find(selector); 15 | return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); 16 | }, 17 | 18 | generateUniqueIdBase: function(el) { 19 | var text = $(el).text(); 20 | var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); 21 | return anchor || el.tagName.toLowerCase(); 22 | }, 23 | 24 | generateUniqueId: function(el) { 25 | var anchorBase = this.generateUniqueIdBase(el); 26 | for (var i = 0; ; i++) { 27 | var anchor = anchorBase; 28 | if (i > 0) { 29 | // add suffix 30 | anchor += '-' + i; 31 | } 32 | // check if ID already exists 33 | if (!document.getElementById(anchor)) { 34 | return anchor; 35 | } 36 | } 37 | }, 38 | 39 | generateAnchor: function(el) { 40 | if (el.id) { 41 | return el.id; 42 | } else { 43 | var anchor = this.generateUniqueId(el); 44 | el.id = anchor; 45 | return anchor; 46 | } 47 | }, 48 | 49 | createNavList: function() { 50 | return $(''); 51 | }, 52 | 53 | createChildNavList: function($parent) { 54 | var $childList = this.createNavList(); 55 | $parent.append($childList); 56 | return $childList; 57 | }, 58 | 59 | generateNavEl: function(anchor, text) { 60 | var $a = $(''); 61 | $a.attr('href', '#' + anchor); 62 | $a.text(text); 63 | var $li = $('
  • '); 64 | $li.append($a); 65 | return $li; 66 | }, 67 | 68 | generateNavItem: function(headingEl) { 69 | var anchor = this.generateAnchor(headingEl); 70 | var $heading = $(headingEl); 71 | var text = $heading.data('toc-text') || $heading.text(); 72 | return this.generateNavEl(anchor, text); 73 | }, 74 | 75 | // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). 76 | getTopLevel: function($scope) { 77 | for (var i = 1; i <= 6; i++) { 78 | var $headings = this.findOrFilter($scope, 'h' + i); 79 | if ($headings.length > 1) { 80 | return i; 81 | } 82 | } 83 | 84 | return 1; 85 | }, 86 | 87 | // returns the elements for the top level, and the next below it 88 | getHeadings: function($scope, topLevel) { 89 | var topSelector = 'h' + topLevel; 90 | 91 | var secondaryLevel = topLevel + 1; 92 | var secondarySelector = 'h' + secondaryLevel; 93 | 94 | return this.findOrFilter($scope, topSelector + ',' + secondarySelector); 95 | }, 96 | 97 | getNavLevel: function(el) { 98 | return parseInt(el.tagName.charAt(1), 10); 99 | }, 100 | 101 | populateNav: function($topContext, topLevel, $headings) { 102 | var $context = $topContext; 103 | var $prevNav; 104 | 105 | var helpers = this; 106 | $headings.each(function(i, el) { 107 | var $newNav = helpers.generateNavItem(el); 108 | var navLevel = helpers.getNavLevel(el); 109 | 110 | // determine the proper $context 111 | if (navLevel === topLevel) { 112 | // use top level 113 | $context = $topContext; 114 | } else if ($prevNav && $context === $topContext) { 115 | // create a new level of the tree and switch to it 116 | $context = helpers.createChildNavList($prevNav); 117 | } // else use the current $context 118 | 119 | $context.append($newNav); 120 | 121 | $prevNav = $newNav; 122 | }); 123 | }, 124 | 125 | parseOps: function(arg) { 126 | var opts; 127 | if (arg.jquery) { 128 | opts = { 129 | $nav: arg 130 | }; 131 | } else { 132 | opts = arg; 133 | } 134 | opts.$scope = opts.$scope || $(document.body); 135 | return opts; 136 | } 137 | }, 138 | 139 | // accepts a jQuery object, or an options object 140 | init: function(opts) { 141 | opts = this.helpers.parseOps(opts); 142 | 143 | // ensure that the data attribute is in place for styling 144 | opts.$nav.attr('data-toggle', 'toc'); 145 | 146 | var $topContext = this.helpers.createChildNavList(opts.$nav); 147 | var topLevel = this.helpers.getTopLevel(opts.$scope); 148 | var $headings = this.helpers.getHeadings(opts.$scope, topLevel); 149 | this.helpers.populateNav($topContext, topLevel, $headings); 150 | } 151 | }; 152 | 153 | $(function() { 154 | $('nav[data-toggle="toc"]').each(function(i, el) { 155 | var $nav = $(el); 156 | Toc.init($nav); 157 | }); 158 | }); 159 | })(); 160 | -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.10/font.css: -------------------------------------------------------------------------------- 1 | /* cyrillic-ext */ 2 | @font-face { 3 | font-family: 'Open Sans'; 4 | font-style: normal; 5 | font-weight: 400; 6 | font-stretch: 100%; 7 | font-display: swap; 8 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4taVIGxA.woff2) format('woff2'); 9 | unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; 10 | } 11 | /* cyrillic */ 12 | @font-face { 13 | font-family: 'Open Sans'; 14 | font-style: normal; 15 | font-weight: 400; 16 | font-stretch: 100%; 17 | font-display: swap; 18 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4kaVIGxA.woff2) format('woff2'); 19 | unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 20 | } 21 | /* greek-ext */ 22 | @font-face { 23 | font-family: 'Open Sans'; 24 | font-style: normal; 25 | font-weight: 400; 26 | font-stretch: 100%; 27 | font-display: swap; 28 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4saVIGxA.woff2) format('woff2'); 29 | unicode-range: U+1F00-1FFF; 30 | } 31 | /* greek */ 32 | @font-face { 33 | font-family: 'Open Sans'; 34 | font-style: normal; 35 | font-weight: 400; 36 | font-stretch: 100%; 37 | font-display: swap; 38 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4jaVIGxA.woff2) format('woff2'); 39 | unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; 40 | } 41 | /* hebrew */ 42 | @font-face { 43 | font-family: 'Open Sans'; 44 | font-style: normal; 45 | font-weight: 400; 46 | font-stretch: 100%; 47 | font-display: swap; 48 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4iaVIGxA.woff2) format('woff2'); 49 | unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; 50 | } 51 | /* math */ 52 | @font-face { 53 | font-family: 'Open Sans'; 54 | font-style: normal; 55 | font-weight: 400; 56 | font-stretch: 100%; 57 | font-display: swap; 58 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5caVIGxA.woff2) format('woff2'); 59 | unicode-range: U+0302-0303, U+0305, U+0307-0308, U+0330, U+0391-03A1, U+03A3-03A9, U+03B1-03C9, U+03D1, U+03D5-03D6, U+03F0-03F1, U+03F4-03F5, U+2034-2037, U+2057, U+20D0-20DC, U+20E1, U+20E5-20EF, U+2102, U+210A-210E, U+2110-2112, U+2115, U+2119-211D, U+2124, U+2128, U+212C-212D, U+212F-2131, U+2133-2138, U+213C-2140, U+2145-2149, U+2190, U+2192, U+2194-21AE, U+21B0-21E5, U+21F1-21F2, U+21F4-2211, U+2213-2214, U+2216-22FF, U+2308-230B, U+2310, U+2319, U+231C-2321, U+2336-237A, U+237C, U+2395, U+239B-23B6, U+23D0, U+23DC-23E1, U+2474-2475, U+25AF, U+25B3, U+25B7, U+25BD, U+25C1, U+25CA, U+25CC, U+25FB, U+266D-266F, U+27C0-27FF, U+2900-2AFF, U+2B0E-2B11, U+2B30-2B4C, U+2BFE, U+FF5B, U+FF5D, U+1D400-1D7FF, U+1EE00-1EEFF; 60 | } 61 | /* symbols */ 62 | @font-face { 63 | font-family: 'Open Sans'; 64 | font-style: normal; 65 | font-weight: 400; 66 | font-stretch: 100%; 67 | font-display: swap; 68 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5OaVIGxA.woff2) format('woff2'); 69 | unicode-range: U+0001-000C, U+000E-001F, U+007F-009F, U+20DD-20E0, U+20E2-20E4, U+2150-218F, U+2190, U+2192, U+2194-2199, U+21AF, U+21E6-21F0, U+21F3, U+2218-2219, U+2299, U+22C4-22C6, U+2300-243F, U+2440-244A, U+2460-24FF, U+25A0-27BF, U+2800-28FF, U+2921-2922, U+2981, U+29BF, U+29EB, U+2B00-2BFF, U+4DC0-4DFF, U+FFF9-FFFB, U+10140-1018E, U+10190-1019C, U+101A0, U+101D0-101FD, U+102E0-102FB, U+10E60-10E7E, U+1D2C0-1D2D3, U+1D2E0-1D37F, U+1F000-1F0FF, U+1F100-1F1AD, U+1F1E6-1F1FF, U+1F30D-1F30F, U+1F315, U+1F31C, U+1F31E, U+1F320-1F32C, U+1F336, U+1F378, U+1F37D, U+1F382, U+1F393-1F39F, U+1F3A7-1F3A8, U+1F3AC-1F3AF, U+1F3C2, U+1F3C4-1F3C6, U+1F3CA-1F3CE, U+1F3D4-1F3E0, U+1F3ED, U+1F3F1-1F3F3, U+1F3F5-1F3F7, U+1F408, U+1F415, U+1F41F, U+1F426, U+1F43F, U+1F441-1F442, U+1F444, U+1F446-1F449, U+1F44C-1F44E, U+1F453, U+1F46A, U+1F47D, U+1F4A3, U+1F4B0, U+1F4B3, U+1F4B9, U+1F4BB, U+1F4BF, U+1F4C8-1F4CB, U+1F4D6, U+1F4DA, U+1F4DF, U+1F4E3-1F4E6, U+1F4EA-1F4ED, U+1F4F7, U+1F4F9-1F4FB, U+1F4FD-1F4FE, U+1F503, U+1F507-1F50B, U+1F50D, U+1F512-1F513, U+1F53E-1F54A, U+1F54F-1F5FA, U+1F610, U+1F650-1F67F, U+1F687, U+1F68D, U+1F691, U+1F694, U+1F698, U+1F6AD, U+1F6B2, U+1F6B9-1F6BA, U+1F6BC, U+1F6C6-1F6CF, U+1F6D3-1F6D7, U+1F6E0-1F6EA, U+1F6F0-1F6F3, U+1F6F7-1F6FC, U+1F700-1F7FF, U+1F800-1F80B, U+1F810-1F847, U+1F850-1F859, U+1F860-1F887, U+1F890-1F8AD, U+1F8B0-1F8B1, U+1F900-1F90B, U+1F93B, U+1F946, U+1F984, U+1F996, U+1F9E9, U+1FA00-1FA6F, U+1FA70-1FA7C, U+1FA80-1FA88, U+1FA90-1FABD, U+1FABF-1FAC5, U+1FACE-1FADB, U+1FAE0-1FAE8, U+1FAF0-1FAF8, U+1FB00-1FBFF; 70 | } 71 | /* vietnamese */ 72 | @font-face { 73 | font-family: 'Open Sans'; 74 | font-style: normal; 75 | font-weight: 400; 76 | font-stretch: 100%; 77 | font-display: swap; 78 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4vaVIGxA.woff2) format('woff2'); 79 | unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; 80 | } 81 | /* latin-ext */ 82 | @font-face { 83 | font-family: 'Open Sans'; 84 | font-style: normal; 85 | font-weight: 400; 86 | font-stretch: 100%; 87 | font-display: swap; 88 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4uaVIGxA.woff2) format('woff2'); 89 | unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; 90 | } 91 | /* latin */ 92 | @font-face { 93 | font-family: 'Open Sans'; 94 | font-style: normal; 95 | font-weight: 400; 96 | font-stretch: 100%; 97 | font-display: swap; 98 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4gaVI.woff2) format('woff2'); 99 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; 100 | } 101 | -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4gaVI.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4gaVI.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4iaVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4iaVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4jaVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4jaVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4kaVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4kaVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4saVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4saVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4taVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4taVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4uaVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4uaVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4vaVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4vaVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5OaVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5OaVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5caVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.10/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5caVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.9/font.css: -------------------------------------------------------------------------------- 1 | /* cyrillic-ext */ 2 | @font-face { 3 | font-family: 'Open Sans'; 4 | font-style: normal; 5 | font-weight: 400; 6 | font-stretch: 100%; 7 | font-display: swap; 8 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4taVIGxA.woff2) format('woff2'); 9 | unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; 10 | } 11 | /* cyrillic */ 12 | @font-face { 13 | font-family: 'Open Sans'; 14 | font-style: normal; 15 | font-weight: 400; 16 | font-stretch: 100%; 17 | font-display: swap; 18 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4kaVIGxA.woff2) format('woff2'); 19 | unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 20 | } 21 | /* greek-ext */ 22 | @font-face { 23 | font-family: 'Open Sans'; 24 | font-style: normal; 25 | font-weight: 400; 26 | font-stretch: 100%; 27 | font-display: swap; 28 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4saVIGxA.woff2) format('woff2'); 29 | unicode-range: U+1F00-1FFF; 30 | } 31 | /* greek */ 32 | @font-face { 33 | font-family: 'Open Sans'; 34 | font-style: normal; 35 | font-weight: 400; 36 | font-stretch: 100%; 37 | font-display: swap; 38 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4jaVIGxA.woff2) format('woff2'); 39 | unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; 40 | } 41 | /* hebrew */ 42 | @font-face { 43 | font-family: 'Open Sans'; 44 | font-style: normal; 45 | font-weight: 400; 46 | font-stretch: 100%; 47 | font-display: swap; 48 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4iaVIGxA.woff2) format('woff2'); 49 | unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; 50 | } 51 | /* math */ 52 | @font-face { 53 | font-family: 'Open Sans'; 54 | font-style: normal; 55 | font-weight: 400; 56 | font-stretch: 100%; 57 | font-display: swap; 58 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5caVIGxA.woff2) format('woff2'); 59 | unicode-range: U+0302-0303, U+0305, U+0307-0308, U+0330, U+0391-03A1, U+03A3-03A9, U+03B1-03C9, U+03D1, U+03D5-03D6, U+03F0-03F1, U+03F4-03F5, U+2034-2037, U+2057, U+20D0-20DC, U+20E1, U+20E5-20EF, U+2102, U+210A-210E, U+2110-2112, U+2115, U+2119-211D, U+2124, U+2128, U+212C-212D, U+212F-2131, U+2133-2138, U+213C-2140, U+2145-2149, U+2190, U+2192, U+2194-21AE, U+21B0-21E5, U+21F1-21F2, U+21F4-2211, U+2213-2214, U+2216-22FF, U+2308-230B, U+2310, U+2319, U+231C-2321, U+2336-237A, U+237C, U+2395, U+239B-23B6, U+23D0, U+23DC-23E1, U+2474-2475, U+25AF, U+25B3, U+25B7, U+25BD, U+25C1, U+25CA, U+25CC, U+25FB, U+266D-266F, U+27C0-27FF, U+2900-2AFF, U+2B0E-2B11, U+2B30-2B4C, U+2BFE, U+FF5B, U+FF5D, U+1D400-1D7FF, U+1EE00-1EEFF; 60 | } 61 | /* symbols */ 62 | @font-face { 63 | font-family: 'Open Sans'; 64 | font-style: normal; 65 | font-weight: 400; 66 | font-stretch: 100%; 67 | font-display: swap; 68 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5OaVIGxA.woff2) format('woff2'); 69 | unicode-range: U+0001-000C, U+000E-001F, U+007F-009F, U+20DD-20E0, U+20E2-20E4, U+2150-218F, U+2190, U+2192, U+2194-2199, U+21AF, U+21E6-21F0, U+21F3, U+2218-2219, U+2299, U+22C4-22C6, U+2300-243F, U+2440-244A, U+2460-24FF, U+25A0-27BF, U+2800-28FF, U+2921-2922, U+2981, U+29BF, U+29EB, U+2B00-2BFF, U+4DC0-4DFF, U+FFF9-FFFB, U+10140-1018E, U+10190-1019C, U+101A0, U+101D0-101FD, U+102E0-102FB, U+10E60-10E7E, U+1D2C0-1D2D3, U+1D2E0-1D37F, U+1F000-1F0FF, U+1F100-1F1AD, U+1F1E6-1F1FF, U+1F30D-1F30F, U+1F315, U+1F31C, U+1F31E, U+1F320-1F32C, U+1F336, U+1F378, U+1F37D, U+1F382, U+1F393-1F39F, U+1F3A7-1F3A8, U+1F3AC-1F3AF, U+1F3C2, U+1F3C4-1F3C6, U+1F3CA-1F3CE, U+1F3D4-1F3E0, U+1F3ED, U+1F3F1-1F3F3, U+1F3F5-1F3F7, U+1F408, U+1F415, U+1F41F, U+1F426, U+1F43F, U+1F441-1F442, U+1F444, U+1F446-1F449, U+1F44C-1F44E, U+1F453, U+1F46A, U+1F47D, U+1F4A3, U+1F4B0, U+1F4B3, U+1F4B9, U+1F4BB, U+1F4BF, U+1F4C8-1F4CB, U+1F4D6, U+1F4DA, U+1F4DF, U+1F4E3-1F4E6, U+1F4EA-1F4ED, U+1F4F7, U+1F4F9-1F4FB, U+1F4FD-1F4FE, U+1F503, U+1F507-1F50B, U+1F50D, U+1F512-1F513, U+1F53E-1F54A, U+1F54F-1F5FA, U+1F610, U+1F650-1F67F, U+1F687, U+1F68D, U+1F691, U+1F694, U+1F698, U+1F6AD, U+1F6B2, U+1F6B9-1F6BA, U+1F6BC, U+1F6C6-1F6CF, U+1F6D3-1F6D7, U+1F6E0-1F6EA, U+1F6F0-1F6F3, U+1F6F7-1F6FC, U+1F700-1F7FF, U+1F800-1F80B, U+1F810-1F847, U+1F850-1F859, U+1F860-1F887, U+1F890-1F8AD, U+1F8B0-1F8B1, U+1F900-1F90B, U+1F93B, U+1F946, U+1F984, U+1F996, U+1F9E9, U+1FA00-1FA6F, U+1FA70-1FA7C, U+1FA80-1FA88, U+1FA90-1FABD, U+1FABF-1FAC5, U+1FACE-1FADB, U+1FAE0-1FAE8, U+1FAF0-1FAF8, U+1FB00-1FBFF; 70 | } 71 | /* vietnamese */ 72 | @font-face { 73 | font-family: 'Open Sans'; 74 | font-style: normal; 75 | font-weight: 400; 76 | font-stretch: 100%; 77 | font-display: swap; 78 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4vaVIGxA.woff2) format('woff2'); 79 | unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; 80 | } 81 | /* latin-ext */ 82 | @font-face { 83 | font-family: 'Open Sans'; 84 | font-style: normal; 85 | font-weight: 400; 86 | font-stretch: 100%; 87 | font-display: swap; 88 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4uaVIGxA.woff2) format('woff2'); 89 | unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; 90 | } 91 | /* latin */ 92 | @font-face { 93 | font-family: 'Open Sans'; 94 | font-style: normal; 95 | font-weight: 400; 96 | font-stretch: 100%; 97 | font-display: swap; 98 | src: url(memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4gaVI.woff2) format('woff2'); 99 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; 100 | } 101 | -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4gaVI.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4gaVI.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4iaVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4iaVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4jaVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4jaVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4kaVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4kaVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4saVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4saVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4taVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4taVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4uaVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4uaVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4vaVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B4vaVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5OaVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5OaVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5caVIGxA.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/Open_Sans-0.4.9/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsjZ0B5caVIGxA.woff2 -------------------------------------------------------------------------------- /docs/deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v1.0.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | !function(a){"use strict";window.Toc={helpers:{findOrFilter:function(e,t){var n=e.find(t);return e.filter(t).add(n).filter(":not([data-toc-skip])")},generateUniqueIdBase:function(e){return a(e).text().trim().replace(/\'/gi,"").replace(/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\\n\t\b\v]/g,"-").replace(/-{2,}/g,"-").substring(0,64).replace(/^-+|-+$/gm,"").toLowerCase()||e.tagName.toLowerCase()},generateUniqueId:function(e){for(var t=this.generateUniqueIdBase(e),n=0;;n++){var r=t;if(0')},createChildNavList:function(e){var t=this.createNavList();return e.append(t),t},generateNavEl:function(e,t){var n=a('');n.attr("href","#"+e),n.text(t);var r=a("
  • ");return r.append(n),r},generateNavItem:function(e){var t=this.generateAnchor(e),n=a(e),r=n.data("toc-text")||n.text();return this.generateNavEl(t,r)},getTopLevel:function(e){for(var t=1;t<=6;t++){if(1 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.4.2/webfonts/fa-brands-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.4.2/webfonts/fa-brands-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.4.2/webfonts/fa-regular-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.4.2/webfonts/fa-regular-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.4.2/webfonts/fa-solid-900.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.4.2/webfonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-v4compatibility.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.4.2/webfonts/fa-v4compatibility.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.4.2/webfonts/fa-v4compatibility.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.4.2/webfonts/fa-v4compatibility.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2 -------------------------------------------------------------------------------- /docs/deps/headroom-0.11.0/headroom.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * headroom.js v0.11.0 - Give your page some headroom. Hide your header until you need it 3 | * Copyright (c) 2020 Nick Williams - http://wicky.nillia.ms/headroom.js 4 | * License: MIT 5 | */ 6 | 7 | !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).Headroom=n()}(this,function(){"use strict";function t(){return"undefined"!=typeof window}function d(t){return function(t){return t&&t.document&&function(t){return 9===t.nodeType}(t.document)}(t)?function(t){var n=t.document,o=n.body,s=n.documentElement;return{scrollHeight:function(){return Math.max(o.scrollHeight,s.scrollHeight,o.offsetHeight,s.offsetHeight,o.clientHeight,s.clientHeight)},height:function(){return t.innerHeight||s.clientHeight||o.clientHeight},scrollY:function(){return void 0!==t.pageYOffset?t.pageYOffset:(s||o.parentNode||o).scrollTop}}}(t):function(t){return{scrollHeight:function(){return Math.max(t.scrollHeight,t.offsetHeight,t.clientHeight)},height:function(){return Math.max(t.offsetHeight,t.clientHeight)},scrollY:function(){return t.scrollTop}}}(t)}function n(t,s,e){var n,o=function(){var n=!1;try{var t={get passive(){n=!0}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){n=!1}return n}(),i=!1,r=d(t),l=r.scrollY(),a={};function c(){var t=Math.round(r.scrollY()),n=r.height(),o=r.scrollHeight();a.scrollY=t,a.lastScrollY=l,a.direction=ls.tolerance[a.direction],e(a),l=t,i=!1}function h(){i||(i=!0,n=requestAnimationFrame(c))}var u=!!o&&{passive:!0,capture:!1};return t.addEventListener("scroll",h,u),c(),{destroy:function(){cancelAnimationFrame(n),t.removeEventListener("scroll",h,u)}}}function o(t,n){n=n||{},Object.assign(this,o.options,n),this.classes=Object.assign({},o.options.classes,n.classes),this.elem=t,this.tolerance=function(t){return t===Object(t)?t:{down:t,up:t}}(this.tolerance),this.initialised=!1,this.frozen=!1}return o.prototype={constructor:o,init:function(){return o.cutsTheMustard&&!this.initialised&&(this.addClass("initial"),this.initialised=!0,setTimeout(function(t){t.scrollTracker=n(t.scroller,{offset:t.offset,tolerance:t.tolerance},t.update.bind(t))},100,this)),this},destroy:function(){this.initialised=!1,Object.keys(this.classes).forEach(this.removeClass,this),this.scrollTracker.destroy()},unpin:function(){!this.hasClass("pinned")&&this.hasClass("unpinned")||(this.addClass("unpinned"),this.removeClass("pinned"),this.onUnpin&&this.onUnpin.call(this))},pin:function(){this.hasClass("unpinned")&&(this.addClass("pinned"),this.removeClass("unpinned"),this.onPin&&this.onPin.call(this))},freeze:function(){this.frozen=!0,this.addClass("frozen")},unfreeze:function(){this.frozen=!1,this.removeClass("frozen")},top:function(){this.hasClass("top")||(this.addClass("top"),this.removeClass("notTop"),this.onTop&&this.onTop.call(this))},notTop:function(){this.hasClass("notTop")||(this.addClass("notTop"),this.removeClass("top"),this.onNotTop&&this.onNotTop.call(this))},bottom:function(){this.hasClass("bottom")||(this.addClass("bottom"),this.removeClass("notBottom"),this.onBottom&&this.onBottom.call(this))},notBottom:function(){this.hasClass("notBottom")||(this.addClass("notBottom"),this.removeClass("bottom"),this.onNotBottom&&this.onNotBottom.call(this))},shouldUnpin:function(t){return"down"===t.direction&&!t.top&&t.toleranceExceeded},shouldPin:function(t){return"up"===t.direction&&t.toleranceExceeded||t.top},addClass:function(t){this.elem.classList.add.apply(this.elem.classList,this.classes[t].split(" "))},removeClass:function(t){this.elem.classList.remove.apply(this.elem.classList,this.classes[t].split(" "))},hasClass:function(t){return this.classes[t].split(" ").every(function(t){return this.classList.contains(t)},this.elem)},update:function(t){t.isOutOfBounds||!0!==this.frozen&&(t.top?this.top():this.notTop(),t.bottom?this.bottom():this.notBottom(),this.shouldUnpin(t)?this.unpin():this.shouldPin(t)&&this.pin())}},o.options={tolerance:{up:0,down:0},offset:0,scroller:t()?window:null,classes:{frozen:"headroom--frozen",pinned:"headroom--pinned",unpinned:"headroom--unpinned",top:"headroom--top",notTop:"headroom--not-top",bottom:"headroom--bottom",notBottom:"headroom--not-bottom",initial:"headroom"}},o.cutsTheMustard=!!(t()&&function(){}.bind&&"classList"in document.documentElement&&Object.assign&&Object.keys&&requestAnimationFrame),o}); -------------------------------------------------------------------------------- /docs/deps/headroom-0.11.0/jQuery.headroom.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * headroom.js v0.9.4 - Give your page some headroom. Hide your header until you need it 3 | * Copyright (c) 2017 Nick Williams - http://wicky.nillia.ms/headroom.js 4 | * License: MIT 5 | */ 6 | 7 | !function(a){a&&(a.fn.headroom=function(b){return this.each(function(){var c=a(this),d=c.data("headroom"),e="object"==typeof b&&b;e=a.extend(!0,{},Headroom.options,e),d||(d=new Headroom(this,e),d.init(),c.data("headroom",d)),"string"==typeof b&&(d[b](),"destroy"===b&&c.removeData("headroom"))})},a("[data-headroom]").each(function(){var b=a(this);b.headroom(b.data())}))}(window.Zepto||window.jQuery); -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /docs/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/favicon-16x16.png -------------------------------------------------------------------------------- /docs/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/favicon-32x32.png -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/favicon.ico -------------------------------------------------------------------------------- /docs/katex-auto.js: -------------------------------------------------------------------------------- 1 | // https://github.com/jgm/pandoc/blob/29fa97ab96b8e2d62d48326e1b949a71dc41f47a/src/Text/Pandoc/Writers/HTML.hs#L332-L345 2 | document.addEventListener("DOMContentLoaded", function () { 3 | var mathElements = document.getElementsByClassName("math"); 4 | var macros = []; 5 | for (var i = 0; i < mathElements.length; i++) { 6 | var texText = mathElements[i].firstChild; 7 | if (mathElements[i].tagName == "SPAN") { 8 | katex.render(texText.data, mathElements[i], { 9 | displayMode: mathElements[i].classList.contains("display"), 10 | throwOnError: false, 11 | macros: macros, 12 | fleqn: false 13 | }); 14 | }}}); 15 | -------------------------------------------------------------------------------- /docs/lightswitch.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Color mode toggler for Bootstrap's docs (https://getbootstrap.com/) 4 | * Copyright 2011-2023 The Bootstrap Authors 5 | * Licensed under the Creative Commons Attribution 3.0 Unported License. 6 | * Updates for {pkgdown} by the {bslib} authors, also licensed under CC-BY-3.0. 7 | */ 8 | 9 | const getStoredTheme = () => localStorage.getItem('theme') 10 | const setStoredTheme = theme => localStorage.setItem('theme', theme) 11 | 12 | const getPreferredTheme = () => { 13 | const storedTheme = getStoredTheme() 14 | if (storedTheme) { 15 | return storedTheme 16 | } 17 | 18 | return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light' 19 | } 20 | 21 | const setTheme = theme => { 22 | if (theme === 'auto') { 23 | document.documentElement.setAttribute('data-bs-theme', (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) 24 | } else { 25 | document.documentElement.setAttribute('data-bs-theme', theme) 26 | } 27 | } 28 | 29 | function bsSetupThemeToggle () { 30 | 'use strict' 31 | 32 | const showActiveTheme = (theme, focus = false) => { 33 | var activeLabel, activeIcon; 34 | 35 | document.querySelectorAll('[data-bs-theme-value]').forEach(element => { 36 | const buttonTheme = element.getAttribute('data-bs-theme-value') 37 | const isActive = buttonTheme == theme 38 | 39 | element.classList.toggle('active', isActive) 40 | element.setAttribute('aria-pressed', isActive) 41 | 42 | if (isActive) { 43 | activeLabel = element.textContent; 44 | activeIcon = element.querySelector('span').classList.value; 45 | } 46 | }) 47 | 48 | const themeSwitcher = document.querySelector('#dropdown-lightswitch') 49 | if (!themeSwitcher) { 50 | return 51 | } 52 | 53 | themeSwitcher.setAttribute('aria-label', activeLabel) 54 | themeSwitcher.querySelector('span').classList.value = activeIcon; 55 | 56 | if (focus) { 57 | themeSwitcher.focus() 58 | } 59 | } 60 | 61 | window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => { 62 | const storedTheme = getStoredTheme() 63 | if (storedTheme !== 'light' && storedTheme !== 'dark') { 64 | setTheme(getPreferredTheme()) 65 | } 66 | }) 67 | 68 | window.addEventListener('DOMContentLoaded', () => { 69 | showActiveTheme(getPreferredTheme()) 70 | 71 | document 72 | .querySelectorAll('[data-bs-theme-value]') 73 | .forEach(toggle => { 74 | toggle.addEventListener('click', () => { 75 | const theme = toggle.getAttribute('data-bs-theme-value') 76 | setTheme(theme) 77 | setStoredTheme(theme) 78 | showActiveTheme(theme, true) 79 | }) 80 | }) 81 | }) 82 | } 83 | 84 | setTheme(getPreferredTheme()); 85 | bsSetupThemeToggle(); 86 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/logo.png -------------------------------------------------------------------------------- /docs/package-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/package-logo.png -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('nav.navbar').headroom(); 6 | 7 | Toc.init({ 8 | $nav: $("#toc"), 9 | $scope: $("main h2, main h3, main h4, main h5, main h6") 10 | }); 11 | 12 | if ($('#toc').length) { 13 | $('body').scrollspy({ 14 | target: '#toc', 15 | offset: $("nav.navbar").outerHeight() + 1 16 | }); 17 | } 18 | 19 | // Activate popovers 20 | $('[data-bs-toggle="popover"]').popover({ 21 | container: 'body', 22 | html: true, 23 | trigger: 'focus', 24 | placement: "top", 25 | sanitize: false, 26 | }); 27 | 28 | $('[data-bs-toggle="tooltip"]').tooltip(); 29 | 30 | /* Clipboard --------------------------*/ 31 | 32 | function changeTooltipMessage(element, msg) { 33 | var tooltipOriginalTitle=element.getAttribute('data-bs-original-title'); 34 | element.setAttribute('data-bs-original-title', msg); 35 | $(element).tooltip('show'); 36 | element.setAttribute('data-bs-original-title', tooltipOriginalTitle); 37 | } 38 | 39 | if(ClipboardJS.isSupported()) { 40 | $(document).ready(function() { 41 | var copyButton = ""; 42 | 43 | $("div.sourceCode").addClass("hasCopyButton"); 44 | 45 | // Insert copy buttons: 46 | $(copyButton).prependTo(".hasCopyButton"); 47 | 48 | // Initialize tooltips: 49 | $('.btn-copy-ex').tooltip({container: 'body'}); 50 | 51 | // Initialize clipboard: 52 | var clipboard = new ClipboardJS('[data-clipboard-copy]', { 53 | text: function(trigger) { 54 | return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); 55 | } 56 | }); 57 | 58 | clipboard.on('success', function(e) { 59 | changeTooltipMessage(e.trigger, 'Copied!'); 60 | e.clearSelection(); 61 | }); 62 | 63 | clipboard.on('error', function(e) { 64 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 65 | }); 66 | 67 | }); 68 | } 69 | 70 | /* Search marking --------------------------*/ 71 | var url = new URL(window.location.href); 72 | var toMark = url.searchParams.get("q"); 73 | var mark = new Mark("main#main"); 74 | if (toMark) { 75 | mark.mark(toMark, { 76 | accuracy: { 77 | value: "complementary", 78 | limiters: [",", ".", ":", "/"], 79 | } 80 | }); 81 | } 82 | 83 | /* Search --------------------------*/ 84 | /* Adapted from https://github.com/rstudio/bookdown/blob/2d692ba4b61f1e466c92e78fd712b0ab08c11d31/inst/resources/bs4_book/bs4_book.js#L25 */ 85 | // Initialise search index on focus 86 | var fuse; 87 | $("#search-input").focus(async function(e) { 88 | if (fuse) { 89 | return; 90 | } 91 | 92 | $(e.target).addClass("loading"); 93 | var response = await fetch($("#search-input").data("search-index")); 94 | var data = await response.json(); 95 | 96 | var options = { 97 | keys: ["what", "text", "code"], 98 | ignoreLocation: true, 99 | threshold: 0.1, 100 | includeMatches: true, 101 | includeScore: true, 102 | }; 103 | fuse = new Fuse(data, options); 104 | 105 | $(e.target).removeClass("loading"); 106 | }); 107 | 108 | // Use algolia autocomplete 109 | var options = { 110 | autoselect: true, 111 | debug: true, 112 | hint: false, 113 | minLength: 2, 114 | }; 115 | var q; 116 | async function searchFuse(query, callback) { 117 | await fuse; 118 | 119 | var items; 120 | if (!fuse) { 121 | items = []; 122 | } else { 123 | q = query; 124 | var results = fuse.search(query, { limit: 20 }); 125 | items = results 126 | .filter((x) => x.score <= 0.75) 127 | .map((x) => x.item); 128 | if (items.length === 0) { 129 | items = [{dir:"Sorry 😿",previous_headings:"",title:"No results found.",what:"No results found.",path:window.location.href}]; 130 | } 131 | } 132 | callback(items); 133 | } 134 | $("#search-input").autocomplete(options, [ 135 | { 136 | name: "content", 137 | source: searchFuse, 138 | templates: { 139 | suggestion: (s) => { 140 | if (s.title == s.what) { 141 | return `${s.dir} >
    ${s.title}
    `; 142 | } else if (s.previous_headings == "") { 143 | return `${s.dir} >
    ${s.title}
    > ${s.what}`; 144 | } else { 145 | return `${s.dir} >
    ${s.title}
    > ${s.previous_headings} > ${s.what}`; 146 | } 147 | }, 148 | }, 149 | }, 150 | ]).on('autocomplete:selected', function(event, s) { 151 | window.location.href = s.path + "?q=" + q + "#" + s.id; 152 | }); 153 | }); 154 | })(window.jQuery || window.$) 155 | 156 | document.addEventListener('keydown', function(event) { 157 | // Check if the pressed key is '/' 158 | if (event.key === '/') { 159 | event.preventDefault(); // Prevent any default action associated with the '/' key 160 | document.getElementById('search-input').focus(); // Set focus to the search input 161 | } 162 | }); 163 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: '3.4' 2 | pkgdown: 2.1.3 3 | pkgdown_sha: ~ 4 | articles: {} 5 | last_built: 2025-05-25T10:15Z 6 | urls: 7 | reference: https://mharinga.github.io/spatialrisk/reference 8 | article: https://mharinga.github.io/spatialrisk/articles 9 | -------------------------------------------------------------------------------- /docs/reference/choropleth-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/reference/choropleth-1.png -------------------------------------------------------------------------------- /docs/reference/choropleth_ggplot2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/reference/choropleth_ggplot2-1.png -------------------------------------------------------------------------------- /docs/reference/figures/example3a-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/reference/figures/example3a-1.png -------------------------------------------------------------------------------- /docs/reference/figures/nl_choro1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/reference/figures/nl_choro1.png -------------------------------------------------------------------------------- /docs/reference/figures/nl_choro2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/reference/figures/nl_choro2.png -------------------------------------------------------------------------------- /docs/reference/figures/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/reference/figures/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /docs/reference/figures/unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/docs/reference/figures/unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /docs/reference/highest_conc.html: -------------------------------------------------------------------------------- 1 | 2 | Find the highest concentration for the current iteration — highest_conc • spatialrisk 3 | Skip to contents 4 | 5 | 6 |
    26 |
    27 |
    32 | 33 |
    34 |

    Find the highest concentration for the current iteration.

    35 |
    36 | 37 |
    38 |

    Usage

    39 |
    highest_conc(hf_conc_new, high_foc, db)
    40 |
    41 | 42 |
    43 |

    Arguments

    44 | 45 | 46 |
    hf_conc_new
    47 |

    highest concentrations from the current iteration, 48 | retrieved from conc_per_cell_new().

    49 | 50 | 51 |
    high_foc
    52 |

    data.frame containing cell ids with the top n focal values 53 | from the current iteration.

    54 | 55 | 56 |
    db
    57 |

    data.frame containing previously saved highest concentrations.

    58 | 59 |
    60 |
    61 |

    Author

    62 |

    Martin Haringa

    63 |
    64 | 65 |
    67 | 68 | 69 |
    72 | 73 | 76 | 77 |
    78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/reference/insurance.html: -------------------------------------------------------------------------------- 1 | 2 | Sum insured per postal code in the Netherlands — insurance • spatialrisk 7 | Skip to contents 8 | 9 | 10 |
    30 |
    31 |
    36 | 37 |
    38 |

    A dataset of postal codes with their sum insured, population 39 | and the corresponding spatial locations in terms of a latitude and a 40 | longitude.

    41 |
    42 | 43 |
    44 |

    Usage

    45 |
    insurance
    46 |
    47 | 48 |
    49 |

    Format

    50 |

    A data frame with 29,990 rows and 5 variables:

    postcode
    51 |

    6-digit postal code

    52 | 53 |
    population_pc4
    54 |

    Population per 4-digit postal code

    55 | 56 |
    amount
    57 |

    Sum insured

    58 | 59 |
    lon
    60 |

    Longitude (in degrees) of the corresponding 6-digit postal code

    61 | 62 |
    lat
    63 |

    Latitude (in degrees) of the corresponding 6-digit postal code

    64 | 65 | 66 |
    67 |
    68 |

    Author

    69 |

    Martin Haringa

    70 |
    71 | 72 |
    74 | 75 | 76 |
    79 | 80 | 83 | 84 |
    85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /docs/reference/knmi_stations.html: -------------------------------------------------------------------------------- 1 | 2 | KNMI stations — knmi_stations • spatialrisk 5 | Skip to contents 6 | 7 | 8 |
    28 |
    29 |
    34 | 35 |
    36 |

    A data frame containing the IDs and meta-data on the official 37 | KNMI weather stations.

    38 |
    39 | 40 |
    41 |

    Usage

    42 |
    knmi_stations
    43 |
    44 | 45 |
    46 |

    Format

    47 |

    A data frame with 50 rows and 7 variables:

    station
    48 |

    ID of the station (209-391)

    49 | 50 |
    city
    51 |

    City where the station is located

    52 | 53 |
    lon
    54 |

    Longitude of station (crs = 4326)

    55 | 56 |
    lat
    57 |

    Latitude of the station (crs = 4326)

    58 | 59 |
    altitude
    60 |

    Altitude of the station (in meters)

    61 | 62 |
    X
    63 |

    X coordinate of the station (crs = 32631)

    64 | 65 |
    Y
    66 |

    Y coordinate of the station (crs = 32631)

    67 | 68 | 69 |
    70 |
    71 |

    Author

    72 |

    Martin Haringa

    73 |
    74 | 75 |
    77 | 78 | 79 |
    82 | 83 | 86 | 87 |
    88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /docs/reference/nl_gemeente.html: -------------------------------------------------------------------------------- 1 | 2 | Object of class sf for municipalities in the Netherlands — nl_gemeente • spatialrisk 5 | Skip to contents 6 | 7 | 8 |
    28 |
    29 |
    34 | 35 |
    36 |

    An object of class sf (simple feature) for municipalities 37 | (Dutch: gemeentes) in the Netherlands in the year 2021.

    38 |
    39 | 40 |
    41 |

    Usage

    42 |
    nl_gemeente
    43 |
    44 | 45 |
    46 |

    Format

    47 |

    A simple feature object with 380 rows and 6 variables:

    id
    48 |

    id of gemeente

    49 | 50 |
    code
    51 |

    code of gemeente

    52 | 53 |
    areaname
    54 |

    name of gemeente

    55 | 56 |
    lon
    57 |

    longitude of the gemeente centroid

    58 | 59 |
    lat
    60 |

    latitude of the gemeente centroid

    61 | 62 |
    geometry
    63 |

    geometry object of gemeente

    64 | 65 | 66 |
    67 |
    68 |

    Author

    69 |

    Martin Haringa

    70 |
    71 | 72 |
    74 | 75 | 76 |
    79 | 80 | 83 | 84 |
    85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /docs/reference/nl_provincie.html: -------------------------------------------------------------------------------- 1 | 2 | Object of class sf for provinces in the Netherlands — nl_provincie • spatialrisk 5 | Skip to contents 6 | 7 | 8 |
    28 |
    29 |
    34 | 35 |
    36 |

    An object of class sf (simple feature) for provinces 37 | (Dutch: provincies) in the Netherlands.

    38 |
    39 | 40 |
    41 |

    Usage

    42 |
    nl_provincie
    43 |
    44 | 45 |
    46 |

    Format

    47 |

    A simple feature object with 12 rows and 4 variables:

    areaname
    48 |

    province name

    49 | 50 |
    geometry
    51 |

    geometry object of province

    52 | 53 |
    lon
    54 |

    longitude of the province centroid

    55 | 56 |
    lat
    57 |

    latitude of the province centroid

    58 | 59 | 60 |
    61 |
    62 |

    Author

    63 |

    Martin Haringa

    64 |
    65 | 66 |
    68 | 69 | 70 |
    73 | 74 | 77 | 78 |
    79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/reference/update_db.html: -------------------------------------------------------------------------------- 1 | 2 | Save highest concentrations per cell for subsequent iterations — update_db • spatialrisk 3 | Skip to contents 4 | 5 | 6 |
    26 |
    27 |
    32 | 33 |
    34 |

    Save highest concentrations per cell for subsequent iterations.

    35 |
    36 | 37 |
    38 |

    Usage

    39 |
    update_db(hf_conc_new, db, cells)
    40 |
    41 | 42 |
    43 |

    Arguments

    44 | 45 | 46 |
    hf_conc_new
    47 |

    highest concentrations from the current iteration, 48 | obtained from conc_per_cell_new().

    49 | 50 | 51 |
    db
    52 |

    data.frame containing previously saved highest concentrations.

    53 | 54 | 55 |
    cells
    56 |

    cells containing points associated with the current highest 57 | concentration to be removed from db.

    58 | 59 |
    60 |
    61 |

    Author

    62 |

    Martin Haringa

    63 |
    64 | 65 |
    67 | 68 | 69 |
    72 | 73 | 76 | 77 |
    78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | https://mharinga.github.io/spatialrisk/404.html 3 | https://mharinga.github.io/spatialrisk/authors.html 4 | https://mharinga.github.io/spatialrisk/index.html 5 | https://mharinga.github.io/spatialrisk/news/index.html 6 | https://mharinga.github.io/spatialrisk/reference/Groningen.html 7 | https://mharinga.github.io/spatialrisk/reference/cells_above_threshold.html 8 | https://mharinga.github.io/spatialrisk/reference/choropleth.html 9 | https://mharinga.github.io/spatialrisk/reference/choropleth_ggplot2.html 10 | https://mharinga.github.io/spatialrisk/reference/conc_per_cell_new.html 11 | https://mharinga.github.io/spatialrisk/reference/concentration.html 12 | https://mharinga.github.io/spatialrisk/reference/convert_crs_df.html 13 | https://mharinga.github.io/spatialrisk/reference/convert_df_to_sf.html 14 | https://mharinga.github.io/spatialrisk/reference/find_highest_concentration.html 15 | https://mharinga.github.io/spatialrisk/reference/haversine.html 16 | https://mharinga.github.io/spatialrisk/reference/highest_conc.html 17 | https://mharinga.github.io/spatialrisk/reference/highest_concentration.html 18 | https://mharinga.github.io/spatialrisk/reference/index.html 19 | https://mharinga.github.io/spatialrisk/reference/insurance.html 20 | https://mharinga.github.io/spatialrisk/reference/interpolate_spline.html 21 | https://mharinga.github.io/spatialrisk/reference/knmi_historic_data.html 22 | https://mharinga.github.io/spatialrisk/reference/knmi_stations.html 23 | https://mharinga.github.io/spatialrisk/reference/map_points_to_cells.html 24 | https://mharinga.github.io/spatialrisk/reference/mw_create.html 25 | https://mharinga.github.io/spatialrisk/reference/neighborhood_gh_search.html 26 | https://mharinga.github.io/spatialrisk/reference/nl_corop.html 27 | https://mharinga.github.io/spatialrisk/reference/nl_gemeente.html 28 | https://mharinga.github.io/spatialrisk/reference/nl_postcode2.html 29 | https://mharinga.github.io/spatialrisk/reference/nl_postcode3.html 30 | https://mharinga.github.io/spatialrisk/reference/nl_postcode4.html 31 | https://mharinga.github.io/spatialrisk/reference/nl_provincie.html 32 | https://mharinga.github.io/spatialrisk/reference/plot.conc.html 33 | https://mharinga.github.io/spatialrisk/reference/plot.concentration.html 34 | https://mharinga.github.io/spatialrisk/reference/plot.html 35 | https://mharinga.github.io/spatialrisk/reference/plot_points.html 36 | https://mharinga.github.io/spatialrisk/reference/points_in_circle.html 37 | https://mharinga.github.io/spatialrisk/reference/points_in_circle_vec.html 38 | https://mharinga.github.io/spatialrisk/reference/points_to_polygon.html 39 | https://mharinga.github.io/spatialrisk/reference/top_n_focals.html 40 | https://mharinga.github.io/spatialrisk/reference/update_db.html 41 | https://mharinga.github.io/spatialrisk/reference/update_focal.html 42 | https://mharinga.github.io/spatialrisk/reference/update_rasterize.html 43 | 44 | 45 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/logo.png -------------------------------------------------------------------------------- /man/Groningen.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data_Groningen.R 3 | \docType{data} 4 | \name{Groningen} 5 | \alias{Groningen} 6 | \title{Coordinates of houses in Groningen} 7 | \format{ 8 | A data frame with 25000 rows and 8 variables: 9 | \describe{ 10 | \item{street}{Name of street} 11 | \item{number}{Number of house} 12 | \item{letter}{Letter of house} 13 | \item{suffix}{Suffix to number of house} 14 | \item{postal_code}{Postal code of house} 15 | \item{city}{The name of the city} 16 | \item{lon}{Longitude (in degrees)} 17 | \item{lat}{Latitude (in degrees)} 18 | \item{amount}{Random value} 19 | } 20 | } 21 | \source{ 22 | The BAG is the Dutch registry for Buildings and adresses 23 | (Basisregistratie adressen en gebouwen). 24 | } 25 | \usage{ 26 | Groningen 27 | } 28 | \description{ 29 | A dataset of postal codes and the corresponding spatial locations in terms of 30 | a latitude and a longitude. 31 | } 32 | \keyword{datasets} 33 | -------------------------------------------------------------------------------- /man/cells_above_threshold.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{cells_above_threshold} 4 | \alias{cells_above_threshold} 5 | \title{Identify the focal cells exceeding the threshold} 6 | \usage{ 7 | cells_above_threshold(focal, threshold) 8 | } 9 | \arguments{ 10 | \item{focal}{focal as output from \code{terra::focal()}.} 11 | 12 | \item{threshold}{lower (numeric) threshold boundary.} 13 | } 14 | \description{ 15 | Generate a data.frame containing the cell indices of the focal 16 | cells surpassing the specified threshold. Additionally, include columns for 17 | the coordinates (xy) corresponding to the center of each cell. 18 | } 19 | \author{ 20 | Martin Haringa 21 | } 22 | \keyword{internal} 23 | -------------------------------------------------------------------------------- /man/choropleth.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/map_choropleth.R 3 | \name{choropleth} 4 | \alias{choropleth} 5 | \title{Create choropleth map} 6 | \usage{ 7 | choropleth( 8 | sf_object, 9 | value = "output", 10 | id_name = "areaname", 11 | mode = "plot", 12 | n = 7, 13 | legend_title = "Clustering", 14 | palette = "viridis" 15 | ) 16 | } 17 | \arguments{ 18 | \item{sf_object}{object of class sf} 19 | 20 | \item{value}{column name to shade the polygons} 21 | 22 | \item{id_name}{column name of ids to plot} 23 | 24 | \item{mode}{choose between static ('plot' is default) and interactive 25 | map ('view')} 26 | 27 | \item{n}{number of clusters (default is 7)} 28 | 29 | \item{legend_title}{title of legend} 30 | 31 | \item{palette}{palette name or a vector of colors. See 32 | \code{tmaptools::palette_explorer()} for the named palettes. 33 | Use a \code{-} as prefix to reverse the palette. The default palette is 34 | "viridis".} 35 | } 36 | \value{ 37 | tmap 38 | } 39 | \description{ 40 | Takes an object produced by \code{points_to_polygon()}, and 41 | creates the corresponding choropleth map. The given clustering is according 42 | to the Fisher-Jenks algorithm. This commonly used method for choropleths 43 | seeks to reduce the variance within classes and maximize the variance 44 | between classes. 45 | } 46 | \examples{ 47 | test <- points_to_polygon(nl_provincie, insurance, sum(amount, na.rm = TRUE)) 48 | choropleth(test) 49 | choropleth(test, id_name = "areaname", mode = "view") 50 | 51 | } 52 | \author{ 53 | Martin Haringa 54 | } 55 | -------------------------------------------------------------------------------- /man/choropleth_ggplot2.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/map_ggplot2.R 3 | \name{choropleth_ggplot2} 4 | \alias{choropleth_ggplot2} 5 | \title{Map object of class sf using ggplot2} 6 | \usage{ 7 | choropleth_ggplot2( 8 | sf_object, 9 | value = output, 10 | n = 7, 11 | dig.lab = 2, 12 | legend_title = "Class", 13 | option = "D", 14 | direction = 1 15 | ) 16 | } 17 | \arguments{ 18 | \item{sf_object}{object of class sf} 19 | 20 | \item{value}{column to shade the polygons} 21 | 22 | \item{n}{number of clusters (default is 7)} 23 | 24 | \item{dig.lab}{number of digits in legend (default is 2)} 25 | 26 | \item{legend_title}{title of legend} 27 | 28 | \item{option}{a character string indicating the colormap option to use. Four 29 | options are available: "magma" (or "A"), "inferno" (or "B"), "plasma" 30 | (or "C"), "viridis" (or "D", the default option) and "cividis" (or "E").} 31 | 32 | \item{direction}{Sets the order of colors in the scale. If \code{1}, 33 | the default, colors are ordered from darkest to lightest. If \code{-1}, 34 | the order of colors is reversed.} 35 | } 36 | \value{ 37 | ggplot map 38 | } 39 | \description{ 40 | Takes an object produced by \code{choropleth_sf()}, and creates 41 | the correspoding choropleth map. 42 | } 43 | \examples{ 44 | test <- points_to_polygon(nl_postcode2, insurance, sum(amount, na.rm = TRUE)) 45 | choropleth_ggplot2(test) 46 | 47 | } 48 | \author{ 49 | Martin Haringa 50 | } 51 | -------------------------------------------------------------------------------- /man/conc_per_cell_new.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{conc_per_cell_new} 4 | \alias{conc_per_cell_new} 5 | \title{Determine the concentrations within the highest focal cells for the current 6 | iteration} 7 | \usage{ 8 | conc_per_cell_new( 9 | high_foc, 10 | dff, 11 | value, 12 | size, 13 | points, 14 | db, 15 | radius, 16 | crs_from, 17 | crs_to, 18 | lon, 19 | lat 20 | ) 21 | } 22 | \arguments{ 23 | \item{high_foc}{data.frame containing cell ids with the top n focal values 24 | from the current iteration.} 25 | 26 | \item{dff}{data.frame with all observations} 27 | 28 | \item{value}{column name in `dff` to find concentrations for.} 29 | 30 | \item{size}{size of cell in meters.} 31 | 32 | \item{points}{number of points per `size`.} 33 | 34 | \item{db}{data.frame containing previously saved highest concentrations.} 35 | 36 | \item{radius}{radius of circle in meters.} 37 | 38 | \item{crs_from}{crs from} 39 | 40 | \item{crs_to}{crs to} 41 | } 42 | \description{ 43 | Determine the concentrations within the highest focal cells for 44 | the current iteration. 45 | } 46 | \author{ 47 | Martin Haringa 48 | } 49 | \keyword{internal} 50 | -------------------------------------------------------------------------------- /man/concentration.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/concentration.R 3 | \name{concentration} 4 | \alias{concentration} 5 | \title{Concentration calculation} 6 | \usage{ 7 | concentration( 8 | sub, 9 | full, 10 | value, 11 | lon_sub = lon, 12 | lat_sub = lat, 13 | lon_full = lon, 14 | lat_full = lat, 15 | radius = 200, 16 | display_progress = TRUE 17 | ) 18 | } 19 | \arguments{ 20 | \item{sub}{data.frame of target points to calculate concentration risk for, 21 | including at least columns for longitude and latitude.} 22 | 23 | \item{full}{data.frame containing reference points, where the function finds 24 | locations within a radius from the target points. Should include at least 25 | columns for longitude, latitude, and the value of interest to summarize.} 26 | 27 | \item{value}{column name with value of interest to summarize in \code{full}.} 28 | 29 | \item{lon_sub}{column name in \code{sub} for longitude 30 | (default is \code{lon}).} 31 | 32 | \item{lat_sub}{column name in \code{sub} for latitude 33 | (default is \code{lat}).} 34 | 35 | \item{lon_full}{column name in \code{full} for longitude in \code{full} 36 | (default is \code{lon}).} 37 | 38 | \item{lat_full}{column name in \code{full} for latitude in \code{full} 39 | (default is \code{lat}).} 40 | 41 | \item{radius}{numeric. Radius of the circle in meters (default is 200).} 42 | 43 | \item{display_progress}{boolean indicating whether to show progress bar 44 | (TRUE/FALSE). Defaults to TRUE.} 45 | } 46 | \value{ 47 | A data.frame equal to \code{sub} including an additional 48 | column \code{concentration}. 49 | } 50 | \description{ 51 | Calculates the concentration, which is the sum of all 52 | observations within a circle of a certain radius. 53 | } 54 | \examples{ 55 | df <- data.frame(location = c("p1", "p2"), lon = c(6.561561, 6.561398), 56 | lat = c(53.21369, 53.21326)) 57 | concentration(df, Groningen, value = amount, radius = 100) 58 | 59 | } 60 | \author{ 61 | Martin Haringa 62 | } 63 | -------------------------------------------------------------------------------- /man/convert_crs_df.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{convert_crs_df} 4 | \alias{convert_crs_df} 5 | \title{Convert Coordinate Reference System (CRS)} 6 | \usage{ 7 | convert_crs_df( 8 | df, 9 | crs_from = 3035, 10 | crs_to = 4326, 11 | lon_from = "x", 12 | lat_from = "y", 13 | lon_to = "lon", 14 | lat_to = "lat" 15 | ) 16 | } 17 | \arguments{ 18 | \item{df}{data.frame to be converted.} 19 | 20 | \item{crs_from}{CRS code of the original coordinate system (default: 3035).} 21 | 22 | \item{crs_to}{CRS code of the target coordinate system (default: 4326).} 23 | 24 | \item{lon_from}{column name of longitude values in \code{df} (default: "x").} 25 | 26 | \item{lat_from}{column name of latitude values in \code{df} (default: "y").} 27 | 28 | \item{lon_to}{column name for longitude values in the converted data frame 29 | (default: "lon").} 30 | 31 | \item{lat_to}{column name for latitude values in the converted data frame 32 | (default: "lat").} 33 | } 34 | \value{ 35 | data.frame with converted coordinates 36 | } 37 | \description{ 38 | Convert Coordinate Reference System (CRS) of a data.frame 39 | from one CRS to another. 40 | } 41 | \author{ 42 | Martin Haringa 43 | } 44 | -------------------------------------------------------------------------------- /man/convert_df_to_sf.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{convert_df_to_sf} 4 | \alias{convert_df_to_sf} 5 | \title{Convert data.frame to simple features (sf) object} 6 | \usage{ 7 | convert_df_to_sf(df, lon = "lon", lat = "lat", crs_from = 4326, crs_to = 3035) 8 | } 9 | \arguments{ 10 | \item{df}{data.frame containing longitude and latitude columns} 11 | 12 | \item{lon}{column name for longitude values (default: "lon").} 13 | 14 | \item{lat}{column name for latitude values (default: "lat").} 15 | 16 | \item{crs_from}{crs of the original coordinate system (default: 4326).} 17 | 18 | \item{crs_to}{crs of the target coordinate system (default: 3035).} 19 | } 20 | \value{ 21 | Returns an sf object with the specified coordinate reference system. 22 | } 23 | \description{ 24 | This function converts a data.frame to a simple features (sf) object. 25 | } 26 | \author{ 27 | Martin Haringa 28 | } 29 | \keyword{internal} 30 | -------------------------------------------------------------------------------- /man/figures/example3a-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/man/figures/example3a-1.png -------------------------------------------------------------------------------- /man/figures/nl_choro1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/man/figures/nl_choro1.png -------------------------------------------------------------------------------- /man/figures/nl_choro2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/man/figures/nl_choro2.png -------------------------------------------------------------------------------- /man/figures/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/man/figures/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /man/figures/unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/man/figures/unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /man/find_highest_concentration.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/highest_concentration_terra.R 3 | \name{find_highest_concentration} 4 | \alias{find_highest_concentration} 5 | \title{Find highest concentration} 6 | \usage{ 7 | find_highest_concentration( 8 | df, 9 | value, 10 | top_n = 1, 11 | radius = 200, 12 | cell_size = 100, 13 | grid_precision = 1, 14 | lon = "lon", 15 | lat = "lat", 16 | crs_metric = 3035, 17 | print_progress = TRUE 18 | ) 19 | } 20 | \arguments{ 21 | \item{df}{data.frame. Should include at least columns for longitude, 22 | latitude, and the value of interest to summarize.} 23 | 24 | \item{value}{column name with value of interest to summarize in \code{df}.} 25 | 26 | \item{top_n}{positive integer value greater or equal to 1 (default is 1).} 27 | 28 | \item{radius}{numeric. Radius of the circle in meters (default is 200).} 29 | 30 | \item{cell_size}{numeric. Size of cell in meters (default is 100).} 31 | 32 | \item{grid_precision}{numeric. Precision of grid in meters (default is 1).} 33 | 34 | \item{lon}{column name in \code{df} with longitude (default is "lon"). 35 | Should be in EPSG:4326.} 36 | 37 | \item{lat}{column name in \code{df} with latitude (default is "lat"). 38 | Should be in EPSG:4326.} 39 | 40 | \item{crs_metric}{numeric. The metric Coordinate Reference System (CRS) is 41 | used solely in the background calculations. For European coordinates, 42 | \href{https://epsg.io/3035}{EPSG:3035} (default) is recommended. For the 43 | United States, \href{https://epsg.io/6317}{EPSG:6317} can be utilized. For 44 | Asia and the Pacific regions, \href{https://epsg.io/8859}{EPSG:8859} is 45 | recommended.} 46 | 47 | \item{print_progress}{print progress iteration steps.} 48 | } 49 | \value{ 50 | A list with two elements: 51 | \enumerate{ 52 | \item A data.frame containing the \code{top_n} concentrations as specified 53 | by \code{top_n}. 54 | \item A data.frame containing the rows from \code{df} that correspond to the 55 | \code{top_n} concentrations. 56 | } 57 | } 58 | \description{ 59 | Determines the central coordinates of a circle with a constant 60 | radius that maximizes the coverage of demand points. 61 | } 62 | \details{ 63 | A recent regulation by the European Commission mandates insurance 64 | companies to report the maximum value of insured fire risk policies for all 65 | buildings partially or fully situated within a circle with a radius of 200 66 | meters (see Article 132 - fire risk sub-module - of the Delegated 67 | Regulation). This article captures the risk of catastrophic fire or 68 | explosion, including as a result of terrorist attacks. The sub-module is 69 | based on the scenario that the insurance or reinsurance undertaking incurs a 70 | loss equal to the capital insured for each building located partly or fully 71 | within a radius of 200 meters. 72 | 73 | This problem resembles a Maximal Covering Location Problem (MCLP) 74 | with a fixed radius, belonging to the category of facility location problems. 75 | The main aim is to select the best locations for a predetermined number of 76 | facilities to achieve maximum coverage of demand points within a specified 77 | radius of each facility. In essence, the objective is to identify optimal 78 | facility locations to cover as many demand points as feasible, while ensuring 79 | that each demand point falls within the designated distance (radius) of at 80 | least one facility. 81 | } 82 | \examples{ 83 | x <- find_highest_concentration(Groningen, "amount") 84 | plot(x) 85 | 86 | y <- find_highest_concentration( 87 | Groningen, "amount", top_n = 2, cell_size = 50 88 | ) 89 | plot(y) 90 | 91 | } 92 | \references{ 93 | Commission Delegated Regulation (EU) (2015). Solvency II 94 | Delegated Act 2015/35. Official Journal of the European Union, 58:124. 95 | } 96 | \author{ 97 | Martin Haringa 98 | } 99 | -------------------------------------------------------------------------------- /man/haversine.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/haversine.R 3 | \name{haversine} 4 | \alias{haversine} 5 | \title{Haversine great circle distance} 6 | \usage{ 7 | haversine(lat_from, lon_from, lat_to, lon_to, r = 6378137) 8 | } 9 | \arguments{ 10 | \item{lat_from}{Latitude of the starting point.} 11 | 12 | \item{lon_from}{Longitude of the starting point.} 13 | 14 | \item{lat_to}{Latitude of the destination point.} 15 | 16 | \item{lon_to}{Longitude of the destination point.} 17 | 18 | \item{r}{Radius of the Earth in meters (default = 6378137).} 19 | } 20 | \value{ 21 | Vector of distances in the same unit as \code{r} (default in meters). 22 | } 23 | \description{ 24 | Calculates the shortest distance between two points on the 25 | Earth's surface using the Haversine formula, also known as the great-circle 26 | distance or "as the crow flies". 27 | } 28 | \details{ 29 | The Haversine ('half-versed-sine') formula was published by R.W. 30 | Sinnott in 1984, although it has been known for much longer. 31 | } 32 | \examples{ 33 | haversine(53.24007, 6.520386, 53.24054, 6.520386) 34 | 35 | } 36 | \references{ 37 | Sinnott, R.W, 1984. Virtues of the Haversine. Sky and Telescope 38 | 68(2): 159. 39 | } 40 | \author{ 41 | Martin Haringa 42 | } 43 | -------------------------------------------------------------------------------- /man/highest_conc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{highest_conc} 4 | \alias{highest_conc} 5 | \title{Find the highest concentration for the current iteration} 6 | \usage{ 7 | highest_conc(hf_conc_new, high_foc, db) 8 | } 9 | \arguments{ 10 | \item{hf_conc_new}{highest concentrations from the current iteration, 11 | retrieved from \code{conc_per_cell_new()}.} 12 | 13 | \item{high_foc}{data.frame containing cell ids with the top n focal values 14 | from the current iteration.} 15 | 16 | \item{db}{data.frame containing previously saved highest concentrations.} 17 | } 18 | \description{ 19 | Find the highest concentration for the current iteration. 20 | } 21 | \author{ 22 | Martin Haringa 23 | } 24 | \keyword{internal} 25 | -------------------------------------------------------------------------------- /man/highest_concentration.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/deprecated_highest_concentration.R 3 | \name{highest_concentration} 4 | \alias{highest_concentration} 5 | \title{Highest concentration risk} 6 | \usage{ 7 | highest_concentration( 8 | df, 9 | value, 10 | lon = lon, 11 | lat = lat, 12 | lowerbound = NULL, 13 | radius = 200, 14 | grid_distance = 25, 15 | gh_precision = 6, 16 | display_progress = TRUE 17 | ) 18 | } 19 | \arguments{ 20 | \item{df}{data.frame of locations, should at least include column for 21 | longitude, latitude and sum insured.} 22 | 23 | \item{value}{column name with value of interest to summarize (e.g. sum 24 | insured).} 25 | 26 | \item{lon}{column name with longitude (defaults to `lon`).} 27 | 28 | \item{lat}{column name with latitude (defaults to `lat`).} 29 | 30 | \item{lowerbound}{set lowerbound.} 31 | 32 | \item{radius}{radius (in meters) (default is 200m).} 33 | 34 | \item{grid_distance}{distance (in meters) for precision of concentration risk 35 | (default is 25m). `neighborhood_search()` can be used to search for 36 | coordinates with even higher concentrations in the neighborhood of the 37 | highest concentrations.} 38 | 39 | \item{gh_precision}{set precision for geohash.} 40 | 41 | \item{display_progress}{show progress bar (TRUE/FALSE). Defaults to TRUE.} 42 | } 43 | \value{ 44 | data.frame with coordinates (lon/lat) with the highest concentrations 45 | } 46 | \description{ 47 | Find the centre coordinates of a circle with a fixed radius that 48 | maximizes the coverage of total fire risk insured. `highest_concentration()` 49 | returns the coordinates (lon/lat) and the corresponding concentration. The 50 | concentration is defined as the sum of all observations within a circle of a 51 | certain radius. See \code{\link{concentration}} for determining concentration 52 | for pre-defined coordinates. 53 | } 54 | \details{ 55 | A recently European Commission regulation requires insurance 56 | companies to determine the maximum value of insured fire risk policies of 57 | all buildings that are partly or fully located within circle of a radius of 58 | 200m (Commission Delegated Regulation (EU), 2015, Article 132). The problem 59 | can be stated as: "find the centre coordinates of a circle with a fixed 60 | radius that maximizes the coverage of total fire risk insured". This can be 61 | viewed as a particular instance of the Maximal Covering Location Problem 62 | (MCLP) with fixed radius. See Gomes (2018) for a solution to the maximum fire 63 | risk insured capital problem using a multi-start local search meta-heuristic. 64 | The computational performance of \code{highest_concentration()} is 65 | investigated to overcome the long times the MCLP algorithm is taking. 66 | \code{highest_concentration()} is written in C++, and for 500,000 buildings 67 | it needs about 5-10 seconds to determine the maximum value of insured fire 68 | risk policies that are partly or fully located within circle of a radius of 69 | 200m. 70 | } 71 | \examples{ 72 | \dontrun{ 73 | # Find highest concentration with a precision of a grid of 25 meters 74 | hc1 <- highest_concentration(Groningen, amount, radius = 200, 75 | grid_distance = 25) 76 | 77 | # Look for coordinates with even higher concentrations in the 78 | # neighborhood of the coordinates with the highest concentration 79 | hc1_nghb <- neighborhood_gh_search(hc1, max.call = 7000) 80 | print(hc1_nghb) 81 | 82 | # Create map with geohashes above the lowerbound 83 | # The highest concentration lies in one of the geohashes 84 | plot(hc1) 85 | 86 | # Create map with highest concentration 87 | plot(hc1_nghb) 88 | } 89 | 90 | } 91 | \references{ 92 | Commission Delegated Regulation (EU) (2015). Solvency II 93 | Delegated Act 2015/35. Official Journal of the European Union, 58:124. 94 | 95 | Gomes M.I., Afonso L.B., Chibeles-Martins N., Fradinho J.M. 96 | (2018). Multi-start Local Search Procedure for the Maximum Fire Risk Insured 97 | Capital Problem. In: Lee J., Rinaldi G., Mahjoub A. (eds) Combinatorial 98 | Optimization. ISCO 2018. Lecture Notes in Computer Science, vol 10856. 99 | Springer, Cham. 100 | } 101 | \author{ 102 | Martin Haringa 103 | } 104 | -------------------------------------------------------------------------------- /man/insurance.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data_insurance.R 3 | \docType{data} 4 | \name{insurance} 5 | \alias{insurance} 6 | \title{Sum insured per postal code in the Netherlands} 7 | \format{ 8 | A data frame with 29,990 rows and 5 variables: 9 | \describe{ 10 | \item{postcode}{6-digit postal code} 11 | \item{population_pc4}{Population per 4-digit postal code} 12 | \item{amount}{Sum insured} 13 | \item{lon}{Longitude (in degrees) of the corresponding 6-digit postal code} 14 | \item{lat}{Latitude (in degrees) of the corresponding 6-digit postal code} 15 | } 16 | } 17 | \usage{ 18 | insurance 19 | } 20 | \description{ 21 | A dataset of postal codes with their sum insured, population 22 | and the corresponding spatial locations in terms of a latitude and a 23 | longitude. 24 | } 25 | \author{ 26 | Martin Haringa 27 | } 28 | \keyword{datasets} 29 | -------------------------------------------------------------------------------- /man/interpolate_spline.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/smooth_sphere.R 3 | \name{interpolate_spline} 4 | \alias{interpolate_spline} 5 | \title{Splines on the sphere} 6 | \usage{ 7 | interpolate_spline( 8 | observations, 9 | targets, 10 | value, 11 | lon_obs = lon, 12 | lat_obs = lat, 13 | lon_targets = lon, 14 | lat_targets = lat, 15 | k = 50 16 | ) 17 | } 18 | \arguments{ 19 | \item{observations}{data.frame of observations.} 20 | 21 | \item{targets}{data.frame of locations to calculate the interpolated and 22 | smoothed values for (target points).} 23 | 24 | \item{value}{Column with values in \code{observations}.} 25 | 26 | \item{lon_obs}{Column in \code{observations} with longitude (lon is default).} 27 | 28 | \item{lat_obs}{Column in \code{observations} with latitude (lat is default).} 29 | 30 | \item{lon_targets}{Column in \code{targets} with longitude (lon is default).} 31 | 32 | \item{lat_targets}{Column in \code{targets} with latitude (lat is default).} 33 | 34 | \item{k}{(default 50) is the basis dimension. For small data sets reduce 35 | \code{k} manually rather than using default.} 36 | } 37 | \value{ 38 | Object equal to object \code{targets} including an extra column 39 | with predicted values. 40 | } 41 | \description{ 42 | Spline interpolation and smoothing on the sphere. 43 | } 44 | \details{ 45 | \code{observations} should include at least columns for longitude 46 | and latitude. 47 | 48 | \code{targets} should include at least columns for longitude, 49 | latitude and value of interest to interpolate and smooth. 50 | 51 | A smooth of the general type discussed in Duchon (1977) is used: 52 | the sphere is embedded in a 3D Euclidean space, but smoothing employs a 53 | penalty based on second derivatives (so that locally as the smoothing 54 | parameter tends to zero we recover a "normal" thin plate spline on the 55 | tangent space). This is an unpublished suggestion of Jean Duchon. 56 | } 57 | \examples{ 58 | \dontrun{ 59 | target <- sf::st_drop_geometry(nl_postcode3) 60 | obs <- dplyr::sample_n(insurance, 1000) 61 | pop_df <- interpolate_spline(obs, target, population_pc4, k = 20) 62 | pop_sf <- dplyr::left_join(nl_postcode3, pop_df) 63 | choropleth(pop_sf, value = "population_pc4_pred", n = 13) 64 | } 65 | 66 | } 67 | \references{ 68 | \code{\link[mgcv:smooth.construct.sos.smooth.spec]{Splines on 69 | the sphere}} 70 | } 71 | \author{ 72 | Martin Haringa 73 | } 74 | -------------------------------------------------------------------------------- /man/knmi_historic_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data_knmi_historic.R 3 | \name{knmi_historic_data} 4 | \alias{knmi_historic_data} 5 | \title{Retrieve historic weather data for the Netherlands} 6 | \format{ 7 | The returned data frame contains the following columns: 8 | \itemize{ 9 | \item station = ID of measurement station; 10 | \item date = Date; 11 | \item FH = Hourly mean wind speed (in 0.1 m/s); 12 | \item FX = Maximum wind gust (in 0.1 m/s) during the hourly division; 13 | \item DR = Precipitation duration (in 0.1 hour) during the hourly division; 14 | \item RH = Hourly precipitation amount (in 0.1 mm) (-1 for <0.05 mm); 15 | \item city = City where the measurement station is located; 16 | \item lon = Longitude of station (crs = 4326); 17 | \item lat = Latitude of station (crs = 4326). 18 | } 19 | } 20 | \usage{ 21 | knmi_historic_data(startyear, endyear) 22 | } 23 | \arguments{ 24 | \item{startyear}{start year for historic weather data.} 25 | 26 | \item{endyear}{end year for historic weather data.} 27 | } 28 | \value{ 29 | Data frame containing weather data and meta data for weather station 30 | locations. 31 | } 32 | \description{ 33 | This function retrieves historic weather data collected by the official KNMI 34 | weather stations. See spatialrisk::knmi_stations for a list of the official 35 | KNMI weather stations. 36 | } 37 | \examples{ 38 | \dontrun{ 39 | knmi_historic_data(2015, 2019) 40 | } 41 | 42 | } 43 | \author{ 44 | Martin Haringa 45 | } 46 | -------------------------------------------------------------------------------- /man/knmi_stations.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data_nl_gemeente.R 3 | \docType{data} 4 | \name{knmi_stations} 5 | \alias{knmi_stations} 6 | \title{KNMI stations} 7 | \format{ 8 | A data frame with 50 rows and 7 variables: 9 | \describe{ 10 | \item{station}{ID of the station (209-391)} 11 | \item{city}{City where the station is located} 12 | \item{lon}{Longitude of station (crs = 4326)} 13 | \item{lat}{Latitude of the station (crs = 4326)} 14 | \item{altitude}{Altitude of the station (in meters)} 15 | \item{X}{X coordinate of the station (crs = 32631)} 16 | \item{Y}{Y coordinate of the station (crs = 32631)} 17 | } 18 | } 19 | \usage{ 20 | knmi_stations 21 | } 22 | \description{ 23 | A data frame containing the IDs and meta-data on the official 24 | KNMI weather stations. 25 | } 26 | \author{ 27 | Martin Haringa 28 | } 29 | \keyword{datasets} 30 | -------------------------------------------------------------------------------- /man/map_points_to_cells.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{map_points_to_cells} 4 | \alias{map_points_to_cells} 5 | \title{Map point coordinates to cell indices} 6 | \usage{ 7 | map_points_to_cells(pts, focal, lon, lat, crs_from, crs_to, r = NULL) 8 | } 9 | \arguments{ 10 | \item{pts}{data.frame with \code{lon} and \code{lat} columns in CRS 4326.} 11 | 12 | \item{focal}{focal (SpatRaster).} 13 | 14 | \item{lon}{character.} 15 | 16 | \item{lat}{character.} 17 | 18 | \item{crs_from}{crs from} 19 | 20 | \item{crs_to}{crs to} 21 | 22 | \item{r}{buffer around extent (in units of the crs).} 23 | } 24 | \description{ 25 | Map point coordinates to cell indices. 26 | } 27 | \author{ 28 | Martin Haringa 29 | } 30 | \keyword{internal} 31 | -------------------------------------------------------------------------------- /man/mw_create.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{mw_create} 4 | \alias{mw_create} 5 | \title{Create focal ("moving window") weight matrix} 6 | \usage{ 7 | mw_create(r, radius) 8 | } 9 | \arguments{ 10 | \item{r}{SpatRaster.} 11 | 12 | \item{radius}{radius of the circle (in units of the crs).} 13 | } 14 | \description{ 15 | Create a focal ("moving window") weight matrix for use in 16 | \code{terra::focal()}. 17 | } 18 | \details{ 19 | \code{mw_create()} is a modified version of 20 | \code{terra::focalMat()}. While \code{terra::focalMat()} creates a matrix 21 | where the border is the distance from the center of the focal cell, 22 | \code{mw_create()} creates a matrix where the border of the moving window 23 | is the distance from the edge of the focal cell. 24 | } 25 | \author{ 26 | Martin Haringa 27 | } 28 | \keyword{internal} 29 | -------------------------------------------------------------------------------- /man/neighborhood_gh_search.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/deprecated_highest_concentration.R 3 | \name{neighborhood_gh_search} 4 | \alias{neighborhood_gh_search} 5 | \title{Search for coordinates with higher concentrations within geohash} 6 | \usage{ 7 | neighborhood_gh_search( 8 | hc, 9 | highest_geohash = 1, 10 | max.call = 1000, 11 | verbose = TRUE, 12 | seed = 1 13 | ) 14 | } 15 | \arguments{ 16 | \item{hc}{object of class `concentration` obtained from 17 | `highest_concentration()`} 18 | 19 | \item{highest_geohash}{the number of geohashes the searching algorithm is 20 | applied to. Defaults to 1 (i.e. algorithm is only applied to the geohash 21 | with the highest concentration).} 22 | 23 | \item{max.call}{maximum number of calls to the concentration function (i.e. 24 | the number of coordinates in the neighborhood of the highest concentration). 25 | Defaults to 1000.} 26 | 27 | \item{verbose}{show messages from the algorithm (TRUE/FALSE). Defaults to 28 | FALSE.} 29 | 30 | \item{seed}{set seed} 31 | } 32 | \value{ 33 | data.frame 34 | } 35 | \description{ 36 | \code{\link{highest_concentration}} returns the highest concentration within 37 | a portfolio based on grid points. However, higher concentrations can be 38 | found within two grid points. `neighborhood_gh_search()` looks for even 39 | higher concentrations in the neighborhood of the grid points with the highest 40 | concentrations. This optimization is done by means of Simulated Annealing. 41 | } 42 | \examples{ 43 | \dontrun{ 44 | # Find highest concentration with a precision of a grid of 25 meters 45 | hc1 <- highest_concentration(Groningen, amount, radius = 200, 46 | grid_distance = 25) 47 | 48 | # Increase the number of calls for more extensive search 49 | hc1_nghb <- neighborhood_gh_search(hc1, max.call = 7000, highest_geohash = 1) 50 | hc2_nghb <- neighborhood_gh_search(hc1, max.call = 7000, highest_geohash = 2) 51 | plot(hc1_nghb) 52 | plot(hc2_nghb) 53 | } 54 | } 55 | \author{ 56 | Martin Haringa 57 | } 58 | -------------------------------------------------------------------------------- /man/nl_corop.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data_nl_gemeente.R 3 | \docType{data} 4 | \name{nl_corop} 5 | \alias{nl_corop} 6 | \title{Object of class \code{sf} for COROP regions in the Netherlands} 7 | \format{ 8 | A simple feature object with 40 rows and 5 variables: 9 | \describe{ 10 | \item{corop_nr}{corop number} 11 | \item{areaname}{corop name} 12 | \item{geometry}{geometry object of COROP region} 13 | \item{lon}{longitude of the corop centroid} 14 | \item{lat}{latitude of the corop centroid} 15 | } 16 | } 17 | \usage{ 18 | nl_corop 19 | } 20 | \description{ 21 | An object of class \code{sf} (simple feature) for COROP regions 22 | in the Netherlands. 23 | } 24 | \details{ 25 | A COROP region is a regional area within the Netherlands. These 26 | regions are used for analytical purposes by, among others, Statistics 27 | Netherlands. The Dutch abbreviation stands for Coordinatiecommissie Regionaal 28 | Onderzoeksprogramma, literally the Coordination Commission Regional Research 29 | Programme. 30 | } 31 | \author{ 32 | Martin Haringa 33 | } 34 | \keyword{datasets} 35 | -------------------------------------------------------------------------------- /man/nl_gemeente.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data_nl_gemeente.R 3 | \docType{data} 4 | \name{nl_gemeente} 5 | \alias{nl_gemeente} 6 | \title{Object of class \code{sf} for municipalities in the Netherlands} 7 | \format{ 8 | A simple feature object with 380 rows and 6 variables: 9 | \describe{ 10 | \item{id}{id of gemeente} 11 | \item{code}{code of gemeente} 12 | \item{areaname}{name of gemeente} 13 | \item{lon}{longitude of the gemeente centroid} 14 | \item{lat}{latitude of the gemeente centroid} 15 | \item{geometry}{geometry object of gemeente} 16 | } 17 | } 18 | \usage{ 19 | nl_gemeente 20 | } 21 | \description{ 22 | An object of class \code{sf} (simple feature) for municipalities 23 | (Dutch: gemeentes) in the Netherlands in the year 2021. 24 | } 25 | \author{ 26 | Martin Haringa 27 | } 28 | \keyword{datasets} 29 | -------------------------------------------------------------------------------- /man/nl_postcode2.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data_nl_gemeente.R 3 | \docType{data} 4 | \name{nl_postcode2} 5 | \alias{nl_postcode2} 6 | \title{Object of class \code{sf} for 2-digit postcode regions in the Netherlands} 7 | \format{ 8 | A simple feature object with 90 rows and 4 variables: 9 | \describe{ 10 | \item{areaname}{2-digit postal code} 11 | \item{geometry}{geometry object of postal code} 12 | \item{lon}{longitude of the 2-digit postal code centroid} 13 | \item{lat}{latitude of the 2-digit postal code centroid} 14 | } 15 | } 16 | \usage{ 17 | nl_postcode2 18 | } 19 | \description{ 20 | An object of class \code{sf} (simple feature) for 2-digit postal 21 | codes (Dutch: postcode) regions in the Netherlands. 22 | } 23 | \details{ 24 | Postal codes in the Netherlands, known as postcodes, are 25 | alphanumeric, consisting of four digits followed by two uppercase letters. 26 | The first two digits indicate a city and a region, the second two digits and 27 | the two letters indicate a range of house numbers, usually on the same 28 | street. 29 | } 30 | \author{ 31 | Martin Haringa 32 | } 33 | \keyword{datasets} 34 | -------------------------------------------------------------------------------- /man/nl_postcode3.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data_nl_gemeente.R 3 | \docType{data} 4 | \name{nl_postcode3} 5 | \alias{nl_postcode3} 6 | \title{Object of class \code{sf} for 3-digit postcode regions in the Netherlands} 7 | \format{ 8 | A simple feature object with 799 rows and 3 variables: 9 | \describe{ 10 | \item{areaname}{3-digit postal code} 11 | \item{geometry}{geometry object of postal code} 12 | \item{lon}{longitude of the 3-digit postal code centroid} 13 | \item{lat}{latitude of the 3-digit postal code centroid} 14 | } 15 | } 16 | \usage{ 17 | nl_postcode3 18 | } 19 | \description{ 20 | An object of class \code{sf} (simple feature) for 3-digit postal 21 | codes (Dutch: postcode) regions in the Netherlands. 22 | } 23 | \details{ 24 | Postal codes in the Netherlands, known as postcodes, are 25 | alphanumeric, consisting of four digits followed by two uppercase letters. 26 | The first two digits indicate a city and a region, the second two digits and 27 | the two letters indicate a range of house numbers, usually on the same 28 | street. 29 | } 30 | \author{ 31 | Martin Haringa 32 | } 33 | \keyword{datasets} 34 | -------------------------------------------------------------------------------- /man/nl_postcode4.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data_nl_gemeente.R 3 | \docType{data} 4 | \name{nl_postcode4} 5 | \alias{nl_postcode4} 6 | \title{Object of class \code{sf} for 4-digit postcode regions in the Netherlands} 7 | \format{ 8 | A simple feature object with 4053 rows and 7 variables: 9 | \describe{ 10 | \item{pc4}{4-digit postal code} 11 | \item{areaname}{name of corresponding 4-digit postal code} 12 | \item{city}{name of city} 13 | \item{biggest_20cities}{pc4 is in one of the following twenty (biggest) 14 | cities in the Netherlands: Amsterdam, Rotterdam, 's-Gravenhage, Utrecht, 15 | Eindhoven, Tilburg, Groningen, Almere, Breda, Nijmegen, Enschede, 16 | Apeldoorn, Haarlem, Amersfoort, Arnhem, 's-Hertogenbosch, Zoetermeer, 17 | Zwolle, Maastricht, Leiden.} 18 | \item{geometry}{geometry object of postal code} 19 | \item{lon}{longitude of the 4-digit postal code centroid} 20 | \item{lat}{latitude of the 4-digit postal code centroid} 21 | } 22 | } 23 | \usage{ 24 | nl_postcode4 25 | } 26 | \description{ 27 | An object of class \code{sf} (simple feature) for 4-digit postal 28 | codes (Dutch: postcode) regions in the Netherlands. 29 | } 30 | \details{ 31 | Postal codes in the Netherlands, known as postcodes, are 32 | alphanumeric, consisting of four digits followed by two uppercase letters. 33 | The first two digits indicate a city and a region, the second two digits and 34 | the two letters indicate a range of house numbers, usually on the same 35 | street. 36 | } 37 | \author{ 38 | Martin Haringa 39 | } 40 | \keyword{datasets} 41 | -------------------------------------------------------------------------------- /man/nl_provincie.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data_nl_gemeente.R 3 | \docType{data} 4 | \name{nl_provincie} 5 | \alias{nl_provincie} 6 | \title{Object of class \code{sf} for provinces in the Netherlands} 7 | \format{ 8 | A simple feature object with 12 rows and 4 variables: 9 | \describe{ 10 | \item{areaname}{province name} 11 | \item{geometry}{geometry object of province} 12 | \item{lon}{longitude of the province centroid} 13 | \item{lat}{latitude of the province centroid} 14 | } 15 | } 16 | \usage{ 17 | nl_provincie 18 | } 19 | \description{ 20 | An object of class \code{sf} (simple feature) for provinces 21 | (Dutch: provincies) in the Netherlands. 22 | } 23 | \author{ 24 | Martin Haringa 25 | } 26 | \keyword{datasets} 27 | -------------------------------------------------------------------------------- /man/plot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/deprecated_highest_concentration.R 3 | \name{plot.neighborhood} 4 | \alias{plot.neighborhood} 5 | \title{Automatically create a plot for objects obtained from 6 | neighborhood_gh_search()} 7 | \usage{ 8 | \method{plot}{neighborhood}( 9 | x, 10 | buffer = 0, 11 | legend_title = NULL, 12 | palette = "viridis", 13 | legend_position = "bottomleft", 14 | palette_circle = "YlOrRd", 15 | legend_position_circle = "bottomright", 16 | legend_title_circle = "Highest concentration", 17 | providers = c("CartoDB.Positron", "nlmaps.luchtfoto"), 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{x}{object neighborhood object produced by `neighborhood_gh_search()`} 23 | 24 | \item{buffer}{numeric value, show objects within buffer (in meters) from 25 | circle (defaults to 0)} 26 | 27 | \item{legend_title}{title of legend} 28 | 29 | \item{palette}{palette for points (defaults to "viridis")} 30 | 31 | \item{legend_position}{legend position for points legend (defaults to 32 | "bottomleft")} 33 | 34 | \item{palette_circle}{palette for circles (default to "YlOrRd")} 35 | 36 | \item{legend_position_circle}{legend position for circles legend (defaults 37 | to "bottomright")} 38 | 39 | \item{legend_title_circle}{title of legend for circles} 40 | 41 | \item{providers}{providers to show. See `leaflet::providers` for a list.} 42 | 43 | \item{...}{additional arguments affecting the interactive map produced} 44 | } 45 | \value{ 46 | Interactive view of highest concentration on map 47 | } 48 | \description{ 49 | Takes an object produced by `neighborhood_gh_search()`, and 50 | creates an interactive map. 51 | } 52 | \author{ 53 | Martin Haringa 54 | } 55 | -------------------------------------------------------------------------------- /man/plot.conc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/deprecated_highest_concentration.R 3 | \name{plot.conc} 4 | \alias{plot.conc} 5 | \title{Automatically create a plot for objects obtained from highest_concentration()} 6 | \usage{ 7 | \method{plot}{conc}( 8 | x, 9 | grid_points = TRUE, 10 | legend_title = NULL, 11 | palette = "viridis", 12 | legend_position = "bottomleft", 13 | providers = c("CartoDB.Positron", "nlmaps.luchtfoto"), 14 | ... 15 | ) 16 | } 17 | \arguments{ 18 | \item{x}{object of class `conc` obtained from 19 | `highest_concentration()`} 20 | 21 | \item{grid_points}{show grid points (TRUE), or objects (FALSE)} 22 | 23 | \item{legend_title}{title of legend} 24 | 25 | \item{palette}{palette for grid points (defaults to "viridis")} 26 | 27 | \item{legend_position}{legend position for grid points legend (defaults to 28 | "bottomleft")} 29 | 30 | \item{providers}{providers to show. See `leaflet::providers` for a list.} 31 | 32 | \item{...}{additional arguments affecting the interactive map produced} 33 | } 34 | \value{ 35 | Interactive view of geohashes with highest concentrations 36 | } 37 | \description{ 38 | Takes an object produced by `highest_concentration()`, 39 | and creates an interactive map. 40 | } 41 | \author{ 42 | Martin Haringa 43 | } 44 | -------------------------------------------------------------------------------- /man/plot.concentration.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/highest_concentration_terra.R 3 | \name{plot.concentration} 4 | \alias{plot.concentration} 5 | \title{Automatically create a plot for objects obtained from 6 | \code{find_highest_concentration()}} 7 | \usage{ 8 | \method{plot}{concentration}( 9 | x, 10 | type = c("concentration", "focal", "rasterized", "updated_focal"), 11 | color1 = NULL, 12 | max.rad = 20, 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{x}{x object of class \code{concentration} obtained from 18 | \code{highest_concentration()}} 19 | 20 | \item{type}{is one of "concentration" (default), "rasterized", "focal", 21 | "updated_focal". See details for more information.} 22 | 23 | \item{color1}{color when one concentration is plotted (default is "#4B0055").} 24 | 25 | \item{max.rad}{maximal radius for size of circles in plot (default is 20).} 26 | 27 | \item{...}{additional arguments.} 28 | } 29 | \description{ 30 | Automatically create a plot for objects obtained from 31 | \code{find_highest_concentration()}. 32 | } 33 | \details{ 34 | More info for type: 35 | \enumerate{ 36 | \item "concentration": this is.. 37 | \item "focal": this is.. 38 | \item "rasterized": this is.. 39 | \item "updated_focal": this is.. 40 | } 41 | } 42 | \examples{ 43 | x <- find_highest_concentration(Groningen, "amount") 44 | plot(x, "concentration") 45 | plot(x, "rasterized") 46 | plot(x, "focal") 47 | plot(x, "updated_focal") 48 | 49 | } 50 | \author{ 51 | Martin Haringa 52 | } 53 | -------------------------------------------------------------------------------- /man/plot_points.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/map_plot_points.R 3 | \name{plot_points} 4 | \alias{plot_points} 5 | \title{Create map with points} 6 | \usage{ 7 | plot_points(df, value, lon = "lon", lat = "lat", crs = 4326, at = NULL) 8 | } 9 | \arguments{ 10 | \item{df}{data.frame containing columns for longitude and latitude.} 11 | 12 | \item{value}{column in \code{df} to be visualized.} 13 | 14 | \item{lon}{column in \code{df} containing longitude values.} 15 | 16 | \item{lat}{column in \code{df} containing latitude values.} 17 | 18 | \item{crs}{crs code for the coordinate reference system (default is 4326).} 19 | 20 | \item{at}{the breakpoints used for visualisation.} 21 | } 22 | \description{ 23 | Create map for a data.frame containing points. 24 | } 25 | \examples{ 26 | \dontrun{ 27 | plot_points(Groningen, value = "amount") 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /man/points_in_circle.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/points_in_circle.R 3 | \name{points_in_circle} 4 | \alias{points_in_circle} 5 | \title{Filter observations within circle} 6 | \usage{ 7 | points_in_circle( 8 | data, 9 | lon_center, 10 | lat_center, 11 | lon = lon, 12 | lat = lat, 13 | radius = 200 14 | ) 15 | } 16 | \arguments{ 17 | \item{data}{data.frame with at least columns for longitude and latitude.} 18 | 19 | \item{lon_center}{numeric. Representing the longitude of the circle's center.} 20 | 21 | \item{lat_center}{numeric. Representing the latitude of the circle's center.} 22 | 23 | \item{lon}{column name in \code{data} containing longitudes 24 | (default is \code{lon}).} 25 | 26 | \item{lat}{column name in \code{data} containing latitudes 27 | (default is \code{lat}).} 28 | 29 | \item{radius}{radius of the circle in meters (default is 200m).} 30 | } 31 | \value{ 32 | A subset of the input data.frame containing only the observations 33 | that fall within the specified circle. 34 | } 35 | \description{ 36 | Filter all observations in a data.frame that fall within a 37 | circle of a specified radius drawn around a given latitude and longitude 38 | point. 39 | } 40 | \examples{ 41 | points_in_circle(Groningen, lon_center = 6.571561, lat_center = 53.21326, 42 | radius = 60) 43 | 44 | } 45 | \author{ 46 | Martin Haringa 47 | } 48 | -------------------------------------------------------------------------------- /man/points_in_circle_vec.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/points_in_circle.R 3 | \name{points_in_circle_vec} 4 | \alias{points_in_circle_vec} 5 | \title{Filter observations within circle (vectorized)} 6 | \usage{ 7 | points_in_circle_vec( 8 | data, 9 | lon_center, 10 | lat_center, 11 | lon = lon, 12 | lat = lat, 13 | radius = 200 14 | ) 15 | } 16 | \arguments{ 17 | \item{data}{data.frame with at least columns for longitude and latitude.} 18 | 19 | \item{lon_center}{numeric. Representing the longitude of the circle's center.} 20 | 21 | \item{lat_center}{numeric. Representing the latitude of the circle's center.} 22 | 23 | \item{lon}{column name in \code{data} containing longitudes 24 | (default is \code{lon}).} 25 | 26 | \item{lat}{column name in \code{data} containing latitudes 27 | (default is \code{lat}).} 28 | 29 | \item{radius}{radius of the circle in meters (default is 200m).} 30 | } 31 | \value{ 32 | A subset of the input data.frame containing only the observations 33 | that fall within the specified circle. 34 | } 35 | \description{ 36 | Filter all observations in a data.frame that fall within a 37 | circle of a specified radius drawn around a given latitude and longitude 38 | point. 39 | } 40 | \examples{ 41 | points_in_circle_vec(Groningen, lon_center = c(6.571561, 6.56561), 42 | lat_center = c(53.21326, 53.20326), radius = 60) 43 | 44 | } 45 | \author{ 46 | Martin Haringa 47 | } 48 | -------------------------------------------------------------------------------- /man/points_to_polygon.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/points_to_polygon.R 3 | \name{points_to_polygon} 4 | \alias{points_to_polygon} 5 | \title{Map points to polygons} 6 | \usage{ 7 | points_to_polygon(sf_map, df, oper, crs = 4326, outside_print = FALSE) 8 | } 9 | \arguments{ 10 | \item{sf_map}{object of class sf representing the polygon geometries.} 11 | 12 | \item{df}{data.frame containing coordinates (column names should be 'lon' 13 | and 'lat')} 14 | 15 | \item{oper}{arithmetic operation to be applied on the polygon level.} 16 | 17 | \item{crs}{coordinate reference system (default is 4326).} 18 | 19 | \item{outside_print}{logical indicating whether to print points that are 20 | not within a polygon (default is FALSE).} 21 | } 22 | \value{ 23 | An object of class \code{sf} 24 | } 25 | \description{ 26 | Join a data.frame containing coordinates (longitude and 27 | latitude) to polygon geometries. Arithmetic operations are then applied to 28 | the attributes of the joined coordinates to obtain aggregated values 29 | for each polygon. 30 | } 31 | \examples{ 32 | points_to_polygon(nl_postcode2, insurance, sum(amount, na.rm = TRUE)) 33 | \dontrun{ 34 | shp_read <- sf::st_read("~/path/to/file.shp") 35 | points_to_polygon(shp_read, insurance, sum(amount, na.rm = TRUE)) 36 | } 37 | 38 | } 39 | \author{ 40 | Martin Haringa 41 | } 42 | -------------------------------------------------------------------------------- /man/top_n_focals.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{top_n_focals} 4 | \alias{top_n_focals} 5 | \title{Identify the focal indices with the highest values} 6 | \usage{ 7 | top_n_focals(focal, n) 8 | } 9 | \arguments{ 10 | \item{focal}{focal as output from \code{terra::focal()}.} 11 | 12 | \item{n}{positive integer value greater or equal to 1.} 13 | } 14 | \description{ 15 | Generate a data.frame containing the cell indices of the focal 16 | cells with the \code{n} highest values. Additionally, include columns for 17 | the coordinates \code{(xy)} corresponding to the center of each cell. 18 | } 19 | \author{ 20 | Martin Haringa 21 | } 22 | \keyword{internal} 23 | -------------------------------------------------------------------------------- /man/update_db.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{update_db} 4 | \alias{update_db} 5 | \title{Save highest concentrations per cell for subsequent iterations} 6 | \usage{ 7 | update_db(hf_conc_new, db, cells) 8 | } 9 | \arguments{ 10 | \item{hf_conc_new}{highest concentrations from the current iteration, 11 | obtained from \code{conc_per_cell_new()}.} 12 | 13 | \item{db}{data.frame containing previously saved highest concentrations.} 14 | 15 | \item{cells}{cells containing points associated with the current highest 16 | concentration to be removed from \code{db}.} 17 | } 18 | \description{ 19 | Save highest concentrations per cell for subsequent iterations. 20 | } 21 | \author{ 22 | Martin Haringa 23 | } 24 | \keyword{internal} 25 | -------------------------------------------------------------------------------- /man/update_focal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{update_focal} 4 | \alias{update_focal} 5 | \title{Update current focal for the next iteration} 6 | \usage{ 7 | update_focal(old_focal, new_rasterized, extent, mw) 8 | } 9 | \arguments{ 10 | \item{old_focal}{Focal obtained from \code{terra::focal()} for the current 11 | iteration.} 12 | 13 | \item{new_rasterized}{Output obtained from \code{update_rasterize()} 14 | for the next iteration.} 15 | 16 | \item{extent}{Extent of the cells corresponding to the coordinates with the 17 | highest concentration for the current iteration. Extent is output from 18 | \code{terra::ext()}.} 19 | 20 | \item{mw}{Moving window obtained from \code{create_mw()}.} 21 | } 22 | \description{ 23 | Update current focal for the next iteration. 24 | } 25 | \details{ 26 | Spatial extent refers to the geographic area covered by a spatial 27 | dataset. It defines the boundaries in terms of its geographic coordinates 28 | (north, east, south, west). 29 | 30 | An focal is updated by the following steps: 31 | \enumerate{ 32 | \item The extent of the cells corresponding to 33 | the coordinates with the highest concentration (xmin, xmax, ymin, ymax) 34 | is determined. 35 | \item A buffer of size two times the radius plus the 36 | cell size around this extent. All cells within this new extent will impact 37 | the focal values. 38 | \item Subset (crop) the rasterized data to include only the cells 39 | within this new extent. Perform focal calculations only for these new 40 | cells. 41 | \item As the focal values of the cells near the borders may be 42 | inflated, crop the result again to include only the cells within a radius 43 | of the original extent. 44 | \item Merge this updated focal with the previous focal object. 45 | } 46 | } 47 | \author{ 48 | Martin Haringa 49 | } 50 | \keyword{internal} 51 | -------------------------------------------------------------------------------- /man/update_rasterize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{update_rasterize} 4 | \alias{update_rasterize} 5 | \title{Update current rasterize for the next iteration} 6 | \usage{ 7 | update_rasterize(old_rasterized, extent, new_spatvector, col) 8 | } 9 | \arguments{ 10 | \item{old_rasterized}{SpatRaster used in the current iteration.} 11 | 12 | \item{extent}{Extent of the cells corresponding to the coordinates with the 13 | highest concentration for the current iteration.Extent is output from 14 | terra::ext().} 15 | 16 | \item{new_spatvector}{Updated SpatVector for next iteration.} 17 | 18 | \item{col}{Character. Variable name in \code{new_spatvector}.} 19 | } 20 | \description{ 21 | Update current rasterize for the next iteration. 22 | } 23 | \details{ 24 | Spatial extent refers to the geographic area covered by a spatial 25 | dataset. It defines the boundaries in terms of its geographic coordinates 26 | (north, east, south, west). 27 | } 28 | \author{ 29 | Martin Haringa 30 | } 31 | \keyword{internal} 32 | -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/pkgdown/favicon/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/pkgdown/favicon/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/pkgdown/favicon/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/pkgdown/favicon/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/pkgdown/favicon/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /spatialrisk.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.so 3 | *.dll 4 | -------------------------------------------------------------------------------- /src/RcppExports.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/src/RcppExports.o -------------------------------------------------------------------------------- /src/haversine_cpp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/src/haversine_cpp.o -------------------------------------------------------------------------------- /src/spatialrisk.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MHaringa/spatialrisk/be18c236b6b66e0be0f7ebe603c924ff7642343c/src/spatialrisk.so -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(spatialrisk) 3 | 4 | test_check("spatialrisk") 5 | -------------------------------------------------------------------------------- /tests/testthat/test_concentration.R: -------------------------------------------------------------------------------- 1 | library(spatialrisk) 2 | context("concentration") 3 | 4 | test_that("value is equal to concentration for small radius", { 5 | conc <- concentration(Groningen[1, ], Groningen, value = amount, 6 | radius = 0.00001, display_progress = FALSE) 7 | expect_equal(conc$amount, conc$concentration) 8 | }) 9 | 10 | test_that("sum of value column obtained from points_in_circle fn is equal to 11 | concentration", { 12 | 13 | # Check first observation 14 | uit1 <- concentration(Groningen[1, ], Groningen, value = amount, 15 | radius = 200, 16 | display_progress = FALSE) 17 | sum1 <- points_in_circle(Groningen, lon_center = uit1$lon, 18 | lat_center = uit1$lat, radius = 200)$amount 19 | expect_equal(uit1$concentration, sum(sum1)) 20 | 21 | # Check second observation 22 | uit2 <- concentration(Groningen[2, ], Groningen, value = amount, 23 | radius = 200, 24 | display_progress = FALSE) 25 | sum2 <- points_in_circle(Groningen, lon_center = uit2$lon, 26 | lat_center = uit2$lat, radius = 200)$amount 27 | expect_equal(uit2$concentration, sum(sum2)) 28 | 29 | # Check last observation 30 | uit3 <- concentration(Groningen[nrow(Groningen), ], Groningen, 31 | value = amount, 32 | radius = 200, display_progress = FALSE) 33 | sum3 <- points_in_circle(Groningen, lon_center = uit3$lon, 34 | lat_center = uit3$lat, radius = 200)$amount 35 | expect_equal(uit3$concentration, sum(sum3)) 36 | }) 37 | 38 | test_that("error should be returned for nonpositive radius", { 39 | expect_error(concentration(Groningen[2, ], Groningen, value = amount, 40 | radius = -1, display_progress = FALSE)) 41 | }) 42 | 43 | 44 | test_that("lon and lat are same for input and output", { 45 | indf1 <- Groningen[1, ] 46 | outdf1 <- concentration(Groningen[1:3, ], Groningen, value = amount, 47 | display_progress = FALSE)[1, ] 48 | expect_equal(indf1$lon, outdf1$lon) 49 | expect_equal(indf1$lat, outdf1$lat) 50 | }) 51 | -------------------------------------------------------------------------------- /tests/testthat/test_haversine.R: -------------------------------------------------------------------------------- 1 | library(spatialrisk) 2 | context("haversine") 3 | 4 | 5 | test_that("return correct output", { 6 | uit <- haversine(52, 6, 53, 7) 7 | expect_equal(round(uit, 0), round(130321.2, 0)) 8 | }) 9 | 10 | test_that("return NA for missing coordinates", { 11 | uit <- haversine(c(52, 51), c(6, 6.1), c(53, 51), c(NA, 6)) 12 | expect_equal(sum(is.na(uit)), 1) 13 | }) 14 | -------------------------------------------------------------------------------- /tests/testthat/test_pointsincircle.R: -------------------------------------------------------------------------------- 1 | library(spatialrisk) 2 | context("points_in_circle") 3 | 4 | test_that("distance in output from points in circle is equal to distance from 5 | haversine", { 6 | 7 | # Check first observation 8 | uit <- points_in_circle(Groningen, 6.52, 53.24) 9 | expect_equal(uit[1, ]$distance_m, haversine(53.24, 6.52, 10 | uit[1, ]$lat, 11 | uit[1, ]$lon)) 12 | 13 | # Check second observation 14 | expect_equal(uit[2, ]$distance_m, haversine(53.24, 6.52, 15 | uit[2, ]$lat, 16 | uit[2, ]$lon)) 17 | }) 18 | 19 | test_that("lon and lat are same for input and output", { 20 | 21 | # Check first observation 22 | indf1 <- Groningen[1, ] 23 | outdf1 <- points_in_circle(Groningen, indf1$lon, indf1$lat)[1, ] 24 | expect_equal(indf1$lon, outdf1$lon) 25 | expect_equal(indf1$lat, outdf1$lat) 26 | 27 | }) 28 | --------------------------------------------------------------------------------