How Interpolate Shape works. Available with 3D Analyst license. The Interpolate Shape tool converts a 2D point, polyline, or polygon feature class into a 3D feature class by interpolating z-values for input features from a surface. Use it if your polyline has some Z values. Otherwise you can use Extract Values to points or Interpolate Shape. These both require surface that you may get your values. Not sure if TIN would be ok, but always you can convert TIN To Raster. Also you could construct polyline ZM and Calibrate Route M with your GPS points. It should do what IZ.InterpolateZsBetween, only for M. Than you could use M as Z. Though as far as I remember year back there was a bug in this algorithm. I need to get the latitude/longitude of a position at X percentage along a straight polyline segment between two other lat/lng points. The closest I have come so far is using the following (for 40% along the line): google.maps.geometry.spherical.interpolate(startLatLng, endLatLng, 0.4).
I need to store into my array the points along the polyline at each defined distance.
Example:The Polyline length is 50m, I set the interval to 5m. I have to store in the array all the points along the polyline each 5 meter. (points on 0m-5m-10m-15m..).
I'm using C#.Any function to get these points?
Answers 2
A possible algorithm in pseudo code (as I don't know how your polyline is implemented):
pointPosition
is the distance from the beginning of the polyline to the current point.prevSegmentsLength
is the sum of the lengths of the preceeding polyline segements.segmentsLength
is the sum of the lengths of the polyline segements including the length of the current segment.The idea is to walk along the polyline for each point until you find the segment on which the point lies. Then interpolate the point from the two end points of the segment.
The difficulty is that several points can lie on one segment, but is is also possible that several segements lie between two points.
Interpolation:
If the segment is defined as (x0, y0) - (x1, y1) you can interpolate like this:
where
t
is the distance of the point along the segment from (x0, y0).Assuming you are using ArcGIS, convert your line features to Linear Referenced Routes using the Create Route tool and setting the measures to use length in meters. All of the measure interpolation between nodes is done for you by an event table without any code just by providing a unique RouteID for the line you want and a measure value in meters in the records of a separate event table.
Create a unique ID for each set of lines you want to function as a single route (or just calc the ObjectID into a long field and use it for each individual line). Then create an event table with the Route (or Routes) IDs and a record for each successive 5 meter interval for as long as you want. When you make the event table into a point layer with the Display Route Layer tool you can access the advanced functions to get an Error Code. Any distance within the actual line will have a 'NO ERROR' code, while those that fall off the line will have a 'MEASURE NOT FOUND' code.
It is easy to create such an event table in Excel starting with just your RouteID set and adding a record for a measure at 0 and 5 and then duplicating and extending the series. Import it to a dbf or GDB table and you are done and make it a Route Event Layer. The Copy Features tool converts the events to actual points independent of the line if you need that, otherwise the events remain fluid with the line geometry and remeasuring of each line. Event tables can also tell you the normal or tangent angle of each point where it falls along the line for offset operations and you can optionally offset your points or line segment events from the line with an Offset field. Dynamic Segmentation is used to aptly describe this fluid and elastic way of creating point position and line segment portions along any line with M values.
For ArcObjects in C# use the ICurve.QueryPointAndDistance Method to do the same thing the event table is doing in code on a line with or without measures.
Related Questions
How can I create random points along a polyline in QGIS?
Updated April 18, 2015 20:09 PMHow to create points in a specified distance along the line in QGIS?
Updated August 04, 2016 08:09 AMCreating polygon from exterior points using PostGIS?
Updated July 11, 2018 12:22 PMCreate New Point Along Transect Starting at Coordinates
Updated April 27, 2017 18:22 PMCombining points and polylines in Qgis
Updated August 23, 2016 08:09 AMActive2 years, 6 months ago
$begingroup$I have looked around for a while and I can't find a solution to this problem.Let's say I have a cubic bezier curve (defined by 4 points) and I want to get a set of points that are spaced evenly along the curve. Think of placing a text along a curve for an example.
Now the problem is that if I input
t
(interpolation value from 0-1) with a constant increment the points are not evenly spaced. The distance along the curve is smaller when the curve makes a turn and longer when the curve is straight.So how do I place points evenly along a bezier curve?
FoalyFoaly
$endgroup$4 Answers
$begingroup$It's more of a math question. So a bezier curve has the following formula, both in the
x
and y
component.Length traveled by
t
along a curve gamma
is given by:There's no human-writable solution to the integral, so you have to approximate.
Replace the
gamma(t)
by the expression B(t)
to get the length length_B
traveled by t
along the bezier segment. Let's say it travels from 0
to L
.Now pick
n
values between 0
and L
that correspond to the evenly spaced points. For examples, lengths of the form k*L/n
for k
from 0
to n
.Now you need to inverse the function
length_B
, so you can compute the t
back from the length l
. It's quite a lot of math and I'm lazy as hell, try doing it yourself. If you can't, you can go to the math stackexchange. For a more complete answer, you can go there anyway.Once you have that inverse
length_B
function (or a reasonable approximation), you process is quite simple.- Create lengths
l[k]
of given path distance away from the origin(P0_x,P1_x)
. - Compute their corresponding
t[k]
usinglength_B_inverse
. - Positing the points using
(B_x(t[k]),B_y(t[k]))
.
LærneLærne
$endgroup$$begingroup$Well it has been some time..
But I was finally able to solve this problem!
Everything you need is in this post: Moving ships between two planets along a bezier, missing some equations for acceleration
FoalyFoaly
$endgroup$$begingroup$Just to expand on what Marco said, a common technique for doing this is to walk down the curve in much smaller increments than the fixed length steps you want to take and store the resulting output point (and perhaps distance?) in a table.
Then, you go through the table and discard all the entries except those points that are closest to the integer multiples of the distances you want to walk.
Then you are left with a table you can index directly at runtime very quickly. If you want to go to the spot that is 5 times the size of your distance you look in your table at index [5].
Note that you could do the two steps in one and not actually store the extra items in the table to begin with, but it's easier to visualize and understand in two steps. Coreldraw graphics suite x5 sp2 keygen.
I once saw a technique for actually calculating this on the fly without precalculating a table (it didn't use iteration / root finding either!), but unfortunately I can't remember the details at all ):
If i remember it or find it, i'll post the info!
Alan WolfeAlan Wolfe
1,99311 gold badge77 silver badges2525 bronze badges
Create Polygons From Polylines
$endgroup$$begingroup$Here's some algorithm that gives pretty ok results:
tp1tp1