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:
2D visibility (
objectnat.get_visibility(),objectnat.get_isovist_grid(),objectnat.get_visibility_catchment()): every obstacle is a wall of infinite height. The result for one observer is its visibility polygon (isovist), a vector polygon whose boundary is computed exactly.2.5D visibility (
objectnat.get_viewshed(),objectnat.get_viewshed_catchment()): buildings have heights, and terrain can raise the ground. The result for one observer is its viewshed, the grid cells to which the line of sight from the eye is clear, merged into one (Multi)Polygon per observer. Its outline follows the cells, so its accuracy iscell_size.
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 |
|---|---|---|
|
How much the observer sees: the area of the isovist, and this area divided by the area of the view disc, π R². |
Open field: |
|
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. |
|
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. |
|
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). |
|
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. |
|
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. |
|
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 orNone, 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 inpoint_from. IfNoneand the column is also missing, aValueErroris raised.max_workers (
int | None, optional) – Maximum number of threads (Noneuses all cores).isovist_metrics (
bool, optional) – IfTrue, 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) andopen_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 ofpoint_from. Observers inside an obstacle get an empty polygon.- Return type:
gpd.GeoDataFrame
- Raises:
TypeError – If
point_fromis not a GeoDataFrame.ValueError – If
point_fromis empty, has no CRS, or if neitherview_distancenor the"visibility_distance"column is provided.
Notes
If a column named
"visibility_distance"is present inpoint_from, its values are used as per-point view distances and theview_distanceargument is ignored.
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_sizecell ofareaoutside the obstacles, and its exact visibility polygon withinview_distanceis measured as withget_visibility(..., isovist_metrics=True). Obstacles outside the area but withinview_distanceof it still block the view.rasterize()turns any metric into aRaster, 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;Noneor empty for open ground.area (
gpd.GeoDataFrame | gpd.GeoSeries | shapely.Geometry) – Area to cover. A shapely geometry is taken in the CRS ofobstacles.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 (Noneuses all cores).
- Returns:
One observer point per open cell, in the CRS of
area(ofobstaclesfor a shapely geometry), with the isovist metric columns ofget_visibility():area,perimeter,compactness,occlusivity,n_occlusions,min_radial,max_radial,mean_radial,std_radial,skew_radial,drift,visible_shareandopen_share.attrsrecord the grid forrasterize().- Return type:
gpd.GeoDataFrame
- Raises:
ValueError – If
areahas no CRS or is empty, orview_distanceorcell_sizeis not positive.
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 withinview_distanceis split intocell_sizecells, and a cell is visible when the straight line from the eye to the cell centre (attarget_heightabove the ground) passes above every building wall it crosses and above the terrain. Visible cells are merged into one polygon per observer. The eye isobserver_heightabove the terrain; observers standing inside a building footprint are placed on its roof.- Parameters:
point_from (
geopandas.GeoDataFrame) – Observer points in any CRS. Optional columnsvisibility_distanceandobserver_heightoverrideview_distanceandobserver_heightper point; other attributes are kept.buildings (
gpd.GeoDataFrame | None) – Building footprints with heights (seeheight_column,storeys_column);Nonefor terrain only.view_distance (
float | None, optional) – View distance in metres, unlesspoint_fromhasvisibility_distance.height_column (
str|None) – Building heights, as inget_insolation().storeys_column (
str|None) – Building heights, as inget_insolation().storey_height (
float) – Building heights, as inget_insolation().default_height (
float|None) – Building heights, as inget_insolation().terrain (
GeoDataFrame|str|PathLike|tuple|None) – Ground heights, as inget_insolation(); without terrain the ground is flat.terrain_height_column (
str) – Ground heights, as inget_insolation(); without terrain the ground is flat.terrain_cell (
float) – Ground heights, as inget_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 toFalse: building footprints are left out.max_workers (
int | None, optional) – Number of threads (Noneuses all cores).
- Returns:
Same index and attributes as
point_fromwith the geometry replaced by the visible area (cells merged into polygons, an empty polygon when nothing is visible) in the CRS ofpoint_from, plusvisible_area(m²) andvisible_share(the share of the target cells within the view distance that are visible).- Return type:
gpd.GeoDataFrame
- Raises:
ValueError – If
point_fromis empty or has no CRS, or no view distance is given.
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:
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 aboutspacingmetres and puts a point in the middle of each piece. Any points will do.Grid. The area within
view_distanceof the observers is divided into square cells ofcell_sizemetres.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 fromweight_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.Result. The cells that at least one observer sees are returned as points at the cell centres with their
count(andweight); 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_distanceof the observers is split into square cells. A cell counts an observer when its centre lies inside the observer’s exact visibility polygon (seeget_visibility()); withweight_columnit sums the observers’ weights instead. With observers placed densely along streets (seeget_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 aRaster.- Parameters:
observers (
geopandas.GeoDataFrame) – Observer points with a CRS.obstacles (
gpd.GeoDataFrame | None) – Obstacle geometries (Polygon, MultiPolygon, LineString, MultiLineString) in any CRS.Noneor an empty frame means no occlusion.view_distance (
float | None, optional) – View distance of every observer, in metres. Used whenobservershas 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 (Noneuses all cores).
- Returns:
The cells seen by at least one observer, as points at the cell centres in the CRS of
observers, withcount(the number of observers that see the cell) and, withweight_column,weight(the sum of their weights). Cells seen by nobody, including cells inside obstacles, are left out.attrsrecord the grid, sorasterize()rebuilds it exactly.- Return type:
gpd.GeoDataFrame
- Raises:
TypeError – If
observersis not a GeoDataFrame.ValueError – If
observersis empty or has no CRS, if no view distance is given, ifcell_sizeis invalid, ifweight_columnis 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 attarget_heightis clear, as inget_viewshed(). Observers stand on the ground with their eyesobserver_heightabove the terrain; observers inside a building footprint are left out. Withinclude_roofsroof 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. fromget_observer_points(). Optional columnsvisibility_distanceandobserver_heightoverrideview_distanceandobserver_heightper point.buildings (
gpd.GeoDataFrame | None) – Building footprints with heights;Nonefor terrain only.view_distance (
float | None, optional) – View distance in metres, unlessobservershasvisibility_distance.height_column (
str|None) – Building heights, as inget_insolation().storeys_column (
str|None) – Building heights, as inget_insolation().storey_height (
float) – Building heights, as inget_insolation().default_height (
float|None) – Building heights, as inget_insolation().terrain (
GeoDataFrame|str|PathLike|tuple|None) – Ground heights, as inget_insolation().terrain_height_column (
str) – Ground heights, as inget_insolation().terrain_cell (
float) – Ground heights, as inget_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 toFalse.weight_column (
str | None, optional) – Observer weights, as inget_visibility_catchment().max_workers (
int | None, optional) – Number of threads (Noneuses all cores).
- Returns:
The cells seen by at least one observer, as points at the cell centres in the CRS of
observers, withcount(andweight), as inget_visibility_catchment();rasterize()turns them into aRaster.- 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
spacingmetres 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 forget_visibility_catchment().- Return type:
gpd.GeoDataFrame
- Raises:
ValueError – If
spacingis not positive or the graph has no edge geometries.
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).