2

I'm using GRASS 7.0.4 under Linuxmint 17.1 KDE.

I need to build a raster with the shortest distance from every pixel to a city following a road. I have two shape files, the city (point) and the road (line). I plan to compute these distances in two steps, first the straight-line distance from the pixel to the road and second the distance from there to the city following the road.

My idea is to build a point grid, compute the distances from each point of the grid to the city and transform this grid to a raster file (May be you have a better idea, could I use r.grow.distance to do this?) So, I've built the grid with points every 500 m.

First, I've tried to solve the problem with v.distance with the to_along parameter. The problem here is that the road continues after the city so I don't know how to compute the distance up to the city and not all along the road. And I cannot clip the line representing the road because I have points to the south and to the north of the city.

After that, I've used the outputparameter of v.distance to build a vector containing the lines connecting every point in the grid to the road. I've merged this new vector with the road and obtained a network connecting all the points in the grid with the city (I think that probably here is my problem).

Then I did the following:

v.net -s input=net_clean points=grid_500 output=net1 operation=connect threshold=400 arc_layer=1 node_layer=2

v.net input=net1 points=City output=net2 operation=connect threshold=400 arc_layer=1 node_layer=3

Up to this step, everything goes fine, but when I try to compute distances:

v.net.distance input=net2 output=distances_1 from_layer=2 to_layer=3

I obtain the following message:

WARNING: 30 'from' features were not reachable

And this is doing a test with only 500 points in the grid, my original grid have almost 80,000.

I've tried with v.clean as suggested here: http://www.webrian.ch/2011/06/routing-with-openstreetmap-data-in.html and here: How to fix unreachable nodes in QGIS GRASS network?.

That reduced the original number of "not reachable" features from 117 to 30. But I still don't know how to completely solve the problem.

If you know of another tool to solve the problem, as long as it is free, I'll be glad to try it.

Any suggestion?

  • When points are not reachable it means they're too far from a road. – MikeRSpencer Jun 7 '16 at 11:11
  • Ok, may be with a higher threshold value? – Lucas Jun 8 '16 at 11:50
  • Yes, I think that's what threshold does, but the manual isn't very helpful! – MikeRSpencer Jun 8 '16 at 11:51
1

I'll try with a higher value for threshold, just to know if it works.

However, I've finally solved my original problem (i.e. "build a raster with the shortest distance from every pixel to a city following a road") in four steps:

1- using 'v.distance' I've calculated the distance from the grid points to the road and the and the x and y coordinate of the nearest point on the 'to' feature. In this case, this feature is the road.

2- I've exported the result as a .csv file and then imported this .csv file as a new vector file of points using the x and y columns as coordinates.

3- Then, I've built the 'net' and calculated the distance from these points to the city following the road (using 'v.net').

4- And finally I computed the distance from the grid points to the city as a sum of the two distances.

May be it is not the best solution, but it was the way I've found to solve this quickly. Now I have more time to continue trying to find a better solution.

Thanks!

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.