0

Need help loading point data in sql spatial.

Similar to this post but I really dont know how to get XY data to be accessible by sql

I want to do what was done in the initial part of this post (Identify points that plot inside the polygon):

https://gis.stackexchange.com/questions/166399/how-do-i-find-points-that-are-not-within-a-list-of-polygons-using-ms-sql

SELECT points.name, polygons.name
    FROM points CROSS JOIN
    polygons
    WHERE  (polygons.shape.STContains(points.shape) = 1) 

How do you get the points loaded into your table and sql to recognize the points with out having to define them like the below?

insert into @points values 
(geometry::Point(1,1,0)), 
(geometry::Point(2,3,0)), 
(geometry::Point(5,4,0)), 
(geometry::Point(4,2,0))

I am having a hard time defining points without doing it manually like above

Ideally I could build a table like this by selecting the xy data I have in a table already

1 Answer 1

1

Its very clunky but you need to use stpointfromtext

geometry::STPointFromText('POINT(xxxxx yyyyyy)', SRID)

...where xxxxx andf yyyyy are the coordinate values and SRID is the grid identifier for the projection you are using. Wrap it all up with a cursor like in the following example:

Insert geometry from XY coordinates using SQL (ESRI | Technical Support)

Your Answer

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

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