Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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);
share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer
    
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 Feb 17 '12 at 9:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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