get geometry of Buffer

26 views
Skip to first unread message

Tara

unread,
Nov 5, 2017, 1:39:59 PM11/5/17
to SpatiaLite Users
Hello,

I am working on a web application, where a user can add an adress name, in order to display some POI around a certain distance. I created a query in spatialite where this works. You can see my statement below:

(''' SELECT ST_X(a.geometry), ST_Y(a.geometry), a.name, a.node_id FROM my_table AS a WHERE Contains(Buffer(GeomFromText('POINT(%s %s)', 3857), %s), a.geometry) ''' % (var1, var2, var3)) Now my aim is, to get the buffer geometry and display it as a circle on my map, as well. Until now just the POIs around a certain distance are displayed, but I want to add a circle as a polygon based on the user given adress name, is there a way to do it in one query statement? Regards Tara

mj10777

unread,
Nov 5, 2017, 2:46:59 PM11/5/17
to SpatiaLite Users
Assuming that:
-  a.geometry is the POINT
- 'var3' is the area in units of the srid of the circle [sample: 10 meters]

SELECT ST_Buffer(a.geometry,10) AS point_circle, ST_Envelope(ST_Buffer(a.geometry,10)) AS point_square;

would be the result of a circle and a square, 10 meters around the point (i.e. width/height 20 meters)
- ST_Buffer creates a circle around the geometry
- ST_Envelope creates a Square or Rectangle (depending on the geometry), using the Min/MaxX,Min/MaxY of the geometry

Mark

Regards Tara

Reply all
Reply to author
Forward
0 new messages