Answered by:
STNumPoints

I am trying to return the number of points in Each Line Segment where the Table is a collection (rows) of unique Line Segments, using the method STNumPoints().
I have WKT and geometry data type for each instance (line segment), and would like to populate an entire column with the number of points in each segment.
I don't really have a clue how to use this function to generate the desired column, and have been unsuccessful with anything I've tried.
Any clues????
thx
Spatio
Question
Answers

Here's a basic usage sample, both in a SELECT statement or as a computed column. Does this help?
USE tempdb; GO setup test data CREATE TABLE specialspatial ( id int ,line geometry ); INSERT specialspatial VALUES (1, geometry::STLineFromText('LINESTRING(10 10, 20 20, 30 30)', 0)) ,(2, geometry::STLineFromText('LINESTRING(10 10, 20 20)', 0)) ,(3, geometry::STLineFromText('LINESTRING(10 10, 20 20, 30 30, 40 40)', 0)); simple usage of STNumPoints SELECT id ,line.STNumPoints() FROM specialspatial; OR as a calculated column ALTER TABLE specialspatial ADD numpoints AS line.STNumPoints(); SELECT * FROM specialspatial;
Jason
 Marked as answer by spatio Thursday, December 12, 2013 5:35 AM

All replies

Here's a basic usage sample, both in a SELECT statement or as a computed column. Does this help?
USE tempdb; GO setup test data CREATE TABLE specialspatial ( id int ,line geometry ); INSERT specialspatial VALUES (1, geometry::STLineFromText('LINESTRING(10 10, 20 20, 30 30)', 0)) ,(2, geometry::STLineFromText('LINESTRING(10 10, 20 20)', 0)) ,(3, geometry::STLineFromText('LINESTRING(10 10, 20 20, 30 30, 40 40)', 0)); simple usage of STNumPoints SELECT id ,line.STNumPoints() FROM specialspatial; OR as a calculated column ALTER TABLE specialspatial ADD numpoints AS line.STNumPoints(); SELECT * FROM specialspatial;
Jason
 Marked as answer by spatio Thursday, December 12, 2013 5:35 AM


