0

I'm new to GIS so this question may be an obvious one.

I have one polygon layer of urban land use and another polygon layer of swamps.

How do I join the two layers so that I get a column in the attributes tables that gives me the distance of the closest land use polygon to that of each swamp?

4

Distances, one to another, can't be calculated on polygons (or lines for that matter). What you need to do is convert the polygons to points using feature to point to get the centroids (1 point per polygon, roughly centre) then do a near or spatial join to find the closest swamp polygon to the land parcel.

If you want better location of the nearest feature use feature vertices to points, but this will give you 1 point for each vertex which you will have to thin down to just one (closest) point. To trim these down you will need to do some manual editing. Start with a summary statistics of the points using Input_FID and Near_FID as the case fields and a static of min for distance, then from that table do summary statistics again with just the Input_FID and a type of count, this will give you a table showing how many occurrences of each FID there are, only the ones with 2 or more need to be edited. Find these records in the first table (use definition query) and remove all but the minimum distance.

Once you have located the closest feature to the point you can attribute join the land parcel via the centroid to the closest swamp. First add a field called Nearest, join the parcels to the points statistic table with the records trimmed and calculate the Nearest to the Near_FID, remove that join and join to the swamps using Nearest to OBJECTID (FID).

  • Great answer. If you don't have an ArcInfo license, and so can't run the Feature to Point tool, a workaround is to use the geometry calculation tools on the table, as explained here – Stephen Lead May 20 '14 at 4:31
  • If you can't run the Vertices to Points tool for the same reason, you'll have to write a script which manually creates a point for each vertex. – Stephen Lead May 20 '14 at 4:32
  • Good point @StephenLead gis.stackexchange.com/questions/26369/… would get you started. Polygons are almost the same as polylines for the purposes of the code. The posted code is almost complete, would just have to insert the ID of the source feature into the points. – Michael Stimson May 20 '14 at 5:25
  • 2
    Distance can't be calc'd on a polygon? What am I missing here? I just ran a test with a lake and building polygon shapefiles as inputs to the Generate Near Table (because it creates a standalone table rather than modifying data as Near does). I then joined the resulting table to buildings based on building FID and table IN_FID, then joined the lakes to buildings using lake FID and table NEAR_FID. The resulting table gives me the building, name of the nearest lake, and the distance to it in CRS units. Seems to be what is being asked for here. – Chris W May 20 '14 at 6:08
  • I was not aware of that tool, now that I am I'll be using it again and again and again. Wish I could do +2. – Michael Stimson May 20 '14 at 22:31
1

Assuming you have an Advanced/Info level license, there are two 'near' tools that could do what you want. The Generate Near Table can create a table that shows the feature IDs of your test and near objects and the distance between them (among other options). This tool doesn't modfiy the original data.

In your case, you would run the tool and use Swamps for your input features and Land Use as the near features. You need to specify an output table location, and that's pretty much it. There are other options available but for what you asked you can leave them at default. Run the tool, then open the resulting table.

Now you'll do a couple of joins to give a little more meaning to that table. First right-click on swamps and join the table you created to it using the swamp FID field (or whichever matches) to the table's IN_FID field. The swamps table should now have the attributes in the table, but while it gives you the distance you want and an ID of the nearest land use, that ID is somewhat cryptic and doesn't tell you the type. So now right-click again on swamps and do another join, this time using the NEAR_FID field you added in the first join to the land use FID. Now you should also have the attributes from the land use features that tell you what type of use the nearest polygon is along with any other attributes stored there. You can hide any fields you don't want or need to see and export to a new layer which will have swamps with the desired attributes.

Alternatively you can use the Near tool in much the same way to save yourself one of the above joins. However this tool will actually modify the existing swamps data (not write a new layer) to add the attributes found in the near table from above. You'll still have to join Land Use to Swamps using that NEAR_FID field and export (or add field) to get the Land Use type instead of an FID as an attribute of Swamps.

Note the distance will be in the units of whatever CRS you're working in.

  • Yet again you've shown me something new @ChrisW thank you. I've been doing it that way since the 90's (ArcINFO workstation) and have not looked at other options. +1 and thanks again! I'll be using that one for sure!! – Michael Stimson May 20 '14 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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