Skip to main content
2 of 6
naming; formatting
Vince
  • 20.3k
  • 16
  • 48
  • 65

How to intersect with ST_Buffer in PostGIS

I have a table called "gebaeude_salzburg" with all types of buildings in the city. In the following I want to use a Buffer around the central train station that has the osm_id="159867730" and a radius of 1000m. Then I want to select the building types "school" and "kindergarten" that are within this radius by intersecting them with the buffer. What I tried looks like this:

WITH center AS (
     SELECT ST_Buffer(geom, 1000) FROM gebaeude_salzburg 
     WHERE osm_id='159867730')
SELECT gebaeude_salzburg.name AS "Name der Einrichtung",
        ST_Distance(center.geom, gebaeude_salzburg) AS Distanz
FROM gebaeude_salzburg, center
WHERE (gebaeude_salzburg.type='school' OR gebaeude_salzburg.type='kindergarten')
AND ST_Intersects(gebaeude_salzburg.geom,center.geom);

I get the following error:

ERROR: column center.geom does not exist LINE 5: ST_Distance(center.geom, gebaeude_salzburg) AS Distanz ^

What am I doing wrong?

Alm
  • 83
  • 5