I have a point dataset representing households that I want to associate with a parcel layer (i.e. assign its parcel_id). With ArcMap, I could spatially join the polygons to the points and specify that the join have a certain search radius and use the nearest polygon.

I wish to perform this with postgres and was wondering what the most prudent way of doing this was. I can't use ST_contains because points fall on streets and not on actual parcels. In stead of ST_contains, is there another function allowing for proximity checks?

update households h set parcel_id = p.parcel_id 
from parcels p where ST_contains(p.the_geom, h.xy);

1 Answer 1


For what you want to accomplish, I think ST_DWithin would work. From the PostGIS site documentation:

ST_DWithin — Returns true if the geometries are within the specified distance of one another. For geometry units are in those of spatial reference and For geography units are in meters and measurement is defaulted to use_spheroid=true (measure around spheroid), for faster check, use_spheroid=false to measure along sphere.

  • This could probably work, but the trick is to set a proper search threshold. Set it too high and I get more than one match, set it too low and I get none. Or set it high and discard the extra match records.
    – ako
    Commented Feb 17, 2012 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.