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.

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 ? (http://gispython.org/shapely/docs/1.2/manual.html#linear-referencing-methods ). 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 (https://code.djangoproject.com/ticket/11948 for the geodjango part)

share|improve this question

1 Answer 1

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:

http://geos.osgeo.org/doxygen/classgeos_1_1linearref_1_1LengthIndexedLine.html#7f1fd2d3467a3bae6e28e2da893506f9

share|improve this answer

Your Answer

 
discard

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.