[postgis-users] min distance to right and left

Martijn Meijers b.m.meijers at tudelft.nl
Mon Nov 23 12:59:11 PST 2015


Hi,

Would http://postgis.net/docs/ST_ShortestLine.html help you in this case?

I am not sure how important the distinction between left/right is, but 
are you sure that this is always defined properly just by looking at the 
street and building only? E.g. if you have the following: the house (in 
the center) is it on the left or right of the small dead end street?

+-------------------+
|                   |
|  +===+            |
|  +===+            |
|                   |
|    +              |
|    |              |
+----+--------------+

One option: You could build explicit topology and then use information 
of the faces and use left/right pointers on the edges (the streets) to 
determine that a building is on the left/right of a street (road part) - 
you can then also easily filter dead ends.

Another (potentially less accurate) option: calculate orient2d 
(https://www.cs.cmu.edu/~quake/robust.html) for every segment of the 
street to every polygon vertex of the building (or even coarser 
approximation, but much faster: use centroid of the house and one 
segment that represents the street, e.g. vector from begin point segment 
- end point segment). I think you have to make such an orientation test 
in Postgres/PostGIS yourself by making a custom database function. Note 
that this could give wrong results when streets run around buildings 
(flipping of left/right as result).


Martijn

On 23-11-15 16:13, toni hernández wrote:
> Hello everyone,
>
> I have two tables: streets and buildings.
> streets with a linestring geometry and buildings with polygons geometry.
>
> I need to know what is the minimal distance from each street to a 
> building on the right, and then, what is the minimal distance from the 
> street to a building on the left.
>
> Any ideas on how I should approach this?
>
> Thank you!
> -- 
> *Toni Hernández Vallès*
> Servei de Sistemes d'Informació Geogràfica i Teledetecció
> -
> Universitat de Girona
> *SIGTE*
> -
> Pl. Ferrater Mora 1
> 17071 Girona
> Tel +34 972 418 039 (7026 intern)
> toni at sigte.udg.edu <mailto:toni at sigte.udg.edu>
>
> http://www.sigte.udg.edu
> Twitter http://twitter.com/SIGTE_UDG
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/postgis-users



More information about the postgis-users mailing list