6

Let me describe the data setup. A line has been provided as an array of coordinate pairs, one for each vertex. This array is variable in size, anywhere from 2 to 200 coordinate pairs per line. What I am trying to wrap my mind around is the best way to create these lines. Arcpy and ArcObjects are both viable options, but ArcObjects is preferred due to its speed (generally).

I have brainstormed a few methods, but they fall short for some reason or another:

1) I could use the Polyline class with arcpy to create polylines and then Copy Features, but the resulting geometry would not have any of the attribution necessary to identify said points.

2) I could use XY To Line, but this only works with one pair of point, and I require something much more robust.

The long and short is that I require a method that can create a polyline from arrays and maintain a schema for data that I have created in a table. One idea I have is to create said table and schema, and then somehow create the polyline and copy its shape property to the output table, porting over the ID and whatever other attribution is needed. How can I go about creating the polyline's shape property without resorting to an intermediate shapefile? Or, if there is a better method that comes to mind, please share it with me.

Update This code seems to work!

IFeatureClass fClass = gpUtil.OpenFeatureClassFromString(path);
IFeatureCursor cursor = fClass.Insert(true);
IFeatureBuffer buffer = fClass.CreateFeatureBuffer();
<snip...>
string[] nodearray = a.Split(';');
foreach (string i in nodearray)
{
 query.WhereClause = "\"PNT_ID\" = '" + i+"'";
 Console.WriteLine(query.WhereClause.ToString());
 ICursor search = table.Search(query, false);
 IRow row = search.NextRow();
 float x = float.Parse(row.get_Value(2).ToString());
 float y = float.Parse(row.get_Value(3).ToString());
 int id = int.Parse(row.get_Value(1).ToString());
 point.X = x;
 point.Y = y;
 point.ID = id;
 point.SpatialReference = sRef;
 pCollection.AddPoint(point, ref Missing, ref Missing);
}
IGeometry5 polygeo = (IGeometry5)pCollection;
buffer.set_Value(1, polygeo);
buffer.set_Value(2, wayid);
cursor.InsertFeature(buffer);
Germán Carrillo
37.3k5 gold badges127 silver badges182 bronze badges
asked Jun 9, 2011 at 17:09
0

2 Answers 2

4

It looks like I've got it. I created an IPoint class and used it to fill an IPointCollection instantiated as a PolylineClass. Then I cast the collection to IGeometry5 and used that as the shape field for the row in my output feature class, copying over the ID with a buffer.

I got my head twisted in a few circles working with two inputs, but it seems to work all right.

answered Jun 9, 2011 at 20:19
0

I'm struggling with a similar schema here.

I have to identify lines and their vertexes and maintain a Line has Vertex relationship between them. I think I'm dealing with a larger requirement (I'm nor sure), but we are implementing this as views and feature class extensions (largely to maintain our "segment" tables)

basic schema is

Line Table Name (PK)

Point Table Name (PK)

LineSegmentTable LineName (FK) ID Order FromPoint (FK) ToPoint (FK)

LineView Name Geometry

In your case, a "vertex" table might be more suitable. We are running on Oracle, also.

answered Jun 9, 2011 at 18:34
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.