Package 'GeoDensityR'

Title: Generate Density Rasters from Polygon and Census Data
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/>.
Authors: Sahal Paladan [aut, cre]
Maintainer: Sahal Paladan <[email protected]>
License: MIT + file LICENSE
Version: 0.1.2
Built: 2026-06-06 07:17:13 UTC
Source: https://github.com/sahalpaladan/geodensityr

Help Index


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"
  )
}