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

I'm trying to sample points along a linestring. The goal is to have the distance between 2 consecutive points to be at most X (eg. 50m).

I'm drawing linestring in openlayers and sending it to a geodjango app. I can do the "segmentization"/sampling in the client (openlayers) or in the server (geodjango: DB API or Geos API). I don't know yet where I will do it, so I'm interested in both solution (if they exist).

I've searched but have not found any simple solution to this really simple problem (at least, it looks very simple).

I've seen this one for example: How to interpolate GPS Positions in PostGIS but it uses complex postgis query to do the interpolation.

Isn't there any 'split(nseg)' function somewhere that would split a segment into nseg sub segments ? Something close to what shapely offers ? ( ). I could use shapely, but that would add another dependency (not really justified...).

EDIT: I guess I should have a look at linearref from GEOS ( for the geodjango part)

share|improve this question
up vote 0 down vote accepted

Here's a potential answer (at least, the one I've chosen to use).

My problem comes from the fact that current geodjango API does not use linearref features from GEOS. So, I've patched my django code (using linked patch in my question) to get the 'project()' and 'interpolate()' methods.

Then, I simply loop to interpolate the needed points. The key here is to use the linearref feature of GEOS:

share|improve this answer

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.