locked
extracting the inner rings lat and longs from a polygon geography data RRS feed

  • Question

  • I have Geography data that represent the county boundaries within each state. At times, these boundaries will have rings within the polygon. How do Identify which points are the outer rings and which points are the inner rings? Right now, I just loop through the geography points and extract all the lats and longs something like this in C sharp. I need to be able to identify the outer polygon points and the inner ring points seperately.  Any help would be appreciated.

     for (int npolygons = 1; npolygons <= geographyfield.STNumGeometries(); npolygons++)
                                            {
                                                for (int nrec = 1; nrec <= (int)geographyfield.STGeometryN(npolygons).STNumPoints(); nrec++)
                                                {
                                                    countyboundaryRecord = new CountyBoundaryClass();

                                                    countyboundaryRecord.PolygonID = npolygons;
                                                    countyboundaryRecord.PointID = nrec;
                                                    countyboundaryRecord.CountyFips = strCountyFips;
                                                    countyboundaryRecord.Longitude = Math.Abs(geographyfield.STGeometryN(npolygons).STPointN(nrec).Long.Value * 1000000);
                                                    countyboundaryRecord.Latitude = Math.Abs(geographyfield.STGeometryN(npolygons).STPointN(nrec).Lat.Value * 1000000);

                                                    WriteCountyPolyPoints(countyboundaryRecord);

                                              }

                                            }

    Tuesday, November 2, 2010 9:48 PM

Answers

  • You can find out the total number of rings in a geography instance using NumRings(), and loop through each one using RingN(n).


    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    • Proposed as answer by Tom Li - MSFT Friday, November 5, 2010 8:02 AM
    • Marked as answer by Tom Li - MSFT Wednesday, November 10, 2010 4:29 AM
    Wednesday, November 3, 2010 3:01 PM
    Answerer