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();


string[] nodearray = a.Split(';');
foreach (string i in nodearray)
    query.WhereClause = "\"PNT_ID\" = '" + i+"'";
    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);
  • Does each array also have a unique ID? – Kirk Kuykendall Jun 9 '11 at 17:27
  • Yes, every array's first index is the unique identifier for the line. – Nathanus Jun 9 '11 at 17:38

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.

| improve this answer | |

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.

| improve this answer | |
  • Have you considered using IPoint.ID on each point in you polyline? – Kirk Kuykendall Jun 9 '11 at 18:53
  • Hello Kirk. I haven't considered that approach because I have multiple point tables, and my guess is that there is overlap between those ids. Am I correct? My shema is actually using multiple point tables with GlobalIds and my segment tables are looking at unioned views of these tables. The big deal here is that these points mean something. The user cannot go freehand with drawing, he needs to use the known points to do some cartography work. – George Silva Jun 9 '11 at 19:55
  • Yes, multiple tables would be complicated. I used PointID in an implementation if ILayerExtensionDraw that allowed vertices in each feature's polyline to be rendered based with a markersymbol based on some lookup attribute. Having multiple tables sure would have complicated things. – Kirk Kuykendall Jun 9 '11 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.