0

I have a huge shapefile (roadnetwork of Europe) and a raster file (Europe, 100x100m resolution). I want to calculate the length of the roadnetwork for each raster cell, resulting in a new raster layer. The problem is that the number of raster cells is huge and the roadnetwork is very large.

My current approach in R is to build 60x60 sub-raster (using the SpaDES-package, convert each sub-raster to polygons (using stars and sf) and then intersect the polygons with the road network. The problem is that this takes very long. Parallelizing the process does not work because of memory limitations (st_intersects/st_intersections cause doParallel to make copies of the whole road network for each thread).

Is there a more efficient way to perform the task?

Is there some software with which this taks can be done efficiently?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Funkwecker
  • 263
  • 8
  • 18
  • I use spatstat for this, the psp type is straightforward (and recent sf has direct converters for this one-to-one format) - pixellate.psp – mdsumner Jun 25 '20 at 22:27

1 Answers1

0

Perhaps an alternative idea, instead of using the intersect function, a common way in QGIS/ArcGIS Pro on how to deal with such problems is to first calculate an intersection point vector at each of the road networks polygon boundary.

You could then use some ready made tools such as discussed here (SAGA - Split lines at points), to calculate/split the length of each individual line:

Splitting a line layer using another point layer

PGerrits
  • 539
  • 2
  • 9