Visibility Analysis

Overview

Visibility analysis determines which parts of the urban space an observer can see and, aggregated over many observers, how often each place is seen. ObjectNat provides two models:

The catchment functions count, for every cell of a grid, the observers that see it; the counts are drawn as a raster. objectnat.get_observer_points() places observers along the streets of an IduEdu graph. All calculations run in parallel threads in ObjectNat’s Rust extension.

Grid results answer two different questions, and their values have different units. An isovist field (objectnat.get_isovist_grid()) describes what an observer standing in each cell sees, for example the visible share of the view disc: it looks out of the place. A catchment counts the observers that see each cell: it looks at the place from the streets. Its unit is the number of observers (or the sum of their weights) in 2D and in 2.5D alike. The middle of a large square has a high visible share, but a low catchment if few streets lead to it.

2D visibility polygons

Method

objectnat.get_visibility() returns, for each observer, the part of the view disc (radius view_distance or the per-observer column visibility_distance, in metres) that is not hidden behind obstacle walls. Obstacles may be polygons (with holes) or lines. Observers and obstacles are reprojected to an estimated UTM zone. Obstacle walls are clipped to the disc, every wall endpoint and wall intersection defines a critical direction, and one ray per angular interval finds the nearest wall. The boundary is therefore exact; no rays are sampled at fixed angles. Observers standing inside an obstacle get an empty polygon.

Isovist metrics

An isovist is the visibility polygon of one observer. With isovist_metrics=True, objectnat.get_visibility() describes every isovist with the measures below (Benedikt 1979; Turner et al. 2001; Batty 2001): how much the observer sees, what shape the visible area has and how much space is hidden behind corners. Lengths are in metres and areas in square metres; observers inside an obstacle get NaN.

The boundary of an isovist consists of three kinds of edges: the visible parts of walls, arcs of the view limit (the circle of radius view_distance) and occluding edges. An occluding edge lies on a line of sight that passes a building corner. Beyond the corner the line of sight continues into space that the observer cannot see, so the edge separates the visible area from a hidden one.

The examples in the table use a view distance R = 200 m and three simple places: an open field without obstacles, the middle of a straight street 20 m wide between continuous walls, and a closed square courtyard 40 m wide.

Columns

What they measure

Examples

area, visible_share

How much the observer sees: the area of the isovist, and this area divided by the area of the view disc, π R².

Open field: visible_share = 1. Street: a strip of about 20 × 400 m, so area ≈ 8,000 m² and visible_share ≈ 0.06.

perimeter, compactness

The length of the isovist boundary, and 4πA/P², which compares the shape with a circle: 1 for a disc, close to 0 for a long narrow or spiky shape.

Open field: 1. Courtyard seen from inside: π/4 ≈ 0.79. Street: ≈ 0.14.

n_occlusions, occlusivity

The number of occluding edges and their total length: how many corners the observer sees past, and how far the hidden space extends behind them.

Open field, street and courtyard: 0, since nothing is hidden. One building in an open field: two edges, the sides of its shadow. Crossings of narrow passages between buildings: high values.

min_radial, max_radial

The distance from the observer to the nearest point of the boundary, usually the nearest wall, and the length of the longest line of sight.

Street: 10 m (the walls) and 200 m (along the street).

mean_radial, std_radial, skew_radial

The distance from the observer to the end of the view (a wall, an occluding edge or the view limit) over all directions: its mean, standard deviation and skewness. They are integrated exactly over each boundary edge.

Open field: mean 200 m, standard deviation 0. Street: mean ≈ 30 m and standard deviation ≈ 41 m; the skewness is positive, because a few long views along the street stand out among many short views to the walls.

drift

The distance from the observer to the centroid of the isovist: 0 when the visible area is balanced around the observer, large when most of it lies to one side.

Centre of the courtyard: 0. Next to the middle of one courtyard wall: 20 m.

open_share

The share of the boundary length that lies on the view limit, that is, on neither walls nor occluding edges.

Open field: 1. Courtyard: 0. Street: the two ends of the strip, 40 m of the 840 m boundary, ≈ 0.05.

The metrics add little time to the visibility calculation (about 0.8 s for 5,000 visibility polygons with 450,000 vertices in total).

objectnat.get_visibility(point_from, obstacles, view_distance=None, *, max_workers=None, isovist_metrics=False)[source]

Compute visibility polygons for one or many observer points.

Each observer gets the exact area visible within its view distance: the view disc minus everything hidden behind obstacle walls. Points and obstacles are reprojected to a locally estimated projected CRS (typically UTM) for the calculation, and observers are processed in parallel by ObjectNat’s Rust extension.

