2

I need to compute the distance from an input point file to a series of target points in different shapefiles. Everything is in Africa. I want to do this in a pyQgis script. The script I have shown below does the job.

However, I would prefer if the aerial distances computed did not cross the sea. Is there a way to impose a restriction so that the distances are only computed to points inside a polygon (the African continent)?

import os
import glob
from qgis.core import * import qgis.utils 

  processing.runalg("qgis:distancematrix","path-to-my-input-file","inputfileid",atts,"path-to-my-target-file",0,1,"path-to-output-file")
1

I think Saga Least cost path might do what you need.

You'll need to convert your Africa polygon to a raster and reclassify it so that land is a low value and sea is a high value. The tool will give you a line representative of the route taken which you can then calculate length on.

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.