xrspatial.sky_view_factor.sky_view_factor#

xrspatial.sky_view_factor.sky_view_factor(agg: DataArray, max_radius: int = 10, n_directions: int = 16, name: str | None = 'sky_view_factor') DataArray[source]#

Compute the sky-view factor for each cell of a DEM.

SVF measures the fraction of the sky hemisphere visible from each cell on a scale from 0 (fully obstructed) to 1 (flat open terrain). Rays are cast at n_directions evenly spaced azimuths out to max_radius cells, and the maximum elevation angle along each ray determines the horizon obstruction.

Parameters:
  • agg (xarray.DataArray or xr.Dataset) – 2D NumPy, CuPy, NumPy-backed Dask, or CuPy-backed Dask xarray DataArray of elevation values. If a Dataset is passed, the operation is applied to each data variable independently.

  • max_radius (int, default=10) – Maximum search distance in cells along each ray direction. Cells within max_radius of the raster edge will be NaN.

  • n_directions (int, default=16) – Number of azimuth directions to sample, evenly spaced around 360 degrees.

  • name (str, default='sky_view_factor') – Name of the output DataArray.

Returns:

2D array of SVF values in [0, 1] with the same shape, coords, dims, and attrs as the input. Edge cells use truncated rays that stop at the raster boundary.

Return type:

xarray.DataArray or xr.Dataset

References

Zakek, K., Ostir, K., Kokalj, Z. (2011). Sky-View Factor as a Relief Visualization Technique. Remote Sensing, 3(2), 398-415.

Examples

>>> from xrspatial import sky_view_factor
>>> svf = sky_view_factor(dem, max_radius=100, n_directions=16)