Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am a GIS novice using SQL 2008, with C# and the NetTopologySuite WKTReader type to work with some geometries.

I have some data which I have been able to save into the database but when I read back out the I receive a 24144 error with suggestions to use MakeValid() to convert it to a valid instance.

I don't understand whats wrong with the WKT. I presume its violating an OGC rule but not sure what.

GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POLYGON ((-2.76 49.38905, -2.7600333333333333 
49.535166666666662, -2.5833500000000003 49.5352, -2.4087833333333331 
49.535166666666662, -2.4087666666666667 49.38905, -2.56075 49.389099999999992, 
-2.5552833333333336 49.437733333333334, -2.5552166666666665 49.455183333333331, 
-2.5968 49.455183333333331, -2.5967833333333332 49.437733333333334, 
-2.5552833333333336 49.437733333333334, -2.56075 49.389099999999992, -2.76 49.38905))))

I am unable to change this data so is there an alternative to reading this out of SQL without having to change it?

Thanks for looking

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Looks like you have a self-intersection, which SQL Server no likey. I'm surprised it even got loaded into the database in the first place. Try running MakeValid() and see what it does to the shape. You don't have to test it on the original data, just make a new one on the fly in Management Studio.

enter image description here

What's interesting is that SQL Server will plot it:

enter image description here

But it is indeed invalid:

DECLARE @test geometry
SET @test = geometry::STGeomCollFromText('GEOMETRYCOLLECTION(POLYGON((
 -2.76 49.38905,
 -2.7600333333333333 49.535166666666662, 
 -2.5833500000000003 49.5352,
 -2.4087833333333331 49.535166666666662, 
 -2.4087666666666667 49.38905, 
 -2.56075 49.389099999999992, 
 -2.5552833333333336 49.437733333333334, 
 -2.5552166666666665 49.455183333333331, 
 -2.5968 49.455183333333331, 
 -2.5967833333333332 49.437733333333334, 
 -2.5552833333333336 49.437733333333334, 
 -2.56075 49.389099999999992, 
 -2.76 49.38905)))',0)
SELECT @test.STIsValid()

>> 0
share|improve this answer
    
Chad, much appreciated. –  SimonNet May 21 '12 at 15:23
    
where can we download the JTS Testbuilder software? It looks absolutely stunning!! –  vinayan May 22 '12 at 8:19
1  
Vinayan, I downloaded it from sourceforge.net/projects/jts-topo-suite –  SimonNet May 22 '12 at 8:21
1  
@vinayan - some good stuff about JTS here as well - which is where I learned of it. –  Chad Cooper May 22 '12 at 11:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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