I have a large set of habitat polygons (over 10,000) between which I wish to calculate least-cost distances and cumulative costs for a subset of polygon pairs (nearest edge to nearest edge), using a series of pre-existing resistance/cost rasters. The size of my datasets mean this is something I'd like to script in R or Python, but so far surprisingly the best option I've found (the gdistance R package) only allows calculation of least-cost paths between points, not polygons.
Is anyone aware of an R package or Python module which allows for least-cost calculations between polygons, or an alternative approach I could use to achieve similar results?