Parameters:
  • point_from (geopandas.GeoDataFrame) – GeoDataFrame with point geometries representing observer locations. Must have a valid CRS. Any additional attributes are preserved in the output.

  • obstacles (geopandas.GeoDataFrame) – GeoDataFrame with obstacle geometries (Polygon, MultiPolygon, LineString, MultiLineString) in any CRS. If empty or None, no occlusion is applied and visibility is limited only by the view distance.

  • view_distance (float | None, optional) – Global view distance for all points (in metres). Used when the "visibility_distance" column is not present in point_from. If None and the column is also missing, a ValueError is raised.

  • max_workers (int | None, optional) – Maximum number of threads (None uses all cores).

  • isovist_metrics (bool, optional) – If True, add isovist metric columns to the result, measured in metres in the local CRS: area, perimeter, compactness (4πA/P², 1 for the full disc), occlusivity (total length of the occluding edges), n_occlusions, min_radial, max_radial, mean_radial, std_radial, skew_radial (moments of the distance to the boundary over all directions, integrated exactly), drift (distance from the observer to the centroid), visible_share (area / area of the view disc) and open_share (share of the boundary on the view limit). Observers inside an obstacle get NaN.

Returns:

GeoDataFrame with the same index and attributes as point_from, but with the geometry column replaced by visibility polygons. The result is returned in the original CRS of point_from. Observers inside an obstacle get an empty polygon.

Return type:

gpd.GeoDataFrame

Raises:
  • TypeError – If point_from is not a GeoDataFrame.

  • ValueError – If point_from is empty, has no CRS, or if neither view_distance nor the "visibility_distance" column is provided.

Notes

If a column named "visibility_distance" is present in point_from, its values are used as per-point view distances and the view_distance argument is ignored.

Visibility polygons of one observer and of three observers with different radii

Left: visibility polygon of one observer within 800 m among the example buildings. Right: three observers with visibility_distance 300, 500 and 800 m.

Isovist field

objectnat.get_isovist_grid() maps the metrics over an area. It places an observer at the centre of every cell_size cell of the area outside the obstacles, computes the exact isovist of each observer and its metrics, and returns the observers as points with the metric columns. Obstacles outside the area but within view_distance of it still block the view. Every value is exact for its observer; the grid only sets where the observers stand. objectnat.rasterize() turns any metric into a raster (see Rasters), which shows for every place what an observer standing there would see. Time is proportional to the number of observers: the field below, 7,889 observers with a view distance of 200 m, takes 0.7 s.

The field has no edge effect: a value describes its own observer only, and buildings outside the area are taken into account. For observers placed in another way, for example along the streets, compute the same metrics with objectnat.get_visibility():

from objectnat import get_observer_points, get_visibility

observers = get_observer_points(walk_graph, spacing=15)            # a point every 15 m along the streets
metrics = get_visibility(observers, buildings, view_distance=200, isovist_metrics=True)
metrics.set_geometry(observers.geometry).plot(column="visible_share", markersize=4)
objectnat.get_isovist_grid(obstacles, area, *, view_distance=200.0, cell_size=5.0, max_workers=None)[source]

Isovist metrics on a regular grid of observers covering the open ground of an area (an isovist field).

An observer is placed at the centre of every cell_size cell of area outside the obstacles, and its exact visibility polygon within view_distance is measured as with get_visibility(..., isovist_metrics=True). Obstacles outside the area but within view_distance of it still block the view. rasterize() turns any metric into a Raster, which shows how openness, compactness or occlusion change across the area.

Parameters:
  • obstacles (gpd.GeoDataFrame | None) – Obstacle geometries (Polygon, MultiPolygon, LineString, MultiLineString) in any CRS; None or empty for open ground.

  • area (gpd.GeoDataFrame | gpd.GeoSeries | shapely.Geometry) – Area to cover. A shapely geometry is taken in the CRS of obstacles.

  • view_distance (float, optional) – View distance of every observer in metres. Defaults to 200.

  • cell_size (float, optional) – Observer spacing in metres. Time grows with (area / cell_size²) * view_distance. Defaults to 5.

  • max_workers (int | None, optional) – Number of threads (None uses all cores).

Returns:

One observer point per open cell, in the CRS of area (of obstacles for a shapely geometry), with the isovist metric columns of get_visibility(): area, perimeter, compactness, occlusivity, n_occlusions, min_radial, max_radial, mean_radial, std_radial, skew_radial, drift, visible_share and open_share. attrs record the grid for rasterize().

Return type:

