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 use a groundwater model program called GMS, and it has a very useful function "Redistribute vertices" (more info). I use this function all the time to both simplify and provide regular spacings between points (vertices) in linestrings.

See this image from GMS where the black lines are original stream with irregular spacings, and the grey lines have redistributed vertices using 50.0 m from GMS

I haven't seen the equivalent function anywhere else in the GIS-processing world (Esri, JTS, PostGIS, etc.). Redistribute vertices requires a specified spacing distance, whereas simplify-type functions use a tolerance and don't use a specified spacing. Does anyone know if there is something equivalent in either ArcGIS or open source GIS projects?

share|improve this question
add comment

3 Answers 3

up vote 2 down vote accepted

This type of processing is achieved using linear referencing. ArcGIS has a number of tools to work with linear referenced features, however for equidistant points it is often easier to create a small script to generate the points and then join them together as new lines.

In the opensource world most spatial databases have this funcitonality, as do spatial libraries such as Shapely for Python.

share|improve this answer
    
The linear referencing keyword is a good start, but it looks like this will be a custom tool –  Mike T Mar 9 '11 at 1:25
add comment

Since the version 2.x, PyQGIS has an has an interpolate function similar to that of Shapely :

for distance in xrange(0,lenght_line,20):
     point = line.interpolate(distance) 

enter image description hereenter image description here

look at How to create points in a specified distance along the line in QGIS?

share|improve this answer
    
Thanks for the hint. I was able to redistribute the vertices to a specified distance in this question –  Dave X 20 mins ago
add comment

Adapting my answer to this question: First make ~/.qgis2/python/mytools.py :

from qgis.core import (QgsFeature, QgsGeometry,
                       QgsVectorLayer, QgsMapLayerRegistry,
                       QgsField)
from PyQt4.QtCore import QVariant
from qgis.utils import iface
import math

def redistribute_geometry_vertices(geom,dist):
    mylen=geom.length()
    line=geom.asPolyline()
    return QgsGeometry.fromPolyline([geom.interpolate(i*float(dist)).asPoint() for i in range(int(math.ceil(mylen/dist)))])


def selection_update_geometry(userFunction, *args):
    """Redistribute the vertices along a polyline """
    layer = iface.mapCanvas().currentLayer()
    for feature in layer.selectedFeatures():
        geom = feature.geometry()
        newgeom=userFunction(geom,*args)
        layer.changeGeometry(feature.id(),newgeom)

Then select the layer, make it editable, select the features, then type this in the console:

import mytools
mytools.selection_update_geometry(mytools.redistribute_geometry_vertices,50)

enter image description here

share
add comment

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.