{"id":60433,"name":"greenR","description":"An R package that enables the quantification, analysis, and visualization of urban greenness within city networks.","url":"https://github.com/sachit27/greenR","last_synced_at":"2026-06-22T18:30:25.177Z","repository":{"id":185547757,"uuid":"670069261","full_name":"sachit27/greenR","owner":"sachit27","description":"greenR is an R package that enables the quantification, analysis, and visualization of urban greenness within city networks. It leverages data from OpenStreetMap (www.openstreetmap.org) and is implemented as both an R package and a Shiny web application for user-friendly interaction.","archived":false,"fork":false,"pushed_at":"2026-05-29T13:58:35.000Z","size":93559,"stargazers_count":182,"open_issues_count":0,"forks_count":20,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-06-15T15:04:14.318Z","etag":null,"topics":["cities","ggplot2","greenness-exposure","leaflet","open-source","openstreetmap","r","rstats","shiny-r","visualization"],"latest_commit_sha":null,"homepage":"https://www.sciencedirect.com/science/article/pii/S1470160X2400565X","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/sachit27.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-24T08:20:57.000Z","updated_at":"2026-06-14T10:54:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"f7886e93-e7a6-4d18-ab1c-fc0fb53c9ef8","html_url":"https://github.com/sachit27/greenR","commit_stats":{"total_commits":191,"total_committers":2,"mean_commits":95.5,"dds":"0.13089005235602091","last_synced_commit":"4adf6eee1e798daaa9829ef01937c9b2f9bc53fa"},"previous_names":["sachit27/greenr"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/sachit27/greenR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachit27%2FgreenR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachit27%2FgreenR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachit27%2FgreenR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachit27%2FgreenR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sachit27","download_url":"https://codeload.github.com/sachit27/greenR/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachit27%2FgreenR/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34453446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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"}},"owner":{"login":"sachit27","name":"Sachit Mahajan","uuid":"20027571","kind":"user","description":"Researcher at ETH Zurich","email":"","website":"https://sites.google.com/view/sachitmahajan","location":"Zurich","twitter":null,"company":"ETH","icon_url":"https://avatars.githubusercontent.com/u/20027571?v=4","repositories_count":30,"last_synced_at":"2023-09-11T17:30:37.699Z","metadata":{"has_sponsors_listing":false},"html_url":"https://github.com/sachit27","funding_links":[],"total_stars":null,"followers":null,"following":null,"created_at":"2023-02-24T14:20:24.226Z","updated_at":"2023-09-11T17:30:38.315Z","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sachit27","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sachit27/repositories"},"packages":[],"commits":{"id":1372336,"full_name":"sachit27/greenR","default_branch":"main","total_commits":302,"total_committers":2,"total_bot_commits":0,"total_bot_committers":0,"mean_commits":151.0,"dds":0.08278145695364236,"past_year_total_commits":39,"past_year_total_committers":1,"past_year_total_bot_commits":0,"past_year_total_bot_committers":0,"past_year_mean_commits":39.0,"past_year_dds":0.0,"last_synced_at":"2026-06-19T17:01:08.552Z","last_synced_commit":"33ea85a0c1170475527d1b1127f262118fcdcbc0","created_at":"2023-09-13T15:20:29.134Z","updated_at":"2026-06-19T17:00:56.547Z","committers":[{"name":"Sachit Mahajan","email":"sachitmahajan90@gmail.com","login":"sachit27","count":277},{"name":"Sachit Mahajan","email":"smahajan@gess-rz-dock-1-125.ethz.ch","login":null,"count":25}],"past_year_committers":[{"name":"Sachit","email":"sachitmahajan90@gmail.com","login":"sachit27","count":39}],"commits_url":"https://commits.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachit27%2FgreenR/commits","host":{"name":"GitHub","url":"https://github.com","kind":"github","last_synced_at":"2026-06-21T00:00:11.101Z","repositories_count":6265206,"commits_count":875219842,"contributors_count":35095675,"owners_count":1169634,"icon_url":"https://github.com/github.png","host_url":"https://commits.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://commits.ecosyste.ms/api/v1/hosts/GitHub/repositories"}},"issues_stats":{"full_name":"sachit27/greenR","html_url":"https://github.com/sachit27/greenR","last_synced_at":"2026-04-03T03:00:44.402Z","status":"error","issues_count":4,"pull_requests_count":0,"avg_time_to_close_issue":564678.5,"avg_time_to_close_pull_request":null,"issues_closed_count":4,"pull_requests_closed_count":0,"pull_request_authors_count":0,"issue_authors_count":4,"avg_comments_per_issue":1.0,"avg_comments_per_pull_request":null,"merged_pull_requests_count":0,"bot_issues_count":0,"bot_pull_requests_count":0,"past_year_issues_count":0,"past_year_pull_requests_count":0,"past_year_avg_time_to_close_issue":null,"past_year_avg_time_to_close_pull_request":null,"past_year_issues_closed_count":0,"past_year_pull_requests_closed_count":0,"past_year_pull_request_authors_count":0,"past_year_issue_authors_count":0,"past_year_avg_comments_per_issue":null,"past_year_avg_comments_per_pull_request":null,"past_year_bot_issues_count":0,"past_year_bot_pull_requests_count":0,"past_year_merged_pull_requests_count":0,"created_at":"2023-09-13T15:20:35.762Z","updated_at":"2026-04-03T03:00:44.402Z","repository_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachit27%2FgreenR","issues_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachit27%2FgreenR/issues","issue_labels_count":{},"pull_request_labels_count":{},"issue_author_associations_count":{"NONE":4},"pull_request_author_associations_count":{},"issue_authors":{"redfrexx":1,"loleg":1,"lyoungblood14":1,"canng":1},"pull_request_authors":{},"host":{"name":"GitHub","url":"https://github.com","kind":"github","last_synced_at":"2026-06-17T00:00:21.091Z","repositories_count":14814483,"issues_count":33119003,"pull_requests_count":109358492,"authors_count":11309491,"icon_url":"https://github.com/github.png","host_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories","owners_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/owners","authors_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/authors"},"past_year_issue_labels_count":{},"past_year_pull_request_labels_count":{},"past_year_issue_author_associations_count":{},"past_year_pull_request_author_associations_count":{},"past_year_issue_authors":{},"past_year_pull_request_authors":{},"maintainers":[],"active_maintainers":[]},"events":{"total":{"ReleaseEvent":1,"ForkEvent":3,"WatchEvent":22,"PushEvent":25,"CreateEvent":1},"last_year":{"ForkEvent":1,"WatchEvent":9,"PushEvent":14}},"keywords":["cities","ggplot2","greenness-exposure","leaflet","open-source","openstreetmap","r","rstats","shiny-r","visualization"],"dependencies":[],"score":5.8971538676367405,"created_at":"2023-09-13T13:28:25.225Z","updated_at":"2026-06-22T18:30:25.180Z","avatar_url":"https://github.com/sachit27.png","language":"R","category":"Biosphere","sub_category":"Plants and Vegetation","monthly_downloads":0,"total_dependent_repos":0,"total_dependent_packages":0,"readme":"[![CRAN Version](https://www.r-pkg.org/badges/version/greenR)](https://CRAN.R-project.org/package=greenR)\n[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/greenR)](https://cran.r-project.org/package=greenR)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![Open Science](https://img.shields.io/badge/Open%20Science-✓-purple.svg)](https://www.sciencedirect.com/science/article/pii/S1470160X2400565X)\n[![FAIR Data](https://img.shields.io/badge/FAIR-Data-orange.svg)](https://www.sciencedirect.com/science/article/pii/S1470160X2400565X)\n![Ecosystem Compatibility](https://img.shields.io/badge/ecosystem-r--spatial-388E3C.svg)\n![Prix Carto Winner](https://img.shields.io/badge/Prix_Carto_2025-Winner-9C27B0.svg)\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://kartografie.ch/category/prixcarto/\"\u003e\n    \u003cimg src=\"vignettes/EDU_mit_SGK.svg\" width=\"130\" alt=\"Prix Carto 2025 Award\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"vignettes/logo.jpg\" width=\"220\" style=\"border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.15);\" /\u003e\n  \u003cimg src=\"vignettes/zh_network.jpg\" width=\"250\" style=\"border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.15);\" /\u003e\n  \u003cimg src=\"vignettes/zh_gi.jpg\" width=\"300\" style=\"border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.15);\" /\u003e\n\u003c/p\u003e\n\n# greenR: Urban Environmental Analytics for R\n\n**Quantify. Analyze. Visualize.**\n\n`greenR` is an award-winning open-source R package for quantifying, analyzing, and visualizing urban greenness and microclimate priorities. It integrates OpenStreetMap, satellite imagery, population grids, and canopy height models into a unified analytical pipeline — from street-segment greenness scoring to city-scale climate-responsive planting prioritization.\n\n\u003e ✨ *Winner of the **[Prix Carto 2025 – Edu category](https://kartografie.ch/category/prixcarto/)** at the celebration of 100 years of the Institute of Cartography and Geoinformation at ETH Zurich.*\n\n| Feature | Description |\n|---------|-------------|\n| 🌲 **Sky View Factor (SVF) 3D** | WebGL 3D structural canopy explorers and network-corridor SVF metrics |\n| 🌡️ **Urban Heat Decision Suite** | Multi-criteria diamond bivariate planting prioritization with street canyon physics |\n| 🌳 **Green Index** | Street-segment greenness scores with configurable distance decay |\n| 🌴 **Canopy Height Modeling** | 1m resolution analysis using Meta/WRI ALS GEDI v6 global dataset |\n| 🚶 **Accessibility Analysis** | Network-based isochrone mapping with walking/cycling routing |\n| 📊 **Spatial Inequality** | H3 hexagonal binning, Gini indices, and Lorenz inequality curves |\n| 🧭 **Directional Analysis** | Compass-oriented green space accessibility corridors |\n| 📷 **Green View Index (GVI)** | Superpixel computer-vision vegetation quantification |\n| ⚖️ **GSSI** | Cross-city green space similarity using spatial connectivity |\n| 🗺️ **Interactive Visualizations** | Deck.gl WebGL 3D, multilayer Leaflets, ggplot2, and tmap outputs |\n| 🖥️ **Shiny Application** | Zero-code web interface for all analytics |\n\n📄 [Published in Ecological Indicators](https://www.sciencedirect.com/science/article/pii/S1470160X2400565X) · [CRAN Package Page](https://CRAN.R-project.org/package=greenR)\n\n## Which Function Should I Use?\n\nStart here if you are new to the package. The three core workflows are:\n\n| Workflow | Use when you want... | Main function |\n|---|---|---|\n| Street greenness | street-level greenness scores from OSM network data, typically after `get_osm_data()` | `calculate_green_index()` |\n| SVF analysis | sky-view factor analysis using `elevatr` terrain, Global Building Atlas buildings, Meta CHMv2 canopy, and ray-casting | `uh_svf()` |\n| Urban heat priority | multi-layer planting-priority analysis using GHSL population by default, plus Landsat-9 LST, Sentinel-2 NDVI, Meta CHM, and OSM/GBA layers; reports population-weighted Gini statistics | `uh_decision()` |\n\nOther exported tools are grouped below so they are easier to find:\n\n| Category | Functions |\n|---|---|\n| Data access and preprocessing | `get_osm_data()`, `convert_to_point()`, `calculate_percentage()` |\n| Green space and accessibility | `accessibility_greenspace()`, `accessibility_mapbox()`, `analyze_green_accessibility()`, `create_accessibility_visualizations()`, `nearest_greenspace()`, `visualize_green_spaces()` |\n| Priority and equity workflows | `analyze_and_visualize_uhi()`, `analyze_green_and_tree_count_density()`, `assess_urban_priority_equity()`, `build_urban_priority_grid()`, `build_urban_block_priority()`, `build_street_canyon_priority()`, `emulate_canyon_microclimate()`, `green_space_clustering()`, `hexGreenSpace()`, `gssi()` |\n| Green index and canopy tools | `plot_green_index()`, `chm_analysis()`, `calculate_and_visualize_GVI()` |\n| Priority and map visualizations | `plot_priority_bivariate()`, `plot_priority_diamond_bivariate()`, `plot_priority_action_classes()`, `plot_canyon_priority_map()`, `plot_canyon_diamond_bivariate()`, `plot_hybrid_field_map()`, `plot_priority_interactive()` |\n| 3D and leaflet outputs | `create_hexmap_3D()`, `create_linestring_3D()`, `plot_priority_3d_explorer()`, `plot_priority_3d_isometric()`, `save_3d_deckgl_dashboard()`, `plot_multilayer_leaflet()`, `save_as_leaflet()` |\n| Workflow helpers and app entry points | `save_json()`, `run_app()` |\n\n---\n\n## ⚙️ System Dependencies\n\nBecause `greenR` leverages high-performance C++ geocomputational engines via `sf` and `terra`, it requires key spatial system libraries (`GDAL`, `GEOS`, `PROJ`) to be installed on your operating system prior to package installation.\n\n\u003e [!IMPORTANT]\n\u003e **Ensure system libraries are installed first:** If these libraries are missing from your PATH, R will fail to compile `sf` and `terra` from source.\n\n### 🍎 macOS (via Homebrew)\nOpen your Terminal and run:\n```bash\nbrew install gdal geos proj\n```\n\n### 🐧 Ubuntu / Debian\nInstall development libraries using `apt-get`:\n```bash\nsudo apt-get update\nsudo apt-get install -y libgdal-dev libgeos-dev libproj-dev libudunits2-dev\n```\n\n### 🪟 Windows\n1. Download and install **[Rtools](https://cran.r-project.org/bin/windows/Rtools/)** matching your R version.\n2. Binary builds for `sf` and `terra` on CRAN include pre-compiled system libraries automatically.\n\n---\n## Installation\nIt can be installed via CRAN\n```r\ninstall.packages(\"greenR\")\n```\nIn case there are difficulties in installing through CRAN (or the current version is not available), you can do it directly via GitHub by running the command below in R.\n\n```r\n# install.packages(\"remotes\") # Uncomment if you do not have the 'remotes' package installed\nremotes::install_github(\"sachit27/greenR\", dependencies = TRUE)\n```\nOr you can also use devtools to install the package.\n\n```r\nlibrary(devtools)\ndevtools::install_github(\"sachit27/greenR\", dependencies = TRUE)\n```\nIf you're updating from a previous version and encounter any issues, try clearing your package cache:\n```r\nremove.packages(\"greenR\")\n.rs.restartR()\ndevtools::install_github(\"sachit27/greenR\", dependencies = TRUE, force = TRUE)\n```\n\n\n\n## ⚡ Quick Start: Fine-Grained Street Greenness Analysis\n\nYou don't need local spatial files to start. Run the following code in R to automatically download street networks, compute street-segment greenness with distance decay, and render an interactive dark-themed map:\n\n```R\nlibrary(greenR)\nlibrary(sf)\n\n# 1. Fetch street network and green spaces dynamically from OpenStreetMap\ncity_data \u003c- get_osm_data(\"City of London, UK\")\n\n# 2. Compute street-segment Green Index with a 100m distance-decay parameter\ngreen_network \u003c- calculate_green_index(city_data, crs_code = 4326, D = 100)\n\n# 3. Visualize the greenness of the street network interactively\ninteractive_map \u003c- plot_green_index(\n  green_network, \n  interactive = TRUE, \n  base_map = \"CartoDB.DarkMatter\"\n)\n\n# 4. Render the dynamic spatial web map\nprint(interactive_map)\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"vignettes/darkmode.jpg\" width=\"100%\" alt=\"Street Greenness Output\" style=\"border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.15);\" /\u003e\n\u003c/p\u003e\n\n---\n\n# 🚀 Signature Suites\n\n## 🌲 Sky View Factor (SVF) 3D Suite\n\n*How much sky can a pedestrian actually see from the street — and where are the critical gaps in the urban canopy?*\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"vignettes/3d_svf.jpg\" width=\"100%\" alt=\"3D SVF Column Explorer\" /\u003e\n  \u003cbr/\u003e\n  \u003cimg src=\"vignettes/svf1.png\" width=\"100%\" alt=\"Sky View Factor Analysis\" style=\"margin-top: 10px;\" /\u003e\n\u003c/p\u003e\n\n### 🔬 Methodology, outputs \u0026 multi-mode code examples\n\n### What it computes\n```\nSky View Factor (SVF) = mean(cos^2(horizon_angle)) across sampled ray directions\n```\n\nSVF is modeled geometrically as the fraction of visible sky from a pedestrian perspective. The implementation ray-casts in multiple directions from each sample point, measures the horizon angle in each direction, and aggregates those angles into a mean cosine-squared SVF estimate. A **low SVF** (near 0) indicates a highly closed canopy or deep street canyon, offering maximum shade. A **high SVF** (near 1) indicates full sky exposure, maximizing direct solar radiation.\n\n### What it produces\n- **3D Deck.gl WebGL dashboards** — Fly through neighborhoods, inspect vertical canopy structures, toggle tree layers\n- **2D street corridor SVF maps** — Network-scale microclimate maps on CartoDB basemaps\n- **SVF distribution analytics** — Statistical distributions, histograms, and summary tables\n- **Interactive Leaflet maps** — Multi-layer toggleable web maps\n\n\u003e **Runtime note:** For larger cities, `uh_svf()` can take a while. Runtime depends on whether terrain and building data must be downloaded online, and on how much ray-casting and map rendering is required for the chosen sample density and outputs. Local inputs reduce download time, but they do not remove the core computation.\n\n---\n\n### 🌐 Example 1: Purely Online Mode (Zero local data setup)\nAutomatically downloads London street networks, terrain elevations, building vectors, and Meta/WRI 1m GEDI canopy height data on-the-fly!\n```R\nlibrary(greenR)\n\nsvf_results \u003c- uh_svf(\n  city_name        = \"City of London, UK\",\n  analysis_scale   = \"city_screening\",\n  terrain_source   = \"elevatr\",\n  elevatr_z        = 13,\n  buildings_source = \"gba\",\n  sample_mode      = \"both\",                 # MUST be \"both\" or \"grid\" to compute buildings and enable 3D!\n  spacing_street_m = 30,                     # Spacing along street network (meters)\n  spacing_grid_m   = 50,                     # Grid sampling interval (meters)\n  n_directions     = 36,                     # Number of ray-cast directions\n  include_leaflet  = TRUE,                    # Build interactive Leaflet map\n  include_3d       = TRUE,                    # Build fully interactive 3D WebGL explorer\n  output_dir       = \"./london_svf_outputs\",  # Save files in this directory\n  output_prefix    = \"london_full\"            # Prefix for all generated maps \u0026 assets\n)\n\n# Open interactive 3D explorer\nbrowseURL(\"./london_svf_outputs/london_full_svf_3d_explorer.html\")\n```\n\n### 📂 Example 2: Local Boundary, Buildings, and Canopy Inputs\nPerfect for using proprietary municipal shapefiles, building footprints, and custom airborne LiDAR rasters while keeping the rest of the SVF workflow unchanged.\n```R\nlibrary(greenR)\nlibrary(sf)\nlibrary(terra)\n\n# 1. Load local spatial layers and canopy rasters\nlocal_boundary \u003c- sf::st_read(\"data/london_district_boundary.geojson\")\nlocal_buildings \u003c- sf::st_read(\"data/london_buildings.geojson\")\nlocal_canopy   \u003c- terra::rast(\"data/airborne_lidar_chm_1m.tif\")\n\n# 2. Run with local terrain, building, and canopy overrides\nsvf_results \u003c- uh_svf(\n  city_name        = \"Local SVF Analysis\",\n  boundary         = local_boundary,\n  terrain_source   = \"local\",\n  terrain_path     = \"data/local_dem_10m.tif\",\n  buildings_source = \"local\",\n  buildings_object = local_buildings,\n  canopy_object    = local_canopy,\n  include_leaflet  = TRUE,\n  include_3d       = TRUE,\n  output_dir       = \"./london_svf_offline\",\n  output_prefix    = \"london_offline\"\n)\n```\n\n### ⚡ Example 3: Hybrid Mode (Online streets + local LiDAR DSM)\nLet greenR fetch the street network dynamically from OpenStreetMap, but override the canopy dataset with your own ultra-high-resolution municipal LiDAR raster.\n```R\nlibrary(greenR)\nlibrary(terra)\n\n# Load local DSM raster\nmy_lidar_chm \u003c- terra::rast(\"data/municipal_lidar_dsm.tif\")\n\nsvf_results \u003c- uh_svf(\n  city_name        = \"Zurich, Switzerland\",\n  terrain_source   = \"elevatr\",\n  buildings_source = \"gba\",\n  sample_mode      = \"both\",                  # Computes both street and building SVF for 3D mapping\n  canopy_object    = my_lidar_chm,            # Overrides global GEDI CHM with local raster\n  include_leaflet  = TRUE,\n  include_3d       = TRUE,\n  output_dir       = \"./zurich_svf_hybrid\",\n  output_prefix    = \"zurich_hybrid\"\n)\n```\n\n\n---\n\n## 🌡️ Urban Heat Decision Suite \u0026 Canyon Physics\n\n*We have limited budget — where do high thermal exposure and planting opportunities actually intersect?*\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"vignettes/newdelhi_decision_action_classes_hexagons.png\" width=\"100%\" alt=\"New Delhi Action Classes\" /\u003e\n  \u003cbr/\u003e\n  \u003cimg src=\"vignettes/newdelhi_decision_hybrid_field_hexagons.png\" width=\"100%\" alt=\"New Delhi Hybrid Priority Field\" /\u003e\n  \u003cbr/\u003e\n  \u003cimg src=\"vignettes/urban_heat1.png\" width=\"100%\" alt=\"Zurich Street Canyon Priorities\" style=\"margin-top: 10px;\" /\u003e\n\u003c/p\u003e\n\n### 🔬 Methodology, outputs \u0026 code examples\n\n### Bivariate Diamond Prioritization\nThe engine maps spatial \"Need\" (heat exposure × population) and \"Opportunity\" (lack of canopy and vegetation) into a **45-degree rotated 3×3 diamond bivariate matrix**:\n\n```\nHeat Exposure       = 0.5 × rank(LST) + 0.5 × rank(log1p(population))\nCooling Deficit     = 0.5 × (1 − rank(NDVI)) + 0.5 × (1 − rank(Canopy Height))\nTree Need Score     = 100 × √(Heat Exposure × Cooling Deficit)\nPlanting Opportunity = 100 × (1 − rank(Canopy Height))\nMaster Priority     = 100 × √(Tree Need × Planting Opportunity)\n```\n\nThe geometric mean guarantees that **both** structural vulnerability and physical planting capacity must be high for a location to rank as top priority.\n\n### Latitude-Aware Street Canyon Physics\nThe framework implements physical, pedestrian-scale street canyon priority indexing:\n\n- **Canyon Buffering:** Roads → 2D canyon polygons (15m motorway, 10m secondary, 6m residential)\n- **Compass Bearing:** Vectorized start-to-end azimuth calculation (0–180°)\n- **Solar Exposure Model:**\n  $$\\text{Solar Exposure} = \\sin(|\\text{lat}|) \\times |\\sin(\\text{bearing})| + (1 - \\sin(|\\text{lat}|)) \\times 1$$\n  E–W canyons are prioritized at mid-latitudes (high noon beam radiation), while the directional bias correctly disappears for equatorial cities.\n\n### What it produces\n- **Diamond bivariate maps** — Rotated 3×3 legend with four interpretive quadrants (Top Priority, Cooler, Constrained, Sufficient)\n- **Street canyon priority corridors** — Continuous priority coloring along every road buffer\n- **Morphological block superblocks** — Voronoi/OSM-based neighborhood subdivision\n- **Action class maps** — Top 5% intervention tiers at both block and hexagon scales\n- **3D Deck.gl dashboards** — Extruded neighborhood columns and hexagonal columns\n- **Interactive multilayer Leaflet** — Toggleable overlays of all analysis layers\n\n\u003e **Runtime note:** For larger cities, `uh_decision()` can also take substantial time. Runtime depends on whether data are fetched online and on the cost of the full spatial workflow, including overlays, scoring, and visualizations. Local rasters and vector inputs can reduce download overhead, but the analysis still scales with city extent and resolution.\n\n### Example 1: Full City (Online Mode)\nRun the complete UHI planting prioritization suite dynamically using purely online spatial data:\n```R\nlibrary(greenR)\n\nresults \u003c- uh_decision(\n  city_name       = \"Zurich, Switzerland\",   # Fetches boundary automatically from OSM\n  hex_size_m      = 100,                     # 100m hexagon spatial resolution\n  use_cache       = TRUE,                    # Caches on-the-fly downloads to avoid re-fetching\n  include_leaflet = TRUE,                    # Builds interactive multilayer Leaflet map\n  include_3d      = TRUE,                    # Builds 3D WebGL explorers (neighborhood \u0026 hex grid columns)\n  include_gis     = TRUE,                    # Exports raw spatial data (GeoPackage, GeoJSON)\n  output_dir      = \"./zurich_outputs\",      # Save all files in this directory\n  output_prefix   = \"zurich_full\"            # Prefix for generated files\n)\n\n# Open interactive explorers in your browser:\nutils::browseURL(\"./zurich_outputs/zurich_full_multilayer_leaflet.html\")\nutils::browseURL(\"./zurich_outputs/zurich_full_3d_explorer.html\")\nutils::browseURL(\"./zurich_outputs/zurich_full_3d_hex_explorer.html\")\n```\n\n### Example 2: Bounding Box with Local Population Data\n```R\nlibrary(greenR)\nlibrary(sf)\n\nzurich_bbox \u003c- sf::st_as_sfc(\n  sf::st_bbox(c(xmin = 8.523, ymin = 47.365, xmax = 8.555, ymax = 47.393), crs = 4326)\n) |\u003e sf::st_sf()\n\nresults \u003c- uh_decision(\n  city_name       = \"Zurich Center, Switzerland\",\n  hex_size_m      = 80,\n  local_boundary  = zurich_bbox,\n  use_cache       = TRUE,\n  include_leaflet = TRUE,\n  include_3d      = TRUE,\n  output_dir      = \"./zurich_outputs\",\n  output_prefix   = \"zurich_quick\"\n)\n```\n\n### Example 3: Local GHSL Population Raster\n```R\nresults \u003c- uh_decision(\n  city_name        = \"New Delhi, India\",\n  hex_size_m       = 100,\n  local_population = \"GHS_POP_E2030_GLOBE_R2023A_54009_100_V1_0_R6_C26.tif\",\n  use_cache        = TRUE,\n  include_leaflet  = TRUE,\n  include_3d       = TRUE,\n  output_dir       = \"./newdelhi_outputs\"\n)\n```\n\n\n---\n\n# 🌍 Data Workflows: Online, Local \u0026 Hybrid Modes\n\n`greenR` is designed to be highly flexible, supporting different data workflows depending on data sensitivity, local resolution requirements, and internet connectivity.\n\n\u003cdetails\u003e\n\u003csummary\u003e🌐 \u003cstrong\u003eMode 1: Online Mode (Hands-Free API Retrieval)\u003c/strong\u003e\u003c/summary\u003e\n\nBest for **rapid scoping, exploratory analysis, and multi-city comparisons**. `greenR` automatically queries online REST APIs and spatial servers to gather all required street, canopy, population, and satellite data on-the-fly.\n\n### Automated Sources\n*   **OpenStreetMap (OSM)**: Street networks, buildings, parks, and tree counts are fetched using a high-performance Overpass API retrieval pipeline.\n*   **Satellite Imagery (NDVI \u0026 Land Surface Temp)**: Automatically queried and composited from Landsat 8/9 and Sentinel-2 STAC endpoints.\n*   **Canopy Height Model (CHM)**: Fetched at 1-meter resolution using the Meta/WRI global LiDAR ALS GEDI v6 dataset.\n*   **Population**: Aggregated dynamically from the Joint Research Centre’s Global Human Settlement Layer (GHSL) raster database.\n\n### Code Example\n```R\nlibrary(greenR)\n\n# Fetch, analyze, and build interactive 3D dashboards with zero local files!\nresults \u003c- uh_decision(\n  city_name  = \"Geneva, Switzerland\",\n  hex_size_m = 100,\n  output_dir = \"./geneva_outputs\"\n)\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e📂 \u003cstrong\u003eMode 2: Local Mode (Completely Offline / Secure Projects)\u003c/strong\u003e\u003c/summary\u003e\n\nBest for **municipalities, private planning consulting, or offline computational servers**. You can bypass all online API calls by feeding in pre-existing local shapefiles, GeoJSONs, and custom high-resolution LiDAR or satellite rasters.\n\n### Code Example\n```R\nlibrary(greenR)\nlibrary(sf)\nlibrary(terra)\n\n# 1. Load local spatial vector layers (GeoJSON / Shapefiles / GPKG)\nmy_boundary  \u003c- sf::st_read(\"data/municipal_boundary.geojson\")\nmy_trees     \u003c- sf::st_read(\"data/tree_inventory_points.shp\")\nmy_buildings \u003c- sf::st_read(\"data/building_footprints.gpkg\")\n\n# 2. Load local satellite \u0026 raster datasets (GeoTIFF)\nmy_lst  \u003c- terra::rast(\"data/local_thermal_lst.tif\")\nmy_chm  \u003c- terra::rast(\"data/high_res_airborne_lidar_chm.tif\")\nmy_pop  \u003c- terra::rast(\"data/exact_census_block_population.tif\")\nmy_ndvi \u003c- terra::rast(\"data/sentinel_ndvi_spring.tif\")\n\n# 3. Package street \u0026 green layers into a local OSM list to bypass Overpass completely\nmy_osm_list \u003c- list(\n  highways    = list(osm_lines    = sf::st_read(\"data/street_network.geojson\")),\n  green_areas = list(osm_polygons = sf::st_read(\"data/parks_and_nature_reserves.geojson\")),\n  trees       = list(osm_points   = my_trees),\n  buildings   = list(osm_polygons = my_buildings)\n)\n\n# 4. Execute fully offline with local files\nresults \u003c- uh_decision(\n  city_name            = \"Municipal Offline Analysis\",\n  hex_size_m           = 50,\n  local_boundary       = my_boundary,\n  local_osm_layers     = my_osm_list,\n  local_ndvi           = my_ndvi,\n  local_lst            = my_lst,\n  local_chm            = my_chm,\n  local_population     = my_pop,\n  local_buildings      = my_buildings,\n  include_leaflet      = TRUE,\n  include_3d           = TRUE,\n  output_dir           = \"./local_offline_outputs\"\n)\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e⚡ \u003cstrong\u003eMode 3: Hybrid Mode (Online Streets + Local Proprietary Overrides)\u003c/strong\u003e\u003c/summary\u003e\n\nBest for **maximizing accuracy while saving setup time**. You let `greenR` download baseline street networks and satellite composites online, but seamlessly override specific layers with your high-resolution local datasets (e.g., proprietary municipal LiDAR rasters or internal census grids).\n\n### Code Example\n```R\nlibrary(greenR)\nlibrary(terra)\n\n# Load a high-resolution local population grid and a local LiDAR canopy model,\n# but let greenR handle the street network, green areas, and LST online!\nlocal_pop_grid  \u003c- terra::rast(\"data/high_res_census_pop.tif\")\nlocal_lidar_chm \u003c- terra::rast(\"data/municipal_lidar_chm.tif\")\n\nresults \u003c- uh_decision(\n  city_name        = \"Zurich, Switzerland\",\n  hex_size_m       = 80,\n  local_population = local_pop_grid,   # overrides online GHSL pop\n  local_chm        = local_lidar_chm,  # overrides online 1m Meta CHM\n  output_dir       = \"./zurich_hybrid_outputs\"\n)\n```\n\n\u003c/details\u003e\n\n---\n\nIf you find `greenR` useful, please consider giving the repository a ★ on GitHub.\n\n# 📊 Classical Urban Analytics\n\n## 🌳 Green Index Quantification\n\n*What is the relative greenness of every street segment in a city?*\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"vignettes/leaflet.jpg\" width=\"100%\" alt=\"Leaflet Street Greenness Map\" /\u003e\n  \u003cbr/\u003e\n  \u003cimg src=\"https://github.com/sachit27/Accessibility-Analysis/blob/main/images/linestring.gif?raw=true\" width=\"100%\" alt=\"3D Linestring Map\" /\u003e\n  \u003cbr/\u003e\n  \u003cimg src=\"https://github.com/sachit27/Accessibility-Analysis/blob/main/images/hex3d.gif?raw=true\" width=\"100%\" alt=\"3D Hex Map\" /\u003e\n\u003c/p\u003e\n\n### 🔬 Details \u0026 code\n\n### Specify the Location and Download the Data\n\nThe first step is to acquire data. This provides a systematic approach to collecting the requisite geospatial data from OSM, thereby serving as the foundation for all subsequent analyses. The users can simply specify any city or neighborhood (that has data available in OSM database). This function looks in the database and finds any city and downloads OSM data for the specified spatial area with regard to three key environmental features: highways, green areas, and trees. Here green areas include all the areas with the following tags: \"forest\", \"vineyard\", \"plant_nursery\", \"orchard\", \"greenfield\", \"recreation_ground\", \"allotments\", \"meadow\", \"village_green\", \"flowerbed\", \"grass\", \"farmland\", \"garden\", \"dog_park\", \"nature_reserve\", and \"park\".\n\n#### Option 1: City or neighborhood name\n```R\ndata \u003c- get_osm_data(\"City of London, United Kingdom\")\n# Or neighborhood specific:\ndata \u003c- get_osm_data(\"Fulham, London, United Kingdom\")\n```\n\n#### Option 2: Bounding box coordinates\nFor more precise control over the area of interest, users can provide a bounding box using coordinates. This is particularly useful when you need to define a specific area around a point of interest.\n```R\n# Define bounding box: (left, bottom, right, top)\nbbox \u003c- c(-0.1, 51.5, 0.1, 51.7)  # Example bounding box for central London\ndata \u003c- get_osm_data(bbox)\n```\n\n#### Handling Overpass API Timeouts\nOpenStreetMap data is retrieved via the Overpass API. Occasionally, you may encounter an error such as: `HTTP 504 Gateway Timeout`. This typically occurs when the default Overpass server is temporarily overloaded.\n\nIf this happens, you can switch to an alternative Overpass mirror before running `get_osm_data()`:\n```R\nlibrary(osmdata)\n\n# Set an alternative Overpass server\nset_overpass_url(\"https://lambert.openstreetmap.de/api/interpreter\")\n\n# Then retry\ndata \u003c- get_osm_data(\"Basel, Switzerland\")\n```\n\n---\n\n### Calculate the Green Index\n\nThis function takes as input the OSM data, a Coordinate Reference System (CRS) code, and parameter D for the distance decay functions. The algorithm extracts the highways, green areas, and trees data from the input list and transforms the data into the given CRS. The CRS affects how distances, areas, and other measurements are calculated. Different CRSs may represent the Earth's surface in ways that either exaggerate or minimize certain dimensions. So, using the wrong CRS can lead to incorrect calculations and analyses. If you're focusing on a city or other localized area, you'll likely want to use a CRS that is tailored to that specific location. This could be a local city grid system or other local CRS that has been designed to minimize distortions in that area. \n\nThis function then defines distance decay functions for green areas and trees using the parameter D. For each edge in the highway data, the function calculates the green index using the decay functions and returns a data frame with the green index for each edge. By default, D is specified to 100 (distance decay parameter in meters) but it can be changed by the user. Similarly, the users must specify the CRS (https://epsg.io/). The green index ranges from 0 to 1 and it represents the relative greenness of each section, factoring in proximity to green spaces and tree density.\n\n```R\ngreen_index \u003c- calculate_green_index(data, 4326, 100)\n```\n\n---\n\n### Create the Green Index Plot\n\nThis function visualizes the green index on a map, with options for both static and interactive display. Interactive maps are rendered using Leaflet and Mapbox, allowing users to zoom, pan, and interact with the map to explore the green index in more detail.\n\n#### Features\n- **Dynamic Mapping**: Create interactive, dynamic maps for a more engaging and detailed visualization.\n- **Customization**: Modify color palette, text size, resolution, title, axis labels, legend position, line width, and line type to suit your preferences.\n\n```R\n# Create a static plot\nmap \u003c- plot_green_index(green_index)\n\n# Customize static plot\nmap \u003c- plot_green_index(green_index, colors = c(\"#FF0000\", \"#00FF00\"), line_width = 1, line_type = \"dashed\")\n```\n\n#### 3D Linestring Map using Mapbox GL JS\nThis map is designed to visualize linear features such as roads, trails, or any other types of linestring data. This can be particularly useful for visualizing connectivity, transportation networks, or other linear spatial patterns. The function supports interactive controls for adjusting the line width and toggling building visibility on the map. It accepts linestring data and automatically processes it to create a visually appealing 3D map.\n\n```R\nmapbox_token \u003c- \"your_mapbox_access_token_here\"\ncreate_linestring_3D(green_index, \"green_index\", mapbox_token)\n```\n\n#### Customize Interactive Base Map (Leaflet version)\nIn interactive mode, you can change the base map to various themes.\n```R\n# Create an interactive plot using Leaflet\nmap \u003c- plot_green_index(green_index, interactive = TRUE, base_map = \"CartoDB.DarkMatter\")\n\n# To view the plot in the console, use:\nprint(map)\n\n# Use a light-themed base map\nmap \u003c- plot_green_index(green_index, interactive = TRUE, base_map = \"CartoDB.Positron\")\nprint(map)\n```\n\nYou can save the interactive map using the htmlwidgets library.\n```R\nlibrary(htmlwidgets)\nsaveWidget(map, file = \"my_plot.html\")\n```\n\n#### 3D Hex Map (Mapbox version)\nThe `create_hexmap_3D` function generates a 3D hexagon map using H3 hexagons and Mapbox GL JS. This map can visualize various types of geographical data, such as points, linestrings, polygons, and multipolygons. It is particularly useful for visualizing density or green indices over an area. It automatically processes these geometries, converting them to points for visualization. Users can dynamically change the radius of the hexagons and their heights to better represent the data. The resulting map includes controls for adjusting hexagon height and H3 resolution, and selecting different Mapbox styles.\n\n```R\nmapbox_token \u003c- \"your_mapbox_access_token_here\"\n\ncreate_hexmap_3D(\n  data = green_index,\n  value_col = \"green_index\",\n  mapbox_token = mapbox_token,\n  output_file = \"map.html\",\n  color_palette = \"interpolateViridis\"\n)\n```\n\n---\n\n### Calculate the Percentage of Edges with a certain Green Index\n\nThis function groups the edges by their respective green index and calculates the percentage of edges for each green index. For easier interpretation, we categorize the index into three tiers: Low (\u003c 0.4), Medium (0.4-0.7), and High (\u003e 0.7).\n\n```R\npercentage \u003c- calculate_percentage(green_index) # Low (\u003c0.4), Medium (0.4-0.7), High (\u003e0.7)\n```\n\n---\n\n### Data Export and Sharing\n\nThese functions allow the user to download the green index values as a GeoJSON file as well as a Leaflet map. The GeoJSON file retains the geographical properties of the data and can be readily employed in a broad range of GIS applications. The Leaflet map, saved as an HTML file, provides an interactive user experience, facilitating dynamic exploration of the data. The users should specify the file path to save these files.\n\n```R\nsave_json(green_index, \"/path/to/map.geojson\")\nsave_as_leaflet(green_index, \"/path/to/map.html\")\n```\n\n\n---\n\n## 🗺️ Green Spaces, Clustering \u0026 Density\n\n*How are green spaces and trees distributed across the city — and how equitable is that distribution?*\n\n![Green_Areas and Clusters](/vignettes/vis.jpg)\n\n### 🔬 Details \u0026 code\n\n### Visualize \u0026 Cluster Green Spaces\n\nThe `visualize_green_spaces()` function is designed to aid in the visual assessment of green space data. Utilizing an integrated Leaflet map, users can explore the distribution and mapping quality of green spaces within a specified area. By plotting this data on an interactive Leaflet map, users gain insights into the extent and accuracy of green space representation. After visualizing the green spaces within the desired area, users may wish to contribute to the OpenStreetMap project to enhance the data quality or add unrepresented areas. \n\nAdditionally, the `green_space_clustering()` function initially transforms the green spaces into an equal-area projection to calculate the areas accurately. Post-transformation, the K-means algorithm is applied to these areas, clustering the green spaces based on the number of clusters specified.\n\n```R\ngreen_areas_data \u003c- data$green_areas\nvisualize_green_spaces(green_areas_data)\n\ngreen_space_clustering(green_areas_data, num_clusters = 3)\n```\n\n---\n\n### H3 Hexagonal Density \u0026 Inequality Analysis\n\nThe `analyze_green_and_tree_count_density()` function quantifies the spatial distribution and inequality of green areas or tree locations within an urban area using hexagonal spatial bins. Users can select either green area polygons or tree point data from OpenStreetMap as the input.\n\n- **Method**: The function divides the study area into hexagons (using the H3 spatial indexing system) and counts either the number of green polygons or trees in each hexagon. Multiple classification schemes (quantile, Jenks, fixed thresholds) are available to assign each hexagon to low, medium, or high density classes, automatically selecting a fallback if the data are sparse. Spatial metrics are calculated, including counts per km² over the hexagonal area.\n- **Analytics**: The function produces a comprehensive set of summary statistics and inequality measures, including the total, mean, and median counts per hexagon, as well as the Gini index to quantify spatial inequality in the distribution of green areas or trees. It also calculates skewness and kurtosis to characterize the shape of the distribution, and generates the Lorenz curve with its area-under-curve to visualize and measure inequality. Additionally, the function reports the classification method and the bin thresholds used to categorize density across the study area.\n\nInteractive maps (Leaflet) and plots (such as the Lorenz curve) are generated automatically. Results and metrics can also be exported as GeoJSON and JSON files for further analysis.\n\n```R\nosm_data \u003c- get_osm_data(\"Zurich, Switzerland\")\n\nresult \u003c- analyze_green_and_tree_count_density(\n  osm_data = osm_data,\n  mode = \"tree_density\",     # or \"green_area\"\n  h3_res = 8,\n  save_lorenz = TRUE\n)\nresult$map        # Interactive Leaflet map\nresult$analytics  # Summary statistics and Gini index\nresult$lorenz_plot # Lorenz curve\n```\n\n\n---\n\n## 🚶 Accessibility Analysis\n\n*How far does every resident have to walk to reach the nearest green space — and does it vary by direction?*\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"vignettes/access.jpg\" width=\"100%\" alt=\"Directional Accessibility\" /\u003e\n  \u003cbr/\u003e\n  \u003cimg src=\"vignettes/isochrone.jpg\" width=\"100%\" alt=\"Isochrone Access\" /\u003e\n  \u003cbr/\u003e\n  \u003cimg src=\"https://github.com/sachit27/Accessibility-Analysis/blob/main/images/access_mapbox.gif?raw=true\" width=\"100%\" alt=\"Access Mapbox\" /\u003e\n\u003c/p\u003e\n\n### 🔬 Details \u0026 code\n\n### Isochrone-Based Accessibility\n\n#### Mapbox Version (Dynamic)\nThe `accessibility_mapbox` function creates an accessibility map using Mapbox GL JS. This map shows green areas and allows users to generate isochrones for walking times. The resulting HTML file includes interactive features for changing the walking time and moving the location marker dynamically.\n```R\nmapbox_token \u003c- \"your_mapbox_access_token_here\"\naccessibility_mapbox(green_areas_data, mapbox_token)\n```\n\n#### Leaflet Version (Multi-Tier)\nThe `accessibility_greenspace` function creates an interactive Leaflet map displaying accessible green spaces within a specified walking time from a provided location. It utilizes isochrones to visualize the areas reachable by 5, 10, and 15 minutes of walking. The function relies on pedestrian routing information and green space data to accurately delineate accessible areas. The default maximum walking time is set to 15 minutes but can be adjusted using the `max_walk_time` parameter.\n\n```R\naccessibility_greenspace(green_areas_data, 47.564275, 7.595820)\n```\n\nIn addition to creating an interactive map, the `accessibility_greenspace` function can also export the data in a format compatible with GIS software.\n```R\nresult \u003c- accessibility_greenspace(\n  green_areas_data, \n  47.564275, 7.595820,\n  output_file = \"green_space_accessibility.gpkg\"\n)\n```\n\n---\n\n### Green Space Accessibility, Directionality, and Population Coverage\n\n`greenR` provides functions to measure and visualize urban residents’ access to green spaces using actual street networks, multiple transport modes, and high-resolution population data.\n\n- **Accessibility Analysis**: The `analyze_green_accessibility()` function calculates the network-based distance from a regular grid of locations across the city to the nearest mapped green space. This is done using real street networks for different modes of travel—walking, cycling, or driving. The analysis can also incorporate gridded population data (for example: GHSL GHS-POP, epoch 2025, 100m resolution, Mollweide projection) to compute population-weighted accessibility metrics. Accessibility is summarized as the percentage of the city’s area, and separately, the percentage of the population within 400m and 800m of a green space.\n- **Directionality of Access**: The analysis quantifies how green space access varies by compass direction (N, NE, E, SE, S, SW, W, NW) from each grid cell. This directionality metric helps identify spatial patterns and potential barriers or corridors in green space exposure.\n- **Visualization**: The `create_accessibility_visualizations()` function summarizes the results in three main plots. A grid map showing the minimum network distance to the nearest green space for each location. A barplot of spatial and population-weighted coverage within 400m and 800m thresholds. A radar plot representing directional coverage, where each axis shows the average green space access in that direction. An interactive Leaflet map is also produced, combining distance, population, and green space layers for exploration.\n\nBelow is a sample output for Basel, Switzerland, showing spatial, population-weighted, and directional green space accessibility.\n\n```R\nlibrary(terra)\nlibrary(sf)\n\ndata \u003c- get_osm_data(\"Basel, Switzerland\")\n\n# Load and reproject your GHSL raster\nghsl_path \u003c- \"GHS_POP_E2025_GLOBE_R2023A_54009_100_V1_0_R4_C19.tif\"\npop_raster_raw \u003c- terra::rast(ghsl_path)\n\nnetwork \u003c- data$highways$osm_lines\ngreen   \u003c- data$green_areas$osm_polygons\n\nresult \u003c- analyze_green_accessibility(\n  network_data      = network,\n  green_areas       = green,\n  mode              = \"walking\",\n  grid_size         = 300,\n  population_raster = pop_raster_raw\n)\n\nviz \u003c- create_accessibility_visualizations(\n  accessibility_analysis = result,\n  green_areas = green,\n  mode = \"walking\"\n)\n\nprint(viz$distance_map)\nprint(viz$coverage_plot)\nprint(viz$directional_plot)\nviz$leaflet_map\n```\n\n\u003e ⚠️ **Note on edge effects:** Grid cells located near the edges of the study area (city boundary or data clipping line) may show artificially high distances to the nearest green space. This is because green spaces located just outside the analysis boundary are not included in the calculation, leading to “edge effects” where accessibility is underestimated at the margins. To mitigate this, consider expanding the analysis boundary or including green spaces from a buffer area surrounding the city. Alternatively, interpret results for boundary cells with caution.\n\n\n---\n\n## 🌡️ Classical Urban Heat Island (UHI) Analysis\n\n*Where are the thermal hotspots — and how do they correlate with green coverage and built density?*\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"vignettes/hotspot.png\" width=\"100%\" alt=\"UHI Hotspot Analysis\" /\u003e\n\u003c/p\u003e\n\n### 🔬 Details \u0026 code\n\n### Urban Heat Island (UHI) Analysis\n\nDetect and analyze urban heat islands by integrating satellite thermal imagery with environmental data. The `analyze_and_visualize_uhi()` function automates the entire workflow from data acquisition to publication-ready outputs.\n\n#### What it does:\n- Fetches Land Surface Temperature from **Landsat 8/9** via Microsoft Planetary Computer.\n- Retrieves green spaces, trees, buildings, and water bodies from **OpenStreetMap**. Supports GHSL Built-up Surface raster for accurate built-up density estimation. If GHSL data is not provided, the function uses building data from OSM.\n- Aggregates data into **H3 hexagonal grids** for consistent spatial analysis.\n- Performs **Getis-Ord Gi* hotspot analysis** with statistical significance testing.\n- Calculates **Moran's I** spatial autocorrelation.\n- Produces interactive Leaflet maps as well as static maps.\n- Generates correlation and regression analysis between LST, green coverage, and built-up intensity. Results can also be visualized in 3D on Mapbox.\n\n```r\nresult \u003c- analyze_and_visualize_uhi(\n  location = \"Zurich, Switzerland\",\n  date_range = c(\"2023-06-01\", \"2023-08-31\"),\n  hex_resolution = 9,\n  ghsl_path = \"path/to/ghsl_built.tif\",\n  thermal_source = \"auto\",\n  composite_scenes = TRUE, # Switch to FALSE for faster computation\n  max_scenes = 5,\n  lst_percentile_filter = c(0.01, 0.99),\n  correlation_method = \"spearman\",\n  use_exactextract = TRUE\n)\n\n# Interactive map with toggleable layers\nresult$maps$interactive\n\n# Scatter plots\nresult$maps$scatter\n\n# Export results\nresult$export_results(\"zurich_uhi\", formats = c(\"geojson\", \"csv\", \"gpkg\", \"shp\"))\n```\n\n\n---\n\n## 🌴 Canopy Height Model (CHM) Analysis\n\n*What is the vertical structure of the urban tree canopy at 1-meter resolution?*\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"vignettes/chm.jpg\" width=\"100%\" alt=\"Canopy Height Model\" /\u003e\n\u003c/p\u003e\n\n### 🔬 Details \u0026 code\n\n### Canopy Height Model (CHM) Analysis with ALS GEDI Data\n\nThe `chm_analysis()` function enables robust analysis and visualization of canopy height using Meta \u0026 WRI’s global 1m ALS GEDI v6 dataset. This function automatically downloads, mosaics, and processes high-resolution canopy height raster tiles for any area of interest, defined by a city name, bounding box, GeoJSON, or user-supplied `.tif` file.\n\n- **Data Source**: Meta \u0026 WRI 1m ALS GEDI v6 global canopy height model (2024), covering most vegetated land worldwide.\n- **Features**: Computes statistics, generates publication-quality maps and interactive web maps, and quantifies tree cover above a user-defined height threshold (meters).\n- **Performance**: Processing may take significant time for large regions due to high data volume and tile downloads.\n\n*The implementation is inspired by the excellent chmloader R package, adapted for greater flexibility and integration with the greenR urban analytics workflow.*\n\n```R\n# Analyze canopy structure for Basel, Switzerland (bounding box example)\nresult \u003c- chm_analysis(\n  bbox = c(7.55, 47.54, 7.62, 47.59),     # xmin, ymin, xmax, ymax (WGS84)\n  output_dir = \"chm_output\",               # Output directory for files\n  max_tiles = 5,                           # Limit tiles for demo\n  height_threshold = 2,                    # Height threshold for tree cover stats (meters)\n  create_plots = TRUE                      # Export static and interactive maps\n)\n\n# View main outputs\nprint(result$stats)            # Summary statistics\nresult$static_map              # Publication-ready map (tmap)\nbrowseURL(result$mapview_file) # Interactive web map (HTML)\n```\n\n\n---\n\n## 📷 Green View Index (GVI)\n\n*What proportion of the visible streetscape is vegetation?*\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"vignettes/gvi.jpg\" width=\"100%\" alt=\"Green View Index\" /\u003e\n\u003c/p\u003e\n\n### 🔬 Details \u0026 code\n\n### Green View Index\n\nThis function allows the users to quantify urban greenness through image analysis. Utilizing the [SuperpixelImageSegmentation library](https://cran.r-project.org/web/packages/SuperpixelImageSegmentation/SuperpixelImageSegmentation.pdf), it reads an image of an urban landscape and segments it into superpixels. The Green View Index (GVI) is then calculated by identifying green pixels within these segments. The GVI provides an objective measure of the proportion of visible vegetation in an image and is an important indicator for understanding urban greenness and its impact on ecological and human health.\n\nThe GVI is calculated using the following formula:\n\n$$GVI = \\frac{\\text{Number of Green Pixels}}{\\text{Total Number of Pixels}}$$\n\nWhere \"Green Pixels\" are identified based on a threshold that considers the RGB values of each pixel.\n\n```R\nresult \u003c- calculate_and_visualize_GVI(\"/path/to/your/image.png\")\nOpenImageR::imageShow(result$segmented_image) # To visualize the segmented image\n\ngreen_pixels_raster \u003c- as.raster(result$green_pixels_image) # To visualize green pixels\nplot(green_pixels_raster)\n\n# Save outputs directly within R\nOpenImageR::writeImage(result$segmented_image, \"/path/to/save/segmented_image.png\")\nOpenImageR::writeImage(result$green_pixels_image, \"/path/to/save/green_pixels_image.png\")\n```\n\n\u003c/details\u003e\n\n---\n\n## ⚖️ Green Space Similarity Index (GSSI)\n\n*How do green space networks compare across different cities in size and connectivity?*\n\n\u003cdetails\u003e\n\u003csummary\u003e🔬 \u003cstrong\u003eDetails \u0026 code\u003c/strong\u003e\u003c/summary\u003e\n\n### Green Space Similarity Index (GSSI)\n\nThe `gssi()` function calculates the Green Space Similarity Index (GSSI), a composite metric for evaluating and comparing urban green spaces across different regions by analyzing their size and spatial connectivity.\n\n#### Functionality\nThis function transforms spatial data into an equal-area projection for accurate area measurements, computes the total area of green spaces, and assesses their spatial connectivity using the Average Nearest Neighbor Distance (ANND). This dual approach provides a comprehensive view of the distribution and accessibility of green spaces.\n\n#### Implementation\nThe GSSI is calculated by inversely weighting the coefficient of variation in area sizes with the ANND, offering a score that reflects the abundance and accessibility of green spaces. Scores are normalized against the highest scoring city in the dataset for relative comparisons:\n\n```r\nd1 \u003c- get_osm_data(\"New Delhi, India\")\ndsf \u003c- d1$green_areas$osm_polygons\nd2 \u003c- get_osm_data(\"Basel, Switzerland\")\nbsf \u003c- d2$green_areas$osm_polygons\nd3 \u003c- get_osm_data(\"Medellin, Colombia\")\nmsf \u003c- d3$green_areas$osm_polygons\n\ncities_data \u003c- list(dsf, bsf, msf)\ngssi_values \u003c- gssi(cities_data, \"ESRI:54009\")\n```\n\n\u003c/details\u003e\n\n---\n\n## 🖥️ Shiny Application\n\n*Analyze urban greenness without writing a single line of code.*\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"vignettes/shiny.jpg\" width=\"100%\" alt=\"Shiny Web Application\" /\u003e\n\u003c/p\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e🔬 \u003cstrong\u003eDetails \u0026 usage\u003c/strong\u003e\u003c/summary\u003e\n\nYou can make your own greenness analysis without having to code using an R Shiny implementation of the package. It is easily accessible from within R by calling the function `run_app()`:\n\n```R\nrun_app()\n```\n\n\u003c/details\u003e\n\n---\n\n# 🛠️ Reference\n\n## Citation\n\n**APA**: Mahajan, S., 2024. greenR: An open-source framework for quantifying urban greenness. *Ecological Indicators* 163, 112108. [doi:10.1016/j.ecolind.2024.112108](https://doi.org/10.1016/j.ecolind.2024.112108)\n\n\u003cdetails\u003e\n\u003csummary\u003e📋 \u003cstrong\u003eBibTeX\u003c/strong\u003e\u003c/summary\u003e\n\n```bibtex\n@article{MAHAJAN2024112108,\n  title   = {greenR: An open-source framework for quantifying urban greenness},\n  journal = {Ecological Indicators},\n  volume  = {163},\n  pages   = {112108},\n  year    = {2024},\n  issn    = {1470-160X},\n  doi     = {https://doi.org/10.1016/j.ecolind.2024.112108},\n  url     = {https://www.sciencedirect.com/science/article/pii/S1470160X2400565X},\n  author  = {Sachit Mahajan},\n  keywords = {Urban greenness, Open source, Urban analytics, Cities, Street network}\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e🔧 \u003cstrong\u003eHandling SSL certificate errors\u003c/strong\u003e\u003c/summary\u003e\n\nIf you encounter an error related to SSL certificate authentication, such as:\n```\nError in curl::curl_fetch_memory(url, handle = handle) :\n  Peer certificate cannot be authenticated with given CA certificates: SSL certificate problem: certificate has expired\n```\nIt may be necessary to update the CA certificates on your system or run the following configuration in your R session to configure R's SSL settings:\n```R\nlibrary(httr)\nhttr::set_config(config(ssl_verifypeer = 0L))\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e⚡ \u003cstrong\u003ePerformance notice\u003c/strong\u003e\u003c/summary\u003e\n\nThis package, 'greenR' provides tools to measure and visualize the 'greenness' of urban areas. It performs intensive computations that require robust computational resources, particularly when analyzing large urban networks.\n\nPlease be aware of the following:\n\n1. **Processing time:** Depending on the size of the area under analysis, computations may take a considerable amount of time. Larger areas, like whole cities or metropolitan regions, will take longer to process compared to small neighborhoods or districts.\n2. **Computational resources:** Due to the computational intensity of these tasks, it is recommended to run this package on a machine with a strong CPU and sufficient RAM. Please ensure your machine meets these requirements before starting the computation to prevent any interruptions or crashes.\n3. **Testing:** If you are using 'greenR' for the first time, or if you're testing on a new machine, it is suggested to begin with a smaller area - such as a specific neighborhood or small town. This will give you a rough idea of how long the computations might take and how well your machine can handle them.\n\n*Remember, performance can greatly vary based on the size of the network and the hardware of your machine.*\n\n\u003c/details\u003e\n\n## Acknowledgments\nOpenStreetMap data is available under the [Open Database License (ODbL)](https://opendatacommons.org/licenses/odbl/).\n","funding_links":[],"readme_doi_urls":["https://doi.org/10.1016/j.ecolind.2024.112108"],"works":{},"citation_counts":{},"total_citations":0,"keywords_from_contributors":[],"project_url":"https://ost.ecosyste.ms/api/v1/projects/60433","html_url":"https://ost.ecosyste.ms/projects/60433"}