Anyone know of a free OpenSource .NET library i could use to convert KML to WKT?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Your other option is to use the NetTopologySuite which is a port from the Java version, it supports WKT Reading/Writing.
We've then taken the Kml xsd, using the provided ms tools converted it to classes which the xml serialiser understands and then walked the tree converting the nodes we cared about into NTS IGeometry that the rest of our system used.
Since i'm using post GIS, I ended up having it do it for me:
If i need two KML feature's converted, i'll send it a select like the following:
SELECT ST_AsText(ST_GeomFromKML('<Polygon > <outerBoundaryIs> <LinearRing> <coordinates> 120.801170655354,14.632489189195,0 120.782956111463,14.5427894930054,0 120.76474480255,14.4530886861418,0 120.925219414103,14.4220920136416,0 120.943496765891,14.5117984961193,0 120.961777812394,14.6015038368517,0 120.801170655354,14.632489189195,0 </coordinates> </LinearRing> </outerBoundaryIs> </Polygon>')), ST_AsText(ST_GeomFromKML('<Polygon > <outerBoundaryIs> <LinearRing> <coordinates> 121.087312420981,14.6013782055702,0 121.071223131928,14.5142178677531,0 121.244070778376,14.4838207663532,0 121.260233278214,14.571006143522,0 121.087312420981,14.6013782055702,0 </coordinates> </LinearRing> </outerBoundaryIs> </Polygon>'))
"POLYGON((120.801170655354 14.632489189195,120.782956111463 14.5427894930054,120.76474480255 14.4530886861418,120.925219414103 14.4220920136416,120.943496765891 14.5117984961193,120.961777812394 14.6015038368517,120.801170655354 14.632489189195))";"POLYGON((121.087312420981 14.6013782055702,121.071223131928 14.5142178677531,121.244070778376 14.4838207663532,121.260233278214 14.571006143522,121.087312420981 14.6013782055702))"