1

I need to create a line between polygons (centroid) and the nearest cell of a raster dataset. The polygon and raster do not intersect. Each polygon has a UID. One cell can be linked to many polygons, but the polygon can only be linked to one cell.

To start, I'm converting the raster to point. From there, I think a Spatial Join needs to be performed using "CLOSEST" as the match option. If I can get the raster cell point to have the polygon UID, I can then use Points to Line with the UID field as the "Line Field" parameter to create an individual line between the two points to connect the polygons to the nearest raster cell.

I tested this on a small area and sample, but it was taking a long time to run each step. In the end, this needs to be performed for hundreds of polygons at a time. Can anyone tell me if I'm on the right track or offer any suggestions to make this work? Some searching has indicated using Near analysis and creating a line from the xy coordinates could be an option as well. Whatever is most efficient.


Making a grid with only values along the boundary would make the raster to point processing faster, as described here. I'm still not sure if the rest of the process is going to work correctly.

1

Your method is OK, but converting a grid to a set of point usually creates very large feature dataset that are heavy to manipulate.

Another idea would be to take advantage of the grid structure : regular spacing. For each polygon,

1) compute the coordinates of the centroid (calculate geometry )

2) deduce the coordinates of the center (or of the corner, whatever your prefer) of the lower left cell (X centroid - X lower left cell, Y centroid - Y lower left cell )

3) divides the coordinates by the cell size (now you are in relative "cell" coordinates)

4) Round (not truncate) the coordinate (this will bring you to the closest cell)

5) multiply by the cell size

6) add the lower left cell coordinates (you are back in map coordinates)

7) build your line

You can do this in Python (see other posts on this site to build lines with arcpy, best way is to use arcpy.da.searchCursor and arcpy.da.InsertCursor). Or you can compute the "rounded" coordinates in the table of your polygons, use these two fields for "make XY layer" then use point to line.

Note that you need to work in the original CRS of your grid, otherwise the cell spacing may not be constant and you could have some rotation, which is more difficult to handle.

  • I'm not following how this is done for every cell in the raster dataset (specifically the border cells). – dubch87 Feb 7 '14 at 21:07

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.