This content applies to a previous version of CARTO
In October 2021 we released a new version of our platform. You can find the latest documentation at docs.carto.com
Back to Help Center
How to Assign a Column Value from a Polygon to a Point
Learn how to assign a polygon attribute to intersecting points.
Overview
Assigning column values from a polygon dataset to the points that intersect them is a common geospatial task. This requires using the ST_Intersects PostGIS function to match points with their containing polygons.
Solution
Use an inner join query with the spatial intersection function:
SELECT pois.*,
polys.column
FROM table_points pois
INNER JOIN table_polygons polys
ON ST_Intersects(
pois.the_geom,
polys.the_geom
)
This query selects all point attributes and adds the desired polygon column by joining tables where the point geometry intersects the polygon geometry.
