Open In Colab

Visibility from OSM data

Generate a visibility analysis from OpenStreetMap (OSM) data.

from cityseer.metrics import visibility

Use the visibility module to create a visibility analysis from OSM data. The visibility will be generated based on the OSM data provided to the visibility_from_osm method.

Pay particular attention to:

  • The bounds_wgs parameter, which defines the geographical area in longitude and latitude to analyze. The order is Left, Bottom, Right, Top.
  • The out_path parameter, which specifies where to save the output files. The filepath must exist. The extension of the output file will be .tif and the file will be saved in GeoTIFF format, which can be opened in QGIS.
  • The to_crs_code parameter, which specifies the coordinate reference system (CRS) to use for the output. The default is the local UTM, but you can change it to any valid CRS code.
  • The view_distance and resolution parameters, which control the analysis granularity.

There is a performance trade-off for the bounds, view_distance, and resolution. A larger view_distance or higher resolution will result in a more detailed graph but may take longer to compute and require more memory.

visibility.visibility_from_osm(
    bounds_wgs=(18.41077, -33.93154, 18.42755, -33.91626),
    out_path="recipes/visibility/images/ct_vis",
    to_crs_code=None,  # defaults to local UTM
    view_distance=100,  # can use a larger view distance - but slower
    resolution=2,  # set resolution - e.g. 2m
)
INFO:cityseer.metrics.visibility:Preparing buildings raster.
INFO:cityseer.metrics.visibility:Running visibility.

The output will generate three files:

  • A density measure - the number of visible pixels.
  • A farness measure - the summed distance to visible pixels - favours farther views (up to view_distance).
  • A harmonic closeness measure - the summed inverse of the distance to visible pixels - favours close adjacency to open spaces.

Visualised as farness (building rooftops included).

Higher visibility density values indicate more open street environments with fewer obstructions, while lower values indicate more enclosed streets surrounded by buildings.

Conclusion

This notebook demonstrated how to generate a visibility analysis directly from OpenStreetMap building footprints using visibility_from_osm. The method produces density, farness, and harmonic closeness rasters that quantify visual openness and enclosure across the urban area, output as GeoTIFF files for use in QGIS or further analysis.

Next steps: To use building data from files, see Visibility from GeoPandas.