{"id":39892569,"url":"https://github.com/giacfalk/locationallocation","last_synced_at":"2026-01-18T14:44:16.822Z","repository":{"id":282242778,"uuid":"933262267","full_name":"giacfalk/locationallocation","owner":"giacfalk","description":"locationallocation: an R package to solve Maximal Coverage Location-Allocation problems using geospatial data","archived":false,"fork":false,"pushed_at":"2026-01-13T15:36:42.000Z","size":15429,"stargazers_count":3,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-13T18:03:07.271Z","etag":null,"topics":["accessibility-analysis","geospatial-analysis","location-allocation","mcla-problem","r","spatial-accessibility","travel-time"],"latest_commit_sha":null,"homepage":"https://giacfalk.github.io/locationallocation/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/giacfalk.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json","zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-15T14:44:41.000Z","updated_at":"2026-01-13T15:34:17.000Z","dependencies_parsed_at":"2025-08-04T17:18:35.670Z","dependency_job_id":"215feb7f-1409-43b5-a957-4d4d43d4695a","html_url":"https://github.com/giacfalk/locationallocation","commit_stats":null,"previous_names":["giacfalk/locationallocation"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/giacfalk/locationallocation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacfalk%2Flocationallocation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacfalk%2Flocationallocation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacfalk%2Flocationallocation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacfalk%2Flocationallocation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giacfalk","download_url":"https://codeload.github.com/giacfalk/locationallocation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacfalk%2Flocationallocation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28538313,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T13:04:05.990Z","status":"ssl_error","status_checked_at":"2026-01-18T13:01:44.092Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accessibility-analysis","geospatial-analysis","location-allocation","mcla-problem","r","spatial-accessibility","travel-time"],"created_at":"2026-01-18T14:44:16.040Z","updated_at":"2026-01-18T14:44:16.802Z","avatar_url":"https://github.com/giacfalk.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# locationallocation \u003ca href = \"https://giacfalk.github.io/locationallocation/\"\u003e\u003cimg src = \"man/figures/logo.png\" align=\"right\" width=\"120\" /\u003e\u003c/a\u003e\n\n\u003c!-- quarto render --\u003e\n\n\u003c!-- Install the package before rendering this file: `devtools::install()` --\u003e\n\n\u003c!-- badges: start --\u003e\n[![Project Status: Active - The project has reached a stable, usable\nstate and is being actively\ndeveloped.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![](https://img.shields.io/badge/doi-10.31223/X5XQ69-1284C5.svg)](https://doi.org/10.31223/X5XQ69)\n[![R build\nstatus](https://github.com/giacfalk/locationallocation/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/giacfalk/locationallocation/actions)\n[![License:\nGPLv3](https://img.shields.io/badge/license-GPLv3-bd0000.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![Contributor Covenant 3.0 Code of\nConduct](https://img.shields.io/badge/Contributor%20Covenant-3.0-4baaaa.svg)](https://www.contributor-covenant.org/version/3/0/code_of_conduct/)\n\u003c!-- badges: end --\u003e\n\n## Overview\n\nAssessing and planning infrastructure and service networks, given a\ndispersed demand, limited capacity, accessibility targets, and concerns\nabout spatial justice, is a central policy challenge. Problems of this\ntype are commonly referred to as *Maximal Coverage Location-Allocation*\n(MCLA) spatial optimization problems.\n\n`locationallocation` is an R package that provides tools for solving\nMCLA problems with geospatial data. It builds on widely used spatial\nlibraries in R, follows [tidyverse\nprinciples](https://tidyverse.tidyverse.org/articles/manifesto.html),\nand integrates seamlessly with the broader [tidyverse\necosystem](https://tidyverse.org/). The package can generate travel-time\nmaps and optimize the placement of facilities or infrastructure\naccording to accessibility criteria, which can be weighted by one or\nmore variables or by a user-defined function.\n\nPotential applications of the package extend to the domains of public\ninfrastructure assessment and planning (public services provision,\ne.g. transport, social services, healthcare, parks), urban environmental\nand climate risk reduction interventions, logistics and hubs allocation,\ncommercial and strategic decisions.\n\n\u003e If you find this project useful, please consider giving it a star!  \n\u003e [![GitHub Repository\n\u003e Stars](https://img.shields.io/github/stars/giacfalk/locationallocation)](https://github.com/giacfalk/locationallocation/)\n\n## Installation\n\nYou can install `locationallocation` using the\n[`remotes`](https://github.com/r-lib/remotes) package:\n\n``` r\n# install.packages(remotes)\nremotes::install_github(\"giacfalk/locationallocation\")\n```\n\nA [CRAN](https://cran.r-project.org/) version of the package is planned\nfor the near future.\n\n## Usage\n\nTo use the package, start by loading it to your R session using the\n`library` function:\n\n``` r\nlibrary(locationallocation)\n```\n\nAs an example, we demonstrate how the package can address urban-scale\nclimate risk through infrastructure assessment and geospatial planning.\nFor this demonstration, we use the demo datasets included with the\npackage.\n\nThese datasets include the coordinates of public drinking water\nfountains (blue dots) in Naples, Italy\n([`naples_fountains`](https://giacfalk.github.io/locationallocation/reference/naples_fountains.html));\na gridded population raster from the Global Human Settlement Layer\n([GHSL](https://human-settlement.emergency.copernicus.eu)) Population\nGrid\n([GHS-POP](https://human-settlement.emergency.copernicus.eu/download.php?ds=pop))\n([`naples_population`](https://giacfalk.github.io/locationallocation/reference/naples_population.html));\na 100-meter resolution heat hazard map, representing the number of days\nwith [Wet-Bulb Globe\nTemperature](https://en.wikipedia.org/wiki/Wet-bulb_globe_temperature)\nabove 25°C during 2008–2017, obtained from the\n[UrbClim](https://www.urban-climate.eu/model) model\n([`naples_hot_days`](https://giacfalk.github.io/locationallocation/reference/naples_hot_days.html));\nand the city’s administrative boundaries\n([`naples_shape`](https://giacfalk.github.io/locationallocation/reference/naples_shape.html)).\n\n![](man/figures/existing-facilities-1.png)\n\nWe can use the\n[`traveltime()`](https://giacfalk.github.io/locationallocation/reference/traveltime.html)\nfunction to create a map of current accessibility to the facility points\n(represented by the [`sf`](https://r-spatial.github.io/sf/) object\n[`naples_fountains`](https://giacfalk.github.io/locationallocation/reference/naples_fountains.html))\nwithin the specified geographical boundaries. The function allows the\nuser to select a travel mode (walking or fastest route) and an output\nspatial resolution in meters, achieved through [dissevering spatial\ndownscaling techniques](https://doi.org/10.1016/j.cageo.2011.08.021).\n\n``` r\ntraveltime_data \u003c-\n  naples_fountains |\u003e\n  traveltime(\n    bb_area = naples_shape,\n    dowscaling_model_type = \"lm\",\n    mode = \"walk\",\n    res_output = 100\n  )\n```\n\nOnce\n[`traveltime()`](https://giacfalk.github.io/locationallocation/reference/traveltime.html)\nhas completed, the resulting layer can be visualized using the\n[`traveltime_plot()`](https://giacfalk.github.io/locationallocation/reference/traveltime_plot.html)\nfunction.\n\n``` r\ntraveltime_data |\u003e\n  traveltime_plot(\n    bb_area = naples_shape,\n    facilities = naples_fountains,\n    contour_traveltime = 15\n  )\n```\n\n![](man/figures/traveltime-plot-1.png)\n\nWe can also generate a summary plot and compute statistics using the\noutput of the\n[`traveltime()`](https://giacfalk.github.io/locationallocation/reference/traveltime.html)\nfunction, together with a demand raster (e.g., population density) and a\nspecified time threshold, using the\n[`traveltime_stats`](https://giacfalk.github.io/locationallocation/reference/traveltime_stats.html)\nfunction:\n\n``` r\ntraveltime_data |\u003e\n  traveltime_stats(\n    demand = naples_population,\n    breaks = c(5, 10, 15, 30),\n    objectiveminutes = 15\n  )\n#\u003e ℹ 85.45148% of coverage within the 15 minutes threshold.\n```\n\n![](man/figures/traveltime-stats-1.png)\n\nWe can now use the\n[`allocation()`](https://giacfalk.github.io/locationallocation/reference/allocation.html)\nfunction to optimize the placement of new water fountains, ensuring that\n(virtually) everyone (i.e., the full extent of the raster layer\nspecified by the `demand` parameter) can reach one within 15 minutes, as\ndefined by the `objectiveminutes` parameter:\n\n``` r\nallocation_data \u003c-\n  naples_population |\u003e\n  allocation(\n    bb_area = naples_shape,\n    facilities = naples_fountains,\n    traveltime = traveltime_data,\n    weights = NULL,\n    objectiveminutes = 15,\n    objectiveshare = 0.99,\n    heur = \"max\",\n    approach = \"norm\",\n    exp_demand = 1,\n    exp_weights = 1\n  )\n```\n\n    #\u003e ✔ Target coverage share of 99% attained with 28 facilities within the 15\n    #\u003e minutes threshold. The achieved coverage share is 99.03953%.\n\n``` r\nallocation_data |\u003e allocation_plot(naples_shape)\n```\n\n![](man/figures/allocation-plot-1-1.png)\n\nNote that it is also possible to solve an allocation problem using the\n`weights` parameter, which assigns greater relative importance or\npriority to areas where demand overlaps with weighting factors defined\nby another raster layer, such as exposure to hot days, as shown in the\nfollowing example:\n\n``` r\nallocation_data \u003c-\n  naples_population |\u003e\n  allocation(\n    bb_area = naples_shape,\n    facilities = naples_fountains,\n    traveltime = traveltime_data,\n    weights = naples_hot_days, # \u003c--- Changed\n    objectiveminutes = 15,\n    objectiveshare = 0.99,\n    heur = \"max\",\n    approach = \"norm\",\n    exp_demand = 1,\n    exp_weights = 1\n  )\n```\n\n    #\u003e ✔ Target coverage share of 99% attained with 25 facilities within the 15\n    #\u003e minutes threshold. The achieved coverage share is 99.16903%.\n\n``` r\nallocation_data |\u003e allocation_plot(naples_shape)\n```\n\n![](man/figures/allocation-plot-2-1.png)\n\nIt is also possible to apply normalization and exponentiation to\ndifferent demand and weighting layers, enhancing their relative\ninfluence on the allocation, using the `approach`, `exp_demand`, and\n`exp_weights` parameters (see the [function\ndocumentation](https://giacfalk.github.io/locationallocation/reference/allocation.html)\nfor details):\n\n``` r\nallocation_data \u003c-\n  naples_population |\u003e\n  allocation(\n    bb_area = naples_shape,\n    facilities = naples_fountains,\n    traveltime = traveltime_data,\n    weights = naples_hot_days,\n    objectiveminutes = 15,\n    objectiveshare = 0.99,\n    heur = \"max\",\n    approach = \"norm\",\n    exp_demand = 2, # \u003c--- Changed\n    exp_weights = 1\n  )\n```\n\n    #\u003e ✔ Target coverage share of 99% attained with 9 facilities within the 15\n    #\u003e minutes threshold. The achieved coverage share is 99.15597%.\n\n``` r\nallocation_data |\u003e allocation_plot(naples_shape)\n```\n\n![](man/figures/allocation-plot-3-1.png)\n\nA variant of the allocation problem arises when the set of candidate\nlocations for new facilities is **discrete**, rather than **continuous**\nacross the study area as in the previous example.\n\nIn this case, the user must provide a set of candidate points via the\n`candidate` parameter of the\n[`allocation_discrete()`](https://giacfalk.github.io/locationallocation/reference/allocation_discrete.html)\nfunction, along with the maximum number of facilities that can be\nselected (`n_fac` parameter). The function applies a quasi-optimality\nheuristic based on a randomization approach, where the number of\nreplications (`n_samples` parameter) gradually approaches the global\noptimum, although computational time increases linearly. As with the\ncontinuous allocation problem, a weight layer and normalization and\nexponentiation parameters can also be specified.\n\n``` r\nlibrary(sf)\n\nallocation_data \u003c-\n  naples_population |\u003e\n  allocation_discrete(\n    bb_area = naples_shape,\n    candidate = naples_shape |\u003e st_sample(20),\n    facilities = naples_fountains,\n    n_fac = 5,\n    n_samples = 100,\n    traveltime = traveltime_data,\n    weights = NULL,\n    objectiveminutes = 15,\n    objectiveshare = NULL,\n    approach = \"norm\",\n    exp_demand = 1,\n    exp_weights = 1,\n    par = FALSE\n  )\n```\n\n    #\u003e ℹ 5 facilities allocated within the 15 minutes threshold. The maximum\n    #\u003e coverage share attained was 88.76062%.\n\n``` r\nallocation_data |\u003e allocation_plot(naples_shape)\n```\n\n![](man/figures/allocation-plot-4-1.png)\n\nNow consider a scenario where the user wants to choose up to `n_fac`\nfacilities to meet a target `objectiveshare` of the total demand,\nassuming that level of coverage is actually attainable.\n\n``` r\nlibrary(sf)\n\nallocation_data \u003c-\n  naples_population |\u003e\n  allocation_discrete(\n    bb_area = naples_shape,\n    candidate = naples_shape |\u003e st_sample(20),\n    facilities = naples_fountains,\n    n_fac = 5,\n    n_samples = 100,\n    traveltime = traveltime_data,\n    weights = NULL,\n    objectiveminutes = 15,\n    objectiveshare = 0.9,\n    approach = \"norm\",\n    exp_demand = 1,\n    exp_weights = 1,\n    par = FALSE\n  )\n```\n\n    #\u003e ✔ Target coverage share of 90% attained with 2 facilities within the 15\n    #\u003e minutes threshold. The achieved coverage share is 90.20134%.\n\n``` r\nallocation_data |\u003e allocation_plot(naples_shape)\n```\n\n![](man/figures/allocation-plot-5-1.png)\n\nFinally, consider a case with no preexisting facilities. The discrete\nlocation-allocation problem must then identify where to place new\nfacilities to cover as much demand as possible, given the limited set of\nspatial options and the cap on how many facilities can be allocated.\n\n``` r\nlibrary(sf)\n\nallocation_data \u003c-\n  naples_population |\u003e\n  allocation_discrete(\n    bb_area = naples_shape,\n    candidate = naples_shape |\u003e st_sample(20),\n    facilities = NULL,\n    n_fac = 5,\n    n_samples = 100,\n    traveltime = NULL,\n    weights = NULL,\n    objectiveminutes = 15,\n    objectiveshare = 0.45,\n    approach = \"norm\",\n    exp_demand = 1,\n    exp_weights = 1,\n    par = FALSE\n  )\n```\n\n    #\u003e ✔ Target coverage share of 45% attained with 2 facilities within the 15\n    #\u003e minutes threshold. The achieved coverage share is 46.40227%.\n\n``` r\nallocation_data |\u003e allocation_plot(naples_shape)\n```\n\n![](man/figures/allocation-plot-6-1.png)\n\n## Citation\n\nIf you use this package in your research, please cite it to acknowledge\nthe effort put into its development and maintenance. Your citation helps\nsupport its continued improvement.\n\n``` r\ncitation(\"locationallocation\")\n#\u003e To cite locationallocation in publications use:\n#\u003e \n#\u003e   Falchetta, G. (2025). locationallocation: Solving Maximal Coverage\n#\u003e   Location-Allocation geospatial infrastructure assessment and\n#\u003e   planning problems [Preprint, manuscript submitted for\n#\u003e   publication]. EarthArXiv. https://doi.org/10.31223/X5XQ69\n#\u003e \n#\u003e \n#\u003e @misc{falchetta_locationallocation_2025,\n#\u003e   author       = {Falchetta, Giacomo and Vartanian, Daniel},\n#\u003e   title        = {locationallocation: an R package to solve Maximal Coverage Location-Allocation problems},\n#\u003e   year         = {2025},\n#\u003e   howpublished = {\\url{https://github.com/giacfalk/locationallocation}},\n#\u003e   note         = {GitHub repository},\n#\u003e }\n```\n\n## License\n\n[![](https://img.shields.io/badge/license-GPLv3-bd0000.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\n``` text\nCopyright (C) 2025 Giacomo Falchetta, Daniel Vartanian\n\nlocationallocation is free software: you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any\nlater version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\nPARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with\nthis program. If not, see \u003chttps://www.gnu.org/licenses/\u003e.\n```\n\n## Contributing\n\n[![](https://img.shields.io/badge/Contributor%20Covenant-3.0-4baaaa.svg)](https://www.contributor-covenant.org/version/3/0/code_of_conduct/)\n\nContributions are welcome! Whether you want to report bugs, suggest\nfeatures, or improve the code or documentation, your input is highly\nvalued. Please check the [issues\ntab](https://github.com/giacfalk/locationallocation/issues) for existing\nissues or to open a new one.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiacfalk%2Flocationallocation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiacfalk%2Flocationallocation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiacfalk%2Flocationallocation/lists"}