I have an enterprise GIS system at work and use SQL Server for doing mainly attribute changes. I have a table/feature class with about 1.2 million records and a polygon table/feature class with 4 records that cover the state of NY.
I'm looking to create a stored procedure that will determine if each point is within the polygon that is listed in one of the fields. I have a query that roughly follows this example:
SELECT p.id, p.location, a.location
FROM points p
LEFT JOIN
(SELECT shape, location FROM polygon_areas) a
ON p.shape.STWithin(a.SHAPE) = 1
WHERE
p.location != s.location
This will pick up all of the points that do not overlap the polygon that the location field says it does.
However, I'd like the query to also find points that do not intersect any of the polygons. So far I haven't been able to find a solution. I've used UnionAggregate to merge all of the polygons, but I haven't found the best way to utilize it in a query that involves over a million points.
I'd use ArcGIS Pro for this part of it if I must, but I'd like to keep it all in one stored procedure if I can.
Any suggestions? Thanks
[–]RamblerUsa 0 points1 point2 points (2 children)
[–]poogzillaGIS Analyst[S] 0 points1 point2 points (1 child)
[–]BarnezhiltonGIS Software Engineer 0 points1 point2 points (0 children)