Package {GeoDensityR}


Type: Package
Title: Generate Density Rasters from Polygon and Census Data
Version: 0.2.0
Description: Creates continuous density raster surfaces by joining vector spatial layers with tabular data frameworks, normalizing values by ellipsoidal polygon area calculations. Reconciles discrete boundary-constrained census or survey counts with uniform grids. Accepts spatial objects in-memory or via file paths. 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, tools
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-07-24 07:08:51 UTC; dell
Author: Sahal Paladan [aut, cre]
Maintainer: Sahal Paladan <sahalpaladan@gmail.com>
Repository: CRAN
Date/Publication: 2026-07-24 07:30:02 UTC

Generate Density Raster from Polygon and Tabular Data

Description

Creates a continuous density raster surface by joining vector spatial layers with tabular data frameworks, normalizing values by ellipsoidal polygon area calculations.

Usage

generate_density_raster(
  spatial_target,
  attribute_table,
  join_spatial,
  join_attribute,
  value_col,
  resolution = 0.1,
  output = NULL
)

Arguments

spatial_target

A terra::SpatVector, sf::sf object, or a path string to a shapefile.

attribute_table

A data.frame, tibble, or path string to a CSV file.

join_spatial

Character. The indexing key column found within the spatial vector object.

join_attribute

Character. The indexing key column found within the attribute table.

value_col

Character. Numeric column containing values to evaluate for density calculation.

resolution

Numeric. The cell size resolution for the generated target output raster template.

output

Optional character. A target filepath string (.tif or .asc) to write the raster to disk.

Value

A terra::SpatRaster object representing computed density surfaces.

Examples

## Not run: 
# Example using in-memory data frames and vectors
result <- generate_density_raster(
  spatial_target = standard_polygon_object,
  attribute_table = census_dataframe,
  join_spatial = "District_ID",
  join_attribute = "ID",
  value_col = "Population",
  resolution = 0.05
)

## End(Not run)