import%20marimo%0A%0A__generated_with%20%3D%20%220.23.13%22%0Aapp%20%3D%20marimo.App()%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Visibility%20from%20OSM%20Data%0A%0A%20%20%20%20Generate%20a%20visibility%20analysis%20from%20OpenStreetMap%20(OSM)%20data.%0A%0A%20%20%20%20Network%20data%20%C2%A9%20%5BOpenStreetMap%5D(https%3A%2F%2Fwww.openstreetmap.org%2Fcopyright)%20contributors%2C%20available%20under%20the%20Open%20Database%20Licence.%0A%0A%20%20%20%20Visibility%20analysis%20is%20provided%20by%20the%20standalone%20%60visibility%60%20module%3B%20it%20is%20not%20wrapped%20by%20the%20higher-level%20%60CityNetwork%60%20class.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20from%20cityseer.metrics%20import%20visibility%0A%0A%20%20%20%20return%20(visibility%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Use%20the%20%5B%60visibility.visibility_from_osm%60%5D(https%3A%2F%2Fcityseer.benchmarkurbanism.com%2Fmetrics%2Fvisibility%23visibility_from_osm)%20method%20to%20run%20a%20visibility%20analysis%20over%20building%20footprints%20downloaded%20from%20OSM.%0A%0A%20%20%20%20Pay%20particular%20attention%20to%3A%0A%0A%20%20%20%20-%20The%20%60bounds_wgs%60%20parameter%2C%20which%20defines%20the%20geographical%20area%20to%20analyse%20in%20longitude%20and%20latitude.%20The%20order%20is%20left%2C%20bottom%2C%20right%2C%20top.%0A%20%20%20%20-%20The%20%60out_path%60%20parameter%2C%20which%20specifies%20where%20to%20save%20the%20output%20files.%20The%20directory%20must%20exist.%20Outputs%20are%20written%20in%20GeoTIFF%20format%20(%60.tif%60)%2C%20which%20can%20be%20opened%20in%20QGIS.%0A%20%20%20%20-%20The%20%60to_crs_code%60%20parameter%2C%20which%20specifies%20the%20coordinate%20reference%20system%20(CRS)%20of%20the%20output.%20The%20default%20is%20the%20local%20UTM%20zone%2C%20but%20any%20valid%20CRS%20code%20can%20be%20used.%0A%20%20%20%20-%20The%20%60view_distance%60%20and%20%60resolution%60%20parameters%2C%20which%20control%20the%20analysis%20granularity.%0A%0A%20%20%20%20There%20is%20a%20performance%20trade-off%20between%20the%20bounds%2C%20view%20distance%2C%20and%20resolution%3A%20a%20larger%20view%20distance%20or%20finer%20resolution%20gives%20more%20detailed%20output%20but%20takes%20longer%20to%20compute%20and%20requires%20more%20memory.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(visibility)%3A%0A%20%20%20%20visibility.visibility_from_osm(%0A%20%20%20%20%20%20%20%20bounds_wgs%3D(18.41077%2C%20-33.93154%2C%2018.42755%2C%20-33.91626)%2C%0A%20%20%20%20%20%20%20%20out_path%3D%22images%2Fct_vis%22%2C%0A%20%20%20%20%20%20%20%20to_crs_code%3DNone%2C%20%20%23%20defaults%20to%20local%20UTM%0A%20%20%20%20%20%20%20%20view_distance%3D100%2C%20%20%23%20can%20use%20a%20larger%20view%20distance%20-%20but%20slower%0A%20%20%20%20%20%20%20%20resolution%3D2%2C%20%20%23%20set%20resolution%20-%20e.g.%202m%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20The%20analysis%20writes%20three%20files%3A%0A%0A%20%20%20%20-%20A%20%60density%60%20measure%3A%20the%20number%20of%20visible%20pixels.%0A%20%20%20%20-%20A%20%60farness%60%20measure%3A%20the%20summed%20distance%20to%20visible%20pixels%2C%20which%20favours%20farther%20views%20(up%20to%20%60view_distance%60).%0A%20%20%20%20-%20A%20%60harmonic%60%20closeness%20measure%3A%20the%20summed%20inverse%20distance%20to%20visible%20pixels%2C%20which%20favours%20close%20adjacency%20to%20open%20spaces.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20The%20output%20below%20shows%20%60farness%60%2C%20with%20building%20rooftops%20included.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%3Cimg%20src%3D%22images%2Fct_farness_100_2.png%22%20style%3D%22width%3A100%25%3B%22%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Higher%20visibility%20values%20indicate%20more%20open%20street%20environments%20with%20fewer%20obstructions%2C%20while%20lower%20values%20indicate%20more%20enclosed%20streets%20surrounded%20by%20buildings.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Conclusion%0A%0A%20%20%20%20This%20notebook%20generated%20a%20visibility%20analysis%20directly%20from%20OpenStreetMap%20building%20footprints%20using%20%60visibility_from_osm%60.%20The%20method%20produces%20density%2C%20farness%2C%20and%20harmonic%20closeness%20rasters%20that%20quantify%20visual%20openness%20and%20enclosure%20across%20the%20urban%20area%2C%20written%20as%20GeoTIFF%20files%20for%20use%20in%20QGIS%20or%20further%20analysis.%0A%0A%20%20%20%20**Next%20steps%3A**%20To%20use%20building%20data%20from%20files%2C%20see%20%5BVisibility%20from%20GeoPandas%5D(https%3A%2F%2Fcityseer.benchmarkurbanism.com%2Fexamples%2Fvisibility%2Fvis-gpd).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
fce6f9ef4d700cb680bf8bbae79eb3da