Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
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 Sep 5 '11 at 9:45

2 Answers 2

up vote 3 down vote accepted

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

share|improve this answer

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.

share|improve this answer
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 Sep 4 '11 at 4:24
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 Sep 4 '11 at 17:52
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 Sep 4 '11 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 Sep 29 '11 at 13:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.