skyview

Sky view factor, topographic openness and street-canyon H/W metrics from DSM rasters or building footprints, validated against Oke's analytic canyon formula.

Version 0.1.2 · Python >=3.9 · MIT licence
pip install skyview
PyPISourceIssuesChangelogCite (DOI)

skyview

PyPI version Python versions pipeline status License: MIT DOI Downloads

Sky view factor and street-canyon geometry for urban planning and urban climate work.

skyview measures how much sky is visible from the ground and how enclosed streets are. It works from either a gridded surface model or from building footprints with heights:

numpy is the only required dependency. GeoTIFF reading and writing uses the optional raster extra (rasterio).

For hours of direct sun and building shadows, use the companion package urbanshadow. It works from the same footprints-and-heights input.

pip install skyview            # numpy only
pip install "skyview[raster]"  # + GeoTIFF I/O via rasterio

Requires Python 3.9 or newer.


Quick start (Python)

import numpy as np
from skyview import Building, BuildingSet, canyon_svf, sky_view_factor, street_canyon

# Closed form: centre of an infinite canyon with H/W = 1 (Oke 1981)
canyon_svf(1.0)                      # 0.4472  (cosine-weighted)
canyon_svf(1.0, "isotropic")         # 0.2952

# Raster: 1 m building-height grid
dsm = np.zeros((200, 200))
dsm[50:150, 60:90] = 24.0
svf = sky_view_factor(dsm, pixel_size=1.0, n_directions=32, max_radius=150.0)

# Footprints: exact horizon at points
blocks = BuildingSet([
    Building.box(-40, -300, -10, 300, 18.0),
    Building.box(10, -300, 40, 300, 18.0),
])
blocks.sky_view_factor([0.0, 5.0], [0.0, 0.0], n_directions=360, weighting="cosine")

# Street canyon along a centreline
c = street_canyon([(0, -250), (0, 250)], blocks, spacing=25.0)
c.width_mean, c.height_mean, c.hw_mean, c.bearing    # 20.0, 18.0, 0.9, 0.0

See examples/quickstart.py for the same canyon computed in three ways.

Quick start (command line)

# SVF raster from a DSM (GeoTIFF needs the raster extra; .npy needs --pixel-size)
skyview raster dsm.tif -o svf.tif --directions 32 --radius 100 --weighting isotropic

# Positive and negative openness
skyview openness dsm.tif -o openness_pos.tif --negative openness_neg.tif

# SVF at points, or on a grid over the buildings (projected GeoJSON, metres)
skyview points buildings.geojson --points sensors.geojson -o sensors_svf.geojson
skyview points buildings.geojson --grid 5 --observer-height 1.1 -o grid_svf.geojson

# H/W and orientation for street centrelines
skyview streets buildings.geojson streets.geojson -o canyons.geojson

# Analytic reference values for a canyon
skyview canyon 1.0

Building heights come from --height-field (default height). Storey counts can be used instead with --levels-field and --floor-height. --default-height fills any gaps.

API overview

Function / class What it does
sky_view_factor(dsm, pixel_size, n_directions, max_radius, weighting, observer_height, edge) SVF of every raster cell
horizon_angles(...), elevation_angle_extremes(...) horizon angle stack (n_dir, rows, cols)
svf_from_horizon(angles, weighting) SVF from your own horizon angles
openness(dsm, pixel_size, n_directions=8, max_radius) positive / negative openness, degrees
Building, BuildingSet, buildings_from_geojson(...) footprint prisms and fast edge arrays
BuildingSet.sky_view_factor(x, y, ...), BuildingSet.horizon_angles(x, y, ...) exact vector SVF at points
point_grid, points_in_buildings, rasterize_buildings grids, masks, footprints to a height raster
canyon_svf(hw, weighting, position), canyon_floor_mean_svf, canyon_wall_mean_svf, canyon_horizon_angle analytic canyon
street_canyon, street_canyons → StreetCanyon width, height, H/W, enclosure, bearing per street
orientation_histogram, orientation_entropy, orientation_order street orientation statistics
read_raster, write_raster, read_geojson, write_geojson, points_to_geojson, canyons_to_geojson I/O

Method and sources

Horizon search (raster). Zakšek, Oštir and Kokalj (2011), Remote Sensing 3(2), 398–415, https://doi.org/10.3390/rs3020398, describe the search. From every cell, rays are cast in n_directions azimuths, measured clockwise from grid north, out to max_radius. Along each ray the elevation angle atan((z − z0)/d) is computed for every visited cell, and the maximum is the horizon angle γᵢ. The visited cells are those hit by sampling the ray every pixel and rounding to the nearest cell. d is the exact distance between the two cell centres.

Two SVF definitions.

Both follow from integrating over the visible part of each azimuth slice: ∫ cos e de and ∫ 2 sin e cos e de from γ to 90°. Horizon angles below 0 are clamped, so SVF ≤ 1.

Analytic canyon (skyview.analytic), for an infinite canyon of height H and width W:

The test suite checks these closed forms against numerical integration of the horizon profile. It also checks that floor and wall factors close the energy balance of the canyon opening.

Openness. Yokoyama, R., Shirasawa, M. and Pike, R. J. (2002), Photogrammetric Engineering & Remote Sensing 68(3), 257–265. Positive openness is the mean of 90° − max elevation angle over the directions, and negative openness is the mean of 90° + min elevation angle. Both equal 90° on flat ground.

Vector horizon. Each ray is intersected with every footprint edge. A building prism has a constant height, so its highest elevation angle along a ray is at the edge where the ray enters it. Taking the maximum over all edge crossings is therefore exact for flat ground and prismatic buildings.

Street canyons. Stations are placed every spacing metres along a centreline. Perpendicular rays find the first building on each side within max_distance. Per station, W = d_left + d_right, H = (h_left + h_right)/2, and the aspect ratio is H/W, the main canyon descriptor in Oke (1988), Energy and Buildings 11, 103–113. The summary also gives svf_oke, Oke's centre-line SVF for the mean H/W, which is an idealised estimate.

Street orientation. Boeing, G. (2019), Applied Network Science 4, 67, https://doi.org/10.1007/s41109-019-0189-1. The method uses 36 bins of 10° centred on 0°, 10°, … . Each segment is counted in both directions, weighted by length by default. The entropy is H = −Σ P ln P, and the orientation order is φ = 1 − ((H − ln 4)/(ln 36 − ln 4))².

Validation

Limitations

Academic citation

@software{eminoglu_skyview,
  author  = {Eminoğlu, Yusuf},
  title   = {skyview},
  year    = {2026},
  version = {0.1.2},
  doi     = {10.5281/zenodo.24122219},
  url     = {https://gitlab.com/geophilo1/skyview_sdk}
}

Related Geophilo SDKs

License

MIT. See LICENSE.

Other Geophilo SDKs