0

I'm looking for the best way to count polylines crossing each raster cell and assign that count value to the raster cell using arcpy.

On input I have a shapefile with hundred thousands of polylines and a raster with all cells 0 values.

The result should be a raster which cells value should be a number of crossing polylines from the shapefile.

Which ArcPy tools should I use to perform this analysis?

1 Answer 1

2

This could easily be built in model builder. I would:

  1. Convert your raster to points
  2. Convert your points back into a raster but using FID as the value column, this will create unique raster cells
  3. convert this new raster to a polygon dataset
  4. Run the intersect tool, this will give your count of lines per individual pixel.
  5. Join count to polygon and rasterize if required.
2
  • Great. Regarding point 4: Intersect tool I run like this: arcpy.analysis.Intersect([lines_file, out_grid], out_intersect, "", "", "LINE") It gives me single lines cut to pixel borders. I still need to count lines in the pixels before performing join. Of course now it is easier to count, because I can count using pixels Id. Or is there another way to get count of the lines per pixel? Commented Jun 21, 2023 at 7:02
  • 1
    You are correct, you use the ID and run that through the summary statistics tool, that should be step "4.5". :)
    – Hornbydd
    Commented Jun 21, 2023 at 9:24

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.