2

I have 2 csv files both with 3 columns: variable, lat, lon.

Let's call them file A and file B. File A has 100 values for variable (in this case city), File B has 100,000 values for variable (station numbers in this case).

The goal is to assign a city (from file A) to every station number (from file B). So for each city, I will have a station number which is the closest station number to that city (by euclidian distance using latitude longitude).

Does anyone know how I can do this? I've looked at using Nearest but that doesn't seem like what I'm looking for.

I can use ArcPy also if that helps, but I'm not too experienced in ArcGIS.

user12279
  • 59
  • 1

2 Answers2

4

You could use a spatial join, which will give each point in file B the attributes of the nearest point in file A, as well as creating a new field that gives the distance between the points.

Edit: This suggestion is assuming an arcgis platform, and assuming from the text that you have generated a spatial layer from the two files. the spatial join can be run by right-clicking on the target layer (file B) going to joins and relates/join... and selecting "Join data from another layer based on spatial location" in the first drop down, selecting file A from the second menu, and clicking the "Each point will be given the attributes of the point closeest to it..." radio button. this will create a new layer

TDavis
  • 1,704
  • 1
  • 15
  • 26
  • Doesn't this assume that a certain package is being used? Is the answer detailed enough? – Martin F Jan 09 '14 at 01:12
  • 2
    I inferred from the reference to Nearest and ArcPy that it's some version of ArcGIS 10, though the spatial join would apply to older Arc versions as well. – TDavis Jan 09 '14 at 01:46
2

Have you considered the Near tool? This would be useful if the csv files were converted to point shapefiles. Once this is done, you set the input feature to city points and the near features to the station points. This will assign the object id of the nearest station point to each city point.

Barbarossa
  • 5,797
  • 27
  • 61