Trying to create an SQL Server geometry instance using STGeomFromText() and a MultiPolygon but the created geometry instance is invalid
I'm trying to create a geometry instance in SQL Server
using STGeomFromText()
and a MultiPolygon
but I keep getting an invalid instance. What is wrong with the MultiPolygon
?
DECLARE @area0 geometry = geometry::STGeomFromText('MULTIPOLYGON (((-123.140037 49.16519, -123.140034 49.165778, -123.140033 49.165874, -123.140032 49.166088, -123.13973 49.166088, -123.139685 49.166088, -123.13969 49.166244, -123.139467 49.16639, -123.13947 49.166784, -123.139395 49.166835, -123.139394 49.166935, -123.139394 49.166993, -123.139393 49.167049, -123.139392 49.167146, -123.139323 49.16719, -123.139322 49.167209, -123.13932 49.167433, -123.139301 49.167671, -123.139303 49.168716, -123.13922 49.168716, -123.139202 49.169448, -123.138172 49.169443, -123.137973 49.16944, -123.137813 49.169336, -123.137777 49.169334, -123.137692 49.169333, -123.137706 49.168571, -123.137711 49.168303, -123.137581 49.168302, -123.136944 49.168296, -123.136937 49.168017, -123.136937 49.167975, -123.136935 49.167931, -123.13693 49.167742, -123.137292 49.167739, -123.137389 49.167738, -123.137476 49.167737, -123.137553 49.167737, -123.137648 49.167736, -123.137651 49.167673, -123.137644 49.16741, -123.137593 49.167373, -123.137593 49.167317, -123.137593 49.167266, -123.137594 49.167046, -123.137595 49.166987, -123.137594 49.16693, -123.137595 49.166603, -123.137632 49.166578, -123.137735 49.166579, -123.137736 49.166428, -123.137737 49.166233, -123.137737 49.166171, -123.137737 49.166093, -123.137661 49.166092, -123.137597 49.166049, -123.137598 49.165823, -123.137598 49.165781, -123.137598 49.165727, -123.137599 49.165437, -123.137601 49.165059, -123.137518 49.165055, -123.137479 49.165022, -123.137487 49.164497, -123.137528 49.164464, -123.139088 49.164475, -123.139092 49.164817, -123.138908 49.164818, -123.13891 49.164915, -123.138789 49.164913, -123.138785 49.165064, -123.139014 49.16507, -123.139018 49.165188, -123.139049 49.165188, -123.140037 49.16519), (-123.137288 49.168425, -123.137253 49.168676, -123.13689 49.168676, -123.136865 49.168425, -123.137288 49.168425), (-123.137771 49.169962, -123.136839 49.16997, -123.136823 49.169063, -123.137193 49.169055, -123.137184 49.169383, -123.137412 49.169391, -123.137424 49.169538, -123.137754 49.169539, -123.137771 49.169962)))', 4326);
SELECT @area0.STIsValid(); --This results in 0
Eventually I want to use @area0 in SQL Server like this: @area0.STIntersects(table.Shape) = 1
When I use the same MultiPolygon
in Snowflake
using to_geography()
, I get a valid instance.
SELECT ST_ISVALID(to_geography(
'MULTIPOLYGON (((-123.140037 49.16519, -123.140034 49.165778, -123.140033 49.165874, -123.140032 49.166088, -123.13973 49.166088, -123.139685 49.166088, -123.13969 49.166244, -123.139467 49.16639, -123.13947 49.166784, -123.139395 49.166835, -123.139394 49.166935, -123.139394 49.166993, -123.139393 49.167049, -123.139392 49.167146, -123.139323 49.16719, -123.139322 49.167209, -123.13932 49.167433, -123.139301 49.167671, -123.139303 49.168716, -123.13922 49.168716, -123.139202 49.169448, -123.138172 49.169443, -123.137973 49.16944, -123.137813 49.169336, -123.137777 49.169334, -123.137692 49.169333, -123.137706 49.168571, -123.137711 49.168303, -123.137581 49.168302, -123.136944 49.168296, -123.136937 49.168017, -123.136937 49.167975, -123.136935 49.167931, -123.13693 49.167742, -123.137292 49.167739, -123.137389 49.167738, -123.137476 49.167737, -123.137553 49.167737, -123.137648 49.167736, -123.137651 49.167673, -123.137644 49.16741, -123.137593 49.167373, -123.137593 49.167317, -123.137593 49.167266, -123.137594 49.167046, -123.137595 49.166987, -123.137594 49.16693, -123.137595 49.166603, -123.137632 49.166578, -123.137735 49.166579, -123.137736 49.166428, -123.137737 49.166233, -123.137737 49.166171, -123.137737 49.166093, -123.137661 49.166092, -123.137597 49.166049, -123.137598 49.165823, -123.137598 49.165781, -123.137598 49.165727, -123.137599 49.165437, -123.137601 49.165059, -123.137518 49.165055, -123.137479 49.165022, -123.137487 49.164497, -123.137528 49.164464, -123.139088 49.164475, -123.139092 49.164817, -123.138908 49.164818, -123.13891 49.164915, -123.138789 49.164913, -123.138785 49.165064, -123.139014 49.16507, -123.139018 49.165188, -123.139049 49.165188, -123.140037 49.16519), (-123.137288 49.168425, -123.137253 49.168676, -123.13689 49.168676, -123.136865 49.168425, -123.137288 49.168425), (-123.137771 49.169962, -123.136839 49.16997, -123.136823 49.169063, -123.137193 49.169055, -123.137184 49.169383, -123.137412 49.169391, -123.137424 49.169538, -123.137754 49.169539, -123.137771 49.169962)))'
)
); --This results in TRUE
Which I then use in Snowflake like this: ST_INTERSECTS("DB"."PUBLIC"."TEMP_TABLE".Polygon, table.Centroid)
Comments
Post a Comment