today i ran into a possible size limitation of geography type Linestrings
within Sql Server 2008.
when i create a Linestring with STGeomFromText()
that contains 567 points containing Long,Lat and Z coordinates, everything works fine.
However, if i add one more point to the linestring i get an:
ArgumentException 24200: The specified input does not represent a valid geography instance.
I was not able to find any documentation regarding size limitations of sql server´s geography type linestrings or something similar.
Is this a limitation of geography or just of the STGeomFromtext()
function?
Does anyone has some links to some more detailed information or is the only way to get around this splitting the linestring up into several smaller linestrings grouped together in a multilinestring.
Any help is appreciated ;)
I haven't heard about any size limitations on LINESTRING (certainly not as short as 567 points).
I just tried an example
which worked fine (creates the LINESTRING and counts 1,122 points).
Does your example fail with ANY 567 points - or just a specific set of points (can you share them with us?). I guess I'm wondering whether your 568th point makes your GEOGRAPHY instance larger than a hemisphere? For example, if I change my example by adding another point (0,0) which forces the GEOGRAPHY to be too large:
I get ArgumentException 24205: The specified input does not represent a valid geography instance because it exceeds a single hemisphere. Each geography instance must fit inside a single hemisphere. A common reason for this error is that a polygon has the wrong ring orientation. which obviously isn't the exact same error as you - but I thought I'd raise it anyway [Skip to the UPDATE at the end for a better idea]
My second question to you is: does it work with the GEOMETRY datatype? Eg. if I change my "breaking" example above to use GEOMETRY then it works fine:
If you can post some more details on your specific problem it might suggest the underlying problem. Also could you add whether you are entering the points in SQL Management Studio or via code (is it C# and SQL data types assembly)? What is the full text of the error message you receive (if there is more than what you quoted above - see my error).
But the short answer is "I don't think there is a 567-point limit".
UPDATE: Ed's post contains the exact error you get (System.ArgumentException: 24200) - so if you can get you data working in GEOMETRY instead, this might be worth a try:
It seems, that geography linestring can't contain more then finite number of self intersection points.
This sample produces exact same error. Intersection of edges (2 0, 3 0) and (3 0, 2 0) contains of infinite number of points.
Same result for:
Hell Craig,
thanks for your quick answer. I´ve encountered a set of really strange behaviors. Eg. the mentioned linestring cannot be read into a geography type, but it works using geometry type. However, i can select the resulting geometry object and can view it in the spatial results tab within management studio. if i call the .STNumPoints() method on this geometry object i get the following exception :
if i call MakeValid() on this geometry object before calling STNumPoints(), everything works fine. MakeValid is not needed to just select the geometry and display it.
the same data cannot be read into a geography type. if the last coordinate points is removed it works like charm.
the sample data i tried to execute is :
which does IMHO not exceed a single hemisphere. It´s not even a big area.
setting @g as geometry and calling the STGeomFromText static method with geometry instead of goegraphy works as long as you do not call methods like STNumPoints() or STDistance() on it.
this is getting really confusing...
edit: I´ve just encountered an even shorter Linestring that fails. removing the last point results in a valid geography object wherease the following statement fails:
i.e. that this Linestring fails with 24(!!!!) points and works with 23. If anyone has an idea what the problem might be...i´m getting somewhat frustrated. Too much nearby points would have been a reason for the first linestring, but i just cannot believe that 24 points that are too near to each other may lead to this error.
Make sure you don't cause a figure-8 with your data. A geography can't have its lines cross each other.
I haven't tried your data yet, but I imagine it could well be the problem. I once grabbed a ton of map data from someone, and found that several of my countries (like Canada, Russia, the UK) couldn't be converted into geographies, and when I investigated, it was down to the occasional figure-8 thing going on.
Ie... coming across a part of the border where it tries to double back on itself and then re-cross the border.
I'm just guessing here, mind you... if I have time today I'll grab your data and do some more investigation - time's the killer though.
Rob