gpd.GeoDataFrame

Raises:

ValueError – If area has no CRS or is empty, or view_distance or cell_size is not positive.

Maps of four isovist metrics

get_isovist_grid(buildings, area, view_distance=200, cell_size=5) over a 500 × 500 m area (outlined) and objectnat.rasterize() of four metrics: the visible share of the 200 m disc, compactness 4πA/P², the total length of occluding edges and drift. Colour scales span the 2nd–98th percentiles. Most of the disc is in view in the open space in the south; compactness is high there and inside closed courtyards; occluding edges are longest where passages between buildings cross; drift is large next to walls that face open space.

2.5D viewsheds

Method

objectnat.get_viewshed() uses building heights and terrain. The eye of an observer is observer_height (default 1.6 m) above the terrain or, for an observer inside a building footprint, above the roof. The area within the view distance is divided into square cells of cell_size metres. A cell is visible when the straight line from the eye to the cell centre at target_height above the ground (0 m for the ground surface, about 1.6 m for people’s faces) passes above every wall it crosses and above the terrain. Visible cells are merged into one (Multi)Polygon per observer. With include_roofs=True cells on flat roofs are targets too, at the roof height. Building heights and terrain are specified as for objectnat.get_insolation() (a height or storeys column; a terrain GeoDataFrame, GeoTIFF or array), and the line-of-sight test shares its Rust implementation with insolation.

The output keeps the index and attributes of the observers and adds visible_area (m²) and visible_share, the share of target cells within the view distance that are visible, the 2.5D counterpart of the isovist metric of the same name. visibility_distance and observer_height columns override the arguments per observer. Computation time grows with (view_distance / cell_size) ** 2 per observer.

For an observer on flat ground whose eye is lower than all surrounding buildings, the viewshed coincides with the 2D visibility polygon up to the cell size. The two differ where buildings are lower than the line of sight: from a roof, from a hill, or when the target is above the ground (target_height).

objectnat.get_viewshed(point_from, buildings, view_distance=None, *, height_column='height', storeys_column=None, storey_height=3.0, default_height=None, terrain=None, terrain_height_column='height', terrain_cell=5.0, observer_height=1.6, target_height=0.0, cell_size=2.0, include_roofs=False, max_workers=None)[source]

Compute 2.5D visibility: the ground (and optionally the roofs) each observer can see from its eye height, among buildings of known height and terrain.

Unlike get_visibility(), which treats every obstacle as infinitely high, here a low building or a hill hides only what lies below the line of sight: an observer sees over a garage onto the street behind it, from a hill over the roofs, from a tower far across the district. The area within view_distance is split into cell_size cells, and a cell is visible when the straight line from the eye to the cell centre (at target_height above the ground) passes above every building wall it crosses and above the terrain. Visible cells are merged into one polygon per observer. The eye is observer_height above the terrain; observers standing inside a building footprint are placed on its roof.

Parameters:
  • point_from (geopandas.GeoDataFrame) – Observer points in any CRS. Optional columns visibility_distance and observer_height override view_distance and observer_height per point; other attributes are kept.

  • buildings (gpd.GeoDataFrame | None) – Building footprints with heights (see height_column, storeys_column); None for terrain only.

  • view_distance (float | None, optional) – View distance in metres, unless point_from has visibility_distance.

  • height_column (str | None) – Building heights, as in get_insolation().

  • storeys_column (str | None) – Building heights, as in get_insolation().

  • storey_height (float) – Building heights, as in get_insolation().

  • default_height (float | None) – Building heights, as in get_insolation().

  • terrain (GeoDataFrame | str | PathLike | tuple | None) – Ground heights, as in get_insolation(); without terrain the ground is flat.

  • terrain_height_column (str) – Ground heights, as in get_insolation(); without terrain the ground is flat.

  • terrain_cell (float) – Ground heights, as in get_insolation(); without terrain the ground is flat.

  • observer_height (float, optional) – Eye height above the terrain (or the roof) in metres. Defaults to 1.6.

  • target_height (float, optional) – Height above the ground of what is looked at, in metres: 0 for the ground itself, 1.6 to see people’s faces, more for the upper part of objects. Defaults to 0.

  • cell_size (float, optional) – Cell size in metres; time grows with (view_distance / cell_size) ** 2. Defaults to 2.

  • include_roofs (bool, optional) – Also return the parts of roofs that can be seen (flat roofs at the building height). Defaults to False: building footprints are left out.

  • max_workers (int | None, optional) – Number of threads (None uses all cores).

Returns:

