locked
Convert geometry linestring to sequence points RRS feed

  • Question

  • Just recently changed over my GIS from xy coords to strictly geometry but I still have some programs that need xy coordinates   I'm looking at taking data from SQL geometry (linestring) and converting it to a list of sequence and xy points.

    column1 column2

    object1     Linestring (LINESTRING (635772.77986025577 4657991.41418756, 635733.63594557007 4657974.9337245114, 635391.95359132346 4657964.0671187723, 635012.094934114 4657954.1538816467)

    object2 INESTRING (635012.094934114 4657954.1538816467, 634998.8007609623 4658748.4009599593, 634994.9205025197 4658920.7702416079)

    Convert to this.

    column1 column2 column3

    Object1 1 635772.77986025577 4657991.41418756

    2 635733.63594557007 4657974.9337245114

    3 635391.95359132346 4657964.0671187723

    4 635012.094934114 4657954.1538816467

    Object2 1 635012.094934114 4657954.1538816467

    2 634998.8007609623 4658748.4009599593

    3 634994.9205025197 4658920.7702416079

    I can't figure out how to get my sequence points to list correctly.  Any help or pointing me in right direction is greatly appreciated.

    Tai

      
    • Edited by JimNasieum Thursday, May 12, 2016 8:45 PM
    Thursday, May 12, 2016 8:43 PM

Answers

  • You need to write procedural code (perhaps as a multi-statement table-valued function) that loops through STPointN using STNumPoints as a limit. If you have more complex geometries that contain multiple or nested geometry objects, you can also iterate through each one using STGeometryN. Note that STPointN and STGeometryN use 1-based iterators, rather than 0-based.


    Thursday, May 12, 2016 9:22 PM