Skip to main content

I’m looking for a way to move points which are spaced at “x” distance from one another to a nearby road (line) shapefile. I want to maintain the same “x” spacing along the road once the points are moved to the line.

Do you want roughly the same spacing, or exactly the same spacing? Both can be done, but roughly the same is much easier.


@daveatsafe roughly the same spacing, i guess but maintain as close to the original spacing as possible. The problem is that i’m working with is if the road crosses nearly perpendicular to a number of points. Those points are being put on roughly the same part of the road.


@daveatsafe just following up to my question if you have any help / insight.


I’m not sure if this will give the best result where the roads are perpendicular to the points, but I don’t know if there is a good answer for that.

I would start by generating measures along the road, using the MeasureGenerator, then extract the last measure to use as a maximum. Relate the point to the road, using the NeighborFinder, with the road as the Candidate and the points as the Bases. This will transfer the road measures onto the points, so you will know how far along the road each point is. You can extract the point measure into an attribute with the MeasureExtractor

The next step is to use a ListBuilder to build a list of point ids and measures, grouping by road id. This will give you a list you can work on in a PythonCaller.

In the PythonCaller use

measures = feature.getAttribute(‘_list{}’)

to get the entire list of measures as a Python list. Now we need to adjust those intervals to hit your target spacing. There is probably a Python module out there that can do this nicely, but I’m not really sure how to search for it. What I would do is:

  • find the smallest interval less then the target in the list as a starting location
  • adjust the measure of the point before that interval down by 10% of the target interval
  • adjust the measure of the point above up by 10%

Repeat this cycle until all intervals are equal to or larger than the target interval, or until the first or last point reaches 0 or the maximum measure of the road line. Use

feature.setAttribute(‘measures’, ‘_list{}’)

to set the adjusted list on the feature.

Use a ListExploder to explode the list into individual features, one for each original point, although they will have no geometry yet. They will have a point id, road id and adjusted road measure. Use a FeatureMerger to merge the road geometry on the points by road id. Next use a Snipper to snip by Measure (Value) - set both the Starting and Ending location to the adjusted measure value.

The result from this should be points sitting on the road line, spaced at your target interval.


Reply