ThinkGeo.com    |     Documentation    |     Premium Support

Proper approach for outlining points

First some context. I am jumping in the middle of an existing project that is using ThinkGeo for some mapping. I have done a little with ThinkGeo, but this is the first time that i've needed to add a shape / layer. The documentation I did find wasn't overly helpful, so if someone could point me in the right direction, I'd appreciate it.


 


Ok, so here's what I need to do. I have a map that displays a bunch of points (50k+). These points are grouped into related collections. So lets say that 50k points are split into 50 groups. What I need to do is draw a box around the outside of each group. These points are not always in a straight line, and keeping the box tight to the points is important.


The plan we came up with is to create a LineShape for each group of points, and then do something (not sure what exactly) with the display to give the appearance of a box around the points.


What I've done so far is to create a LineShape out of each groups vertices:


  



List<Vertex> linePoints = new List<Vertex>();
LineShape line;

foreach (myObject dataPoint in stripPoints)
{
    PointShape point = new PointShape(Convert.ToDouble(dataPoint.Longitude, CultureInfo.InvariantCulture),
                  Convert.ToDouble(dataPoint.Latitude, CultureInfo.InvariantCulture));

    linePoints.Add(new Vertex(point));
}

line = new LineShape(linePoints);

Feature feature = new Feature(line);


 


Where I seem to be stuck is knowing what to do with this shape. I made the assumption that i needed a new layer, could add it to an existing overlay, and then add my shape to the layer. When i do this i get an error "FeatureSource is not in a transaction". So then i started digging deeper into the ThinkGeo forums and found a post talking about creating a shapefile and adding that to the map. Should this really be the route that I need to go? It makes sense to me, but in the end, I just need some guidance from the experts on what's the best way to go.



This is the post I mentioned: 
  
 gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/5060/afv/topic/Default.aspx

*update* 



I went the route of creating a shapefile and adding it to my map. That worked, however, it looks like I need to approach this differently as the groups of points do go in multiple directions, and may turn back on themselves. Drawing this line results in a snake looking line. Anyways, I then went the route of a ConvexHull, but that won't work either because of the rubberband nature of it. Basically, if my points make an L, i need to show a shape of an L, not a triangle. 



Is there built in functionality for building a box like this? Bounding box also does not work for what i need.



attached is a very rough example of what I'm trying to do.


Is it possible that NTS has a function that will build the shape for me based on my vertices? It's as if i need a function that takes an array of vertices, a geo unit, and a tolerance to build the shape.



1792-boundries.png (7.54 KB)

I think that in your case the problem to resolved needs to be more precisely defined. I understand that using ConvexHull or the bounding does not give you the expected result but you need to define a little more concretely how you want to build the shape based on the points. By looking at the attached picture, it seems to me, that the polygon with the red outline has been created the following way: 
  
 -Create square of a certain size (tolerance) for each point. The point being the center. 
 -Union (merge) all the squares into one to create the resulting polygon. 
  
  Visually, this is what i tried to guess on how the polygon was built. Can you confirm that this is indeed the method used and I will write a little sample app for this? If this is not the case, can you explain more precisely how the resulting shape should be built? 
  
 Thank you.

the image i attached was hand drawn in paint to express what i’m looking for. The dots being the data points, the red line being the poly i need to created. 
  
 But your suggestion is actually right on target with what I need to do. We were actually considering the same process, but with convexHulls. I think the idea of doing it with squares may be the better way to go simply due to processing cycles. My assumption is that creating 5000 convexHulls compared to 5000 squares or circles is going to be very very heavy. 
  
 I would be interested in seeing a sample app that starts to accomplish this. our concern with the proposed solution is that it will take a long time to process.

We have done this in our COM app.  The performance issue is the union, not the Convex Hulls.   And the NTS unioning code is marginal compared to the tool we were using in COM.   You can reduce the number of unions by trying to figure out if the points that fall insiide the convex hull really need to be be considered in other convex hulls.  If they are interior points, then there are cases they can be dropped from the solution.   Stuff like that. 
  
 As an alternative, if your points represent a chronological travel pattern, you can buffer the line that runs through the points, and then merge the buffered lines together for a full boundary.   That’s the approach we are using now.   And that works well because you want the boundary to reflect the width of the machine collecting the points… not the centerline of the points.   It also works well if you have data collected from two different machines, because if you process just the points, you don’t know the width to associate to the buffer of each point (or the convex hull). 
  
 I just wanted to offer some gotcha’s to think about before jumping in with both feet :)

Ted is making a good point. Levi, could you tell us in what context you want to do the outlining of the points? If think that if we understand a little more the real world scenario you are working with, we will be in a better position to give the more appropriate method. Thank you.