2

I have a point layer and a polygon layer (both containing hundreds of records) and I want to know how far those points are from a nearest polygon feature,

I've used the Near tool and it returns two columns, NEAR_FID (identifies which polygon feature is the nearest) and NEAR_DIST (distance between a point and the nearest polygon feature). However, I would like to use a different field as the identifying field to show which polygon feature is the nearest (my own ID field instead of ArcGIS's automatic FID field).

Point layer:
FID ID
0   2
1   7
2   10
3   213
4   476

Does anyone know if this is possible, and if yes, how?

1

I don't think it's possible to use a different field as the identifier. Using ESRI's ID field guarantees that the number will be unique. After running the Near tool, run the Join Field tool.

JoinField_management (in_data, in_field, join_table, join_field, {fields})

In your case use this, (replace "Name" with the attribute you want from the polygons. This will join the attributes from the polygon table to your point table. If you have a lot of records you may want to experiment with an attribute index.

JoinField_management("points", "NEAR_FID", "polygons", "OBJECTID", "Name")

1

Yes, you just need to use the Add_Field tool to add new column to the attribute table. This way you can name the field whatever you want. After that, right click on the column in the table you want in a different row (NEAR_FID) and select field calculator. Now set your new row equal to NEAR_FID.

  • Thanks for your answer! If I understand right this wouldn't change the fact that ArcGIS would still use the FID as the identifier. I edited my question as I didn't mention before that my data is huge, and even though it's possible to create a new field and change the ID to that field, with lots of data it's very time consuming. – FiveO Dec 6 '17 at 20:18

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.