1

I have a polygon database (bdus) and a point database (bdps) under the same schema in PostGIS. These databases were imported from shapefiles with the Shapefile and DBF loader. What I want to do is to join the point attributes on the polygon layer based on the contain criteria. So for every polygon that contain one to n points, to add the columns of points to polygons. If there are more than one point a good approach would be to average column values.

Can someone guide me? I am new to PostGreSQL and PostGIS but I managed to run this query

SELECT * FROM bdps
JOIN
bdus
ON
ST_Contains(bdus.the_geom, bdps.the_geom);

which return a table with bdps joined with the corresponding bdus, but I want the reverse.

Thanks in advance for any help!

user1165791
  • 111
  • 1
  • 1
  • 4

1 Answers1

0

Did you meant, that you want to create a new polygon with the polygon and the points that satisfy the ST_Contains(polys, points) criteria?

SELECT ST_Union(bdus.the_geom, bdps.the_geom) FROM bdus,bdps WHERE 
ST_Contains(bdus.the_geom, bdps.the_geom);
Paco Valdez
  • 1,915
  • 14
  • 26