ST_ISOVist
Signature
Description
This function compute the visibility polygon obstructed by provided obstacles
.
Obstacles
can be LINESTRING(S)
,POLYGON(S)
or GEOMETRYCOLLECTION(S)
.
Resulting polygon will be enclosed by a circle defined by the maximum distance (maxDistance
) parameter.
Parameters
point
: Point coordinates (x, y, (z)) from which the visibility will be calculated,obstacles
: Geometry or set of geometries grouped into a simple or complex geometry, used as obstacles,maxDistance
: Only obstacles located within this distance from thepoint
are considered in the calculation (only cartesian distance is accepted - depends on your spatial ref),angleStart
: Starting angle from which visibility will be calculated (exprimed in radian - to convert from degree, use the H2 database PI() function),angleStop
: Ending angle from which visibility will be calculated (exprimed in radian).
Examples
Initialize input geometries
- point where the visibility will be computed :
point
layer - buildings :
polygon
layer - walls :
linestring
layer - buildings and walls :
geomCollection
layer
Example with a distance
Using polygon
Use buildings (polygon
) to compute the visibility from the point
with a distance of 20m.
Result
Legend : polygon
in grey / point
in red / resulting ISOVist layer
in orange
Same but with a distance of 50m.
Result
Legend : polygon
in grey / point
in red / resulting ISOVist layer
in orange
Using linestring
Use walls (linestring
) to compute the visibility from the point
with a distance of 50m.
Result
Legend : walls
in black / point
in red / resulting ISOVist layer
in orange
Using geomCollection
Result
Legend : polygon
in grey / walls
in black / point
in red / resulting ISOVist layer
in orange
Example with starting and ending angles
Compute the visibility using buildings (poygon
layer) with a distance of 50m, starting at 0 rad and ending at 3 rad.
Same, but ending at 5 rad.
Application : Compute visibility along a path
Aim
Compute visibilities in the city center of Vannes (France), every 10m, with a 100m maximum distance of visibility and export results into an animated .gif file.
Cool isn’t it? Thanks to H2GIS, OrbisGIS, Groovy and The Gimp (all free and open-source) you will see that it’s quite easy to reproduce.
How to produce this animation?
To do so, just follow these steps:
- 1- Prepare input data
- 2- Run the Groovy script
- 3- Convert all the images into an animated .gif
1- Prepare input data
In this example, only two tables are needed:
buildings
: a set ofpolygons
(grey in the gif)path
: alinestring
. If you want to do a loop (like in the .gif), yourlinestring
has to be closed (red in the gif).
Load your data into OrbisGIS
In the SQL Console, execute the following script.
Where ST_IsoVist(a.the_geom, ST_Accum(b.the_geom), 100)
→ 100
is the maxDistance value used in this example.
This script will creates:
- the first (starting) point of your
path
(src
layer), - the ISOVist (
iso
layer) from the first point.
Once executed, load src
and iso
layers into the TOC
and adapt their styles to fit to your needs (here red point and orange polygon).
2- Run the Groovy script
In the OrbisGIS’s Groovy Console, execute the script presented below.
In a nutshell, this script will:
- densify the path in order to obtain a set of points that will be used to compute visibilities,
- for each point, compute the visibility and export the map into a .png file.
Where
mapImageWriter.setWidth(729)
andsetHeight(513)
defines the size (in pixels) of the output .png files,for(int i=1;i<=256;i+=1)
→256
correspond to the maximum number of image produced (so here the maximum number of point used to compute the visibility along thepath
),ST_Densify(the_geom, 10)
→10
is the distance (exprimed in meter) used to densify thepath
→ every10
m a point will be added,path
is the layer name of the linestring used to computes visibilities,ST_Accum(the_geom), 100)
→100
is the maximum distance used to compute the visibilty (seemaxDistance
parameter),buildings
is the layer name in which obstacles are stored,/myUrl/+"test"+i+".png"
→ .png files, prefixed bytest
; will be saved into a folder defined by/myUrl/
.src
andiso
are respectively the output table names for the point where the visibility is calculated and the resulting visibility polygon.
3- Convert all the images into an animated gif
Once the script ran, you obtain many .png files (in this example we have 200 files).
To convert them into an animated .gif file, follow these steps:
- Launch The Gimp,
- In the
File
menu, “Open” the first image (heretest1.png
), - In the
File
menu, choose “Open as layers” and load the rest of images (here fromtest2.png
totest200.png
),
- Optionnaly, optimized the rendering for animation →
Filters
→Animation
→Optimize (for GIF)
, - Export the result :
File
→Èxport as
→ choose the.gif
file format and specify the file name and output folder →Export
, - In the configuration panel, choose
Save as animation
and you can specify the time between images (by default 100ms) →Export
Your animated .gif file is produced !