| Type: | Package |
| Title: | Generate Density Rasters from Polygon and Census Data |
| Version: | 0.1.2 |
| Description: | Creates density rasters from polygon vector data and tabular census or survey data. The package joins polygon boundaries with attribute data, calculates densities, rasterizes outputs, and exports ASCII Grid or GeoTiff rasters. Methods are based on spatial rasterization workflows implemented in the 'terra' package Hijmans (2025) https://rspatial.github.io/terra/. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.1.0) |
| Imports: | terra |
| Suggests: | testthat, knitr, rmarkdown |
| URL: | https://github.com/sahalpaladan/GeoDensityR |
| BugReports: | https://github.com/sahalpaladan/GeoDensityR/issues |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-06-01 07:30:55 UTC; dell |
| Author: | Sahal Paladan [aut, cre] |
| Maintainer: | Sahal Paladan <sahalpaladan@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-06-05 15:00:22 UTC |
Generate Density Raster from Polygon and Tabular Data
Description
Creates a density raster by joining polygon attributes with tabular data and calculating density as: value / polygon area.
Usage
generate_density_raster(
csv_file,
shp_file,
join_shp,
join_csv,
value_col,
resolution = 0.1,
output = "density.asc"
)
Arguments
csv_file |
Path to CSV file. |
shp_file |
Path to polygon shapefile (.shp). |
join_shp |
Join column in shapefile. |
join_csv |
Join column in CSV. |
value_col |
Numeric column used for density calculation. |
resolution |
Output raster resolution. |
output |
Output raster filename (.asc or .tif). |
Value
A terra SpatRaster object.
Examples
if (file.exists("population.csv") &&
file.exists("districts.shp")) {
generate_density_raster(
csv_file = "population.csv",
shp_file = "districts.shp",
join_shp = "District",
join_csv = "District",
value_col = "Population",
resolution = 0.1,
output = "density.asc"
)
}