This is related to a previous question I've asked: Create filled contour map with GRASS

I've created a point layer using OpenStreetMap data and pgRouting's driving_distance() function, where the points contain a cost attribute which contains the walking distance from a school. I've used QGIS and the contour plugin to create what I want:

walking distance isolines

However I'd now like to do this programmatically for a web app, and in addition result in polygons rather than a raster. I've got something working using GRASS, however it is quite slow, around 30 secs on my machine versus less than 1 sec using QGIS and the contour plugin. Here the short version (or see Python version):

# read file and set resolution and bounds
v.in.ogr dsn=cost_points.shp output=cost_points
g.region vect=cost_points rows=256 cols=256
# interpolate points and make bands of 0.4km increments
v.surf.rst input=cost_points elev=interp zcolumn=cost
r.mapcalc res='int(interp/0.4)'
# convert to polygons and write out file
r.to.vect -s input=result output=polys feature=area
v.out.ogr -c input=polys dsn=polys.shp type=area

Are there other GRASS functions I should use? r.surf.rst takes the majority of the time, so perhaps it is too robust for my needs, but even then the results aren't smooth enough for my liking. Are there other open source libraries I should be considering for this?

If you'd like to know more about my overall goals, see this page.

  • This is also possible in saga gis. Can you provide an example cost_points.shp file? I can write a short script doing the same. It would be nice to see how the performance would differ from grass.
    – johanvdw
    Commented Sep 5, 2011 at 9:45

2 Answers 2


In the end I just took the code from the QGIS contour plugin and modified it for my purposes to accept and output any OGR supported formats. I can now have it spit out GeoJSON and display the vector layers (polygons) on an OpenLayers map. If interested, you can get the code on GitHub: pysochrone. enter image description here


For sure v.surf.rst is time consuming. Consider to use the much faster v.surf.bspline instead. You may also replace, since you only have points, v.in.ogr with v.external which just registers the data source.

  • Thanks for the suggestion, I've been playing with v.surf.bspline for a bit, but am having trouble getting sensible results. I think I need to better understand the parameters; I've varied the spline step, which changes the results significantly, but I haven't figured out what's the "right" number to use yet.
    – joshdoe
    Commented Sep 4, 2011 at 4:24
  • 1
    The manual page grass.osgeo.org/grass64/manuals/html64_user/v.surf.bspline.html suggests "For optimum performance, the length of spline step should be no less than the distance between observation points." - did you try this?
    – markusN
    Commented Sep 4, 2011 at 17:52
  • 1
    I read that, but the problem with my data is that the distance between points varies significantly, maybe between a meter and 50 meters or more. I haven't yet found a value that gives good results. Maybe I should find out what method the QGIS contour plugin uses.
    – joshdoe
    Commented Sep 4, 2011 at 18:24
  • You may want to check in v.surf.bspline this flag: "-e Estimate point density and distance for the input vector points within the current region extends and quit"
    – markusN
    Commented Sep 29, 2011 at 13:56

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.