Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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 input=cost_points elev=interp zcolumn=cost
r.mapcalc res='int(interp/0.4)'
# convert to polygons and write out file -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? 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
up vote 4 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 is time consuming. Consider to use the much faster instead. You may also replace, since you only have points, with v.external which just registers the data source.

share|improve this answer
Thanks for the suggestion, I've been playing with 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 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 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.