Same index and attributes as point_from with the geometry replaced by the visible area (cells merged into polygons, an empty polygon when nothing is visible) in the CRS of point_from, plus visible_area (m²) and visible_share (the share of the target cells within the view distance that are visible).

Return type:

gpd.GeoDataFrame

Raises:

ValueError – If point_from is empty or has no CRS, or no view distance is given.

2D visibility polygon, street-level viewshed and roof-level viewshed

One observer on a street: 2D visibility polygon (left) and 2.5D viewshed at 1.6 m eye height (centre), both 2.8 ha within 300 m (dotted circle). Right: an observer on the roof edge of a 17-storey building, include_roofs=True; the viewshed covers 9.6 ha of ground and roofs. Grey shades show building height; cell_size=2.

Visibility catchment

Method

objectnat.get_visibility_catchment() answers the question from how many places is this place seen? It takes a set of observers, for example pedestrians every 15 m along the streets, and counts for every small piece of the area how many of them can see it:

  1. Observers. objectnat.get_observer_points() places them along the streets of a graph: it splits every street edge (on walk and intermodal graphs, every pedestrian edge) into pieces of about spacing metres and puts a point in the middle of each piece. Any points will do.

  2. Grid. The area within view_distance of the observers is divided into square cells of cell_size metres.

  3. Counting. For every observer the visibility polygon is computed as in objectnat.get_visibility(), and every cell whose centre lies inside it gets one more observer (or the observer’s weight from weight_column, for example pedestrian flow). The value of a cell is therefore the number of observers that see it. The polygons are only counted, not returned, which keeps memory low.

  4. Result. The cells that at least one observer sees are returned as points at the cell centres with their count (and weight); cells inside buildings and cells nobody sees are left out. objectnat.rasterize() turns them back into the grid, a raster that shows the counts as a continuous colour scale.

For example, with observers every 15 m and a view distance of 250 m, a square that several streets open onto is seen by a hundred observers or more, and a closed courtyard only by the few observers inside it.

Place observers beyond the analysed area. A cell near the edge of the area is also seen by observers outside it, up to view_distance away. If the observers stop at the boundary of the area, the counts near the boundary come out too low. Place observers over the area extended by view_distance and clip the result to the area.

Time and memory grow with the number of cells. Counts are in observers, so two areas or two scenarios with the same observer spacing can be drawn on one colour scale. Visibility is symmetric, so the value of a cell is also the number of observers visible from that cell.

objectnat.get_viewshed_catchment() is the 2.5D counterpart: a cell counts an observer when the line of sight from the observer’s eye to the cell target is clear, as in objectnat.get_viewshed(). Observers inside building footprints are left out. Building footprints are rasterized once, and the lines of sight of all observers are counted in the Rust extension. With include_roofs=True roof cells are counted too; roofs are seen from street level only where the terrain or observer_height lifts the eye above them.

objectnat.get_visibility_catchment(observers, obstacles, *, view_distance=None, cell_size=5.0, weight_column=None, max_workers=None)[source]

Count, for every place around the observers, how many of them see it (the visibility catchment).

The area within view_distance of the observers is split into square cells. A cell counts an observer when its centre lies inside the observer’s exact visibility polygon (see get_visibility()); with weight_column it sums the observers’ weights instead. With observers placed densely along streets (see get_observer_points()) the counts show where objects are seen from most often: the visual catchment of facades, squares and landmarks. rasterize() turns the result into a Raster.

Parameters:
  • observers (geopandas.GeoDataFrame) – Observer points with a CRS.

  • obstacles (gpd.GeoDataFrame | None) – Obstacle geometries (Polygon, MultiPolygon, LineString, MultiLineString) in any CRS. None or an empty frame means no occlusion.

  • view_distance (float | None, optional) – View distance of every observer, in metres. Used when observers has no "visibility_distance" column; one of the two is required.

  • cell_size (float, optional) – Cell side in metres. Halving it gives four times as many cells, and memory and time grow with them.

  • weight_column (str | None, optional) – Column of non-negative observer weights (e.g. pedestrian flow). Cells then sum the weights of the observers that see them instead of counting them. Observers with zero or missing weight are ignored.

  • max_workers (int | None, optional) – Number of threads (None uses all cores).

Returns:

The cells seen by at least one observer, as points at the cell centres in the CRS of observers, with count (the number of observers that see the cell) and, with weight_column, weight (the sum of their weights). Cells seen by nobody, including cells inside obstacles, are left out. attrs record the grid, so rasterize() rebuilds it exactly.

Return type:

gpd.GeoDataFrame

