Saturday, May 17, 2014

Dude, your KML is too long

My Google Fusion Tables challenge this week was a single shapefile/kml that had about 25 different polygons in the same layer, which when I converted it to KML it put them all within the same tag. Fusion tables would only show some of the shapes on the map, even though they all showed in the KML preview of the data row.

What the Fusion Tables map showed

What the KML preview from the data showed (which is correct)

So I put a question about it into the Fusion Tables API Users Google Group. Folks there explained there is a limitation with Fusion Tables (or maybe the Maps API) that shows only the 10 largest polygons if there are multiple in a Placemark in the KML file. They suggested I use “Singleparts to multipart” tool in QGIS to split the shapes.

Well, I tried that, but I got the following error and couldn't make it work not matter what I tried in that dialog.

So, I peaked at the KML file in a text editor. After all, it's really just an XML file, which is by nature structured, so I hoped I could figure out how it worked and split the file myself. I could see the and tags with very long, multiple tags.

Word wrap is off, but the white line is really, really long.

So I duplicated the tag and then pulled out enough tags to make sure I had no more than 10 within a specific  Luckily there wasn’t too much data to this shape, or that would’ve been a nightmare. The final KML looked like this:

Now there are three tags, each with no more than 10 polygons.

  © Blogger template 'A Click Apart' by 2008

Back to TOP