0

I have two polygon shapefiles, one of mine sites and one of parks. I've clipped one layer so that only mines within the park boundaries are shown. However, I want to take an attribute from the parks layer (park name) and add it into the mine layer so that when I export the table to excel it will show which park the mine is in. I can't merge the attribute tables because I need the park name to line up with the correct mine.

How do I copy the attributes from the Park layer to the Mine layer based on location?

2
  • 2
    What software do you have access to? This can usually be achieved by running the intersection within a GIS software Apr 9, 2015 at 2:03
  • 1
    Or a spatial join/query.
    – Chris W
    Apr 9, 2015 at 4:05

1 Answer 1

1

You can import your data to postgis via shp2pgsql

Then you can use an intersection sql like:

*Update mine set your_column =k.park_name
From park as k
Where intersects(st_pointonsurface(mine.the_geom),k.the_geom) and st_pointonsurface(mine.the_geom)&&k.the_geom*

Or you can use simple intersection. Note that intersection function return true even geometrically touches. So you can use additional criteria like area intersection.

*update mine set your_column= k.park_name
 from park as k 
where intersects(mine.the_geom, k.the_geom) 
and mine.the_geom&&k.the_geom
--and area(intersection(mine.the_geom,k.the_geom))> your_value*

Your Answer

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

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