Raises:
  • TypeError – If observers is not a GeoDataFrame.

  • ValueError – If observers is empty or has no CRS, if no view distance is given, if cell_size is invalid, if weight_column is missing or contains negative values, or if the grid would exceed 200 million cells.

Notes

Visibility is symmetric, so the value of a cell is also the number of observers visible from it.

objectnat.get_viewshed_catchment(observers, buildings, *, view_distance=None, height_column='height', storeys_column=None, storey_height=3.0, default_height=None, terrain=None, terrain_height_column='height', terrain_cell=5.0, observer_height=1.6, target_height=0.0, cell_size=5.0, include_roofs=False, weight_column=None, max_workers=None)[source]

Count, for every place around the observers, how many of them see it, over buildings of known height and terrain (the 2.5D visibility catchment).

The 2.5D counterpart of get_visibility_catchment(): every cell around the observers gets the number of observers (or the sum of their weights) whose line of sight to the cell centre at target_height is clear, as in get_viewshed(). Observers stand on the ground with their eyes observer_height above the terrain; observers inside a building footprint are left out. With include_roofs roof cells are counted too, which shows the roofs and building tops seen from the streets.

Parameters:
  • observers (geopandas.GeoDataFrame) – Observer points with a CRS, e.g. from get_observer_points(). Optional columns visibility_distance and observer_height override view_distance and observer_height per point.

  • buildings (gpd.GeoDataFrame | None) – Building footprints with heights; None for terrain only.

  • view_distance (float | None, optional) – View distance in metres, unless observers has visibility_distance.

  • height_column (str | None) – Building heights, as in get_insolation().

  • storeys_column (str | None) – Building heights, as in get_insolation().

  • storey_height (float) – Building heights, as in get_insolation().

  • default_height (float | None) – Building heights, as in get_insolation().

  • terrain (GeoDataFrame | str | PathLike | tuple | None) – Ground heights, as in get_insolation().

  • terrain_height_column (str) – Ground heights, as in get_insolation().

  • terrain_cell (float) – Ground heights, as in get_insolation().

  • observer_height (float, optional) – Eye height above the terrain in metres. Defaults to 1.6.

  • target_height (float, optional) – Height above the ground of what is looked at, in metres. Defaults to 0.

  • cell_size (float, optional) – Cell side in metres. Defaults to 5.

  • include_roofs (bool, optional) – Count roof cells too. Defaults to False.

  • weight_column (str | None, optional) – Observer weights, as in get_visibility_catchment().

  • max_workers (int | None, optional) – Number of threads (None uses all cores).

Returns:

The cells seen by at least one observer, as points at the cell centres in the CRS of observers, with count (and weight), as in get_visibility_catchment(); rasterize() turns them into a Raster.

Return type:

gpd.GeoDataFrame

Raises:

ValueError – On empty observers, a missing view distance, bad weights or a grid larger than 30 million cells.

objectnat.get_observer_points(urban_graph, *, spacing=15.0)[source]

Place observer points evenly along the streets of a graph.

Each street segment (an edge, counted once for both directions) is split into pieces of about spacing metres and gets one point in the middle of every piece, so points never pile up at intersections. Walk and intermodal graphs use their pedestrian (type == "walk") edges only.

Parameters:
  • urban_graph (UrbanGraph) – Street graph from IduEdu.

  • spacing (float, optional) – Target distance between neighbouring points in metres.

Returns:

Points in the CRS of urban_graph, ready for get_visibility_catchment().

Return type:

gpd.GeoDataFrame

Raises:

ValueError – If spacing is not positive or the graph has no edge geometries.

2D visibility catchment and 2.5D viewshed catchment

Number of observers that see each cell: 1,805 observers on open ground within 12 m of buildings, placed over the shown area extended by the view distance, view_distance=250, cell_size=4, the counts rasterized with objectnat.rasterize() on one colour scale. Left: 2D. Right: 2.5D with target_height=10, the number of observers that see a point 10 m above the ground. Such a point is seen over buildings lower than the line of sight, so more observers see it.

Limitations

  • 2D visibility ignores heights: low walls, fences and garages block the view as tall buildings do.

  • 2.5D viewsheds use flat roofs and vertical walls; trees, street furniture and pitched roofs are not modelled. Results are discrete at cell_size.

  • Neither model accounts for atmospheric conditions, lighting or the visual acuity of the observer; a cell is visible if the geometric line of sight is clear within the view distance.

Example notebooks

2D visibility: visibility polygons, isovist metrics and catchment (2D visibility, isovist metrics, catchment) and 2.5D visibility: viewsheds and viewshed catchment (2.5D viewsheds and viewshed catchment).