Are there any references available for converting a large number of GPS points (taken every second) into a more managable number of lines?
This is a discussion on Converting points to lines within the MapPoint Desktop Discussion forums, part of the Map Forums category; Are there any references available for converting a large number of GPS points (taken every second) into a more managable ...
Are there any references available for converting a large number of GPS points (taken every second) into a more managable number of lines?
You could try something like this (pseudo VB code):
' assuming an array of your GPS latitudes 'aLat', and longitudes 'aLong'
dim aObjLocs(0 to Ubound(aLat)) as MapPoint.Location
' now create an array of location objects - one for each GPS fix
For n = 0 to Ubound(aLat)
Set aObjLocs(n) = objMap.GetLocation(aLat(n),aLong(n))
Next n
' now turn the array of locations into a polyline
objMap.Shapes.AddPolyline aObjLocs
You'd use the objMap.Shapes.Item(x).Vertices to retrieve and work with the array of locations that make up the Polyline, assuming 'x' is the item in the Shapes collection that you just added. Get this by calling objMap.Shapes.Count right after you call the AddPolyline method.
Note: Don't expect this code to work first time. I've probably left out a few things, but it gives the sense of a method that you could try.
What I really want to do is reduce the amount of data. For instance, I have a thousand points going in a line down Main Street. Because of the small errors in GPS, the points aren't mathematically in a line, but I want to save the data as a line segment, not as a thousand points. When the points make a left turn at 9th Street, I want to programatically detect that and have another line segment until the points turn or stop. I want my program to go through up to a million points and plot as few line segments on the map as possible.
How close are the points and what are the acceptable errors at turns?
If they're close and/or acceptable errors are reasonable, then you could do a simple decimation of the data - ie. only keep every other point / every third point / etc.
Snapping lines to data points is possible, but you still have to be aware of errors and tolerances. I wrote something to do this in 1d a while ago for reducing finely sampled geophysical data into "segments", based on the "method of least squares".
2d would be more complicated but do-able, and there are some nifty speedups possible if you know what you're doing.![]()
Contact me off list (see contact form on website), if you're interested in us writing a program to do this for you.
Richard
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
There are currently 1 users browsing this thread. (0 members and 1 guests)