0

I have a series of .csv datasets with points in Lat/Long mapped to Town Names:

CSV points

In addition, I have a shapefile containing similar data (town names with their corresponding x/y):

Shapefile points

I also have geobuffer data with buffers for each of these towns.

My goal is to join each of the towns in the shapefile to the nearest (within certain limits) town in each of the .csv files. This has to be done spatially (i.e, on a lat/long basis), and the end result would ideally be a table containing:

  1. The town name in the shapefile
  2. The coordinates of the point in the shapefile
  3. The name of the matched town from the csv data
  4. The coordinates of the matched town from the csv data

Points 1 and 3 are essential.

I am fairly new to ArcGIS, so I am struggling to get this done. Ideally, I would have to perform this on ArcPy. I have tried using the near command to no avail. I have also tried creating a feature class from the csv data, and then trying to do a "Point to point" join using the join tool, but I am struggling as well.

What would be the best way to go about this?

1 Answer 1

0
  1. Use Make XY Event Layer to convert the CSV file(s) into feature layers.
  2. Use the Near tool with your shapefile as the in_features and the layer from step 1 as the near_features.
  3. Join the shapefile and the feature layer from step 1 on the NEAR_FID field (added to the shapefile in step 2). There is also a NEAR_DST field you can use to filter out matches above some distance threshold.
  4. Rinse and repeat for additional CSVs.

The docs linked above have code examples, you can follow the same basic approach in arcpy or in ArcMap.

3
  • Thank you so much! I gave it a go, but the NEAR_FID field is -1 in the shapefile after step 2. Also, what should be the field to base the join on for the feature layer?
    – Kamyen
    Feb 14, 2022 at 0:17
  • Look at what the docs page says about NEAR_FID under usage - it addressed both of those questions.
    – Nick
    Feb 14, 2022 at 1:57
  • I understand what you suggest and what the docs say in the Usage section. But I guess this is a bigger issue, e.g. I don't think that GIS knows TownName is supposed to be the ObjectId in either of the datasets. I am struggling as to how to specify the ID fields
    – Kamyen
    Feb 14, 2022 at 14:12

Your Answer

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

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