locked
Import KML data? RRS feed

  • Question

  • Hi folks - can we import KML data into Sql Server 2008? If not, are there some tools? if not .. is there a better format I could convert our data into, and then import that?

     

    Cheers folks Smile

     

     

    PS. Is this the best forum to ask SQL2008 Spatial questions, still?

    Thursday, October 30, 2008 6:03 AM

Answers

  • The only formats you can directly import into SQL Server are WKT, WKB, or GML (or SQL Server's own native binary format).
    So, if you can output one of those formats, that's your easiest option.

    If not, there are a couple of ways you could go about converting KML... depending on how much you want to spend, and how much of the metadata associated with the kml file you want to retain.

    KML and GML are both XML-based languages, so it is relatively simple to write a custom transformation between the two using either XQuery or XSLT. Most KML elements have a direct GML equivalent, but there are a few gotchas along the way (such as the co-ordinate-ordering issue), and the other thing to remember is that whilst GML only contains those elements necessary to describe the geometrical properties of a feature, KML contains additional styling information, descriptions etc. that will be lost in the process.

    There are some free tools you can find to convert from KML - most of them seem to convert to shapefile format (google for kml2shp) - from which you could import the data SHP using Morten Nielsen's Shape2Sql. Again though, you will lose the additional KML metadata.

    Or, if you want the commercial alternative, FME from Safe software has been recommended lots of times on this forum for all sorts of conversion/importing needs (www.safe.com)

    Thursday, October 30, 2008 9:50 AM
    Answerer

All replies

  • The only formats you can directly import into SQL Server are WKT, WKB, or GML (or SQL Server's own native binary format).
    So, if you can output one of those formats, that's your easiest option.

    If not, there are a couple of ways you could go about converting KML... depending on how much you want to spend, and how much of the metadata associated with the kml file you want to retain.

    KML and GML are both XML-based languages, so it is relatively simple to write a custom transformation between the two using either XQuery or XSLT. Most KML elements have a direct GML equivalent, but there are a few gotchas along the way (such as the co-ordinate-ordering issue), and the other thing to remember is that whilst GML only contains those elements necessary to describe the geometrical properties of a feature, KML contains additional styling information, descriptions etc. that will be lost in the process.

    There are some free tools you can find to convert from KML - most of them seem to convert to shapefile format (google for kml2shp) - from which you could import the data SHP using Morten Nielsen's Shape2Sql. Again though, you will lose the additional KML metadata.

    Or, if you want the commercial alternative, FME from Safe software has been recommended lots of times on this forum for all sorts of conversion/importing needs (www.safe.com)

    Thursday, October 30, 2008 9:50 AM
    Answerer
  •  

    I think i can get our commercial data as a shp file also. that means i don't need to convert it, and then use MN's program to dump it into sql server.

     

    As to programming my own converter? no time.

     

    besides that - awesome! that's the prompt answers Smile

    Thursday, October 30, 2008 10:56 PM