Hey! This content applies only to previous CARTO products

Please check if it's relevant to your use case. On October 2021 we released a new version of our platform.
You can learn more and read the latest documentation at docs.carto.com

Questions  /  Working with Data  /  PostGIS

How to assign a column value from a polygon to a point

Learn how to assign a polygon attribute to intersecting points.

Assigning column values from a polygon dataset to the points that intersect them is a very common use case. In order to achieve the desired result, a query like this one using the ST_Intersects PostGIS function is needed:

    SELECT pois.*,
           polys.column
      FROM table_points pois
INNER JOIN table_polygons polys
        ON ST_Intersects(
               pois.the_geom,
               polys.the_geom
           )