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

  1. a placename point table in postgis with 'district' column.

  2. a districts polygon shapefile with district name in 'Name' column. See the image below.

I would like to update the 'district' columns(in placename psql table) with the corresponding district name from the shapefile polygons in which each placename point feature reside.

How can I do this in QGIS? Or Is there any other way? enter image description here

share|improve this question

1 Answer 1

Postgis way : (import polygon shape to postgis using shp2psql )

UPDATE points SET district = poly.district FROM poly WHERE ST_Within(points.geom, poly.geom)

see ST_Within

and i cant remember easy QGIS way , but its possible

share|improve this answer
    
Can we update multiple columns in single update query? like, "province" also.. –  mapsir Mar 21 '14 at 11:49
    
See postgresql.org/docs/9.2/static/sql-update.html UPDATE points SET (district, province) = (poly.district, poly.province) FROM poly WHERE ST_Within(points.geom, poly.geom) That may work , didn't test. But it should be possible. –  simplexio Mar 21 '14 at 13:48
    
Should I use any EPSG codes? If, yes, how? Point geom is in 900913. And poly geom does not show any. –  mapsir Mar 24 '14 at 6:08
    
both need to be in same system (ST_SetSrid(geom, srid) can be used to set srid and ST_Transform(geom,srid ) can be used to transform to different projection –  simplexio Mar 24 '14 at 7:40
    
should I add this along with the update query? –  mapsir Mar 24 '14 at 9:02

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.