[GIS] Snapping points to lines in ArcGIS Desktop and automate using VBA

arcgis-desktopsnappingvba

I use ArcGIS Desktop and I want create a network with a point feature and a line feature. I need my point features to be on the line features so I should do Snap point to line.

However, I do not know how do it in ArcGIS, and then automate it with code for this in VBA.

Best Answer

Snapping points to a line using ArcGIS geoprocessing tools

Assumptions:

You have a point layer and a line layer. You want a points to be snapped to the line layer.

Instructions

1. Use the Near tool to find snap locations

  1. In ArcGIS's Toolbox pane, Select Analysis Tools -> Proximity -> Near
  2. Choose your point layer as Input features, your line layer as Near features. Make sure you tick the Location checkbox.
  3. Four new attributes will be added to your point layer, NEAR_FID, NEAR_DIST, NEAR_X and NEAR_Y.

2. Export the layer as a table

  1. Open the attribute table of the point layer
  2. Click on the Table Options button in the attribute table window, and choose Export.... Save it is a dbase (.dbf) file.
  3. When prompted if you want to add the table to your current map, choose Yes.

3. Recreate the points layer from the table

  1. Find the table you just added in your Table of Contents pane. You might need to switch tabs if you are using ArcGIS 9.3 to the Source tab.
  2. Right-click on the table, and choose Add XY Data.
  3. Make sure the X field is set to NEAR_X, and the Y field to NEAR_Y. Adjust the coordinate system if appropriate.
  4. Your new point Event layer should appear in the table of contents. Right click on it, and select Data->Export data... to save the layer permanently as a shapefile.
Related Question