Skip to main content
Solved

Split single KML into multiple KML files with equal record count

  • August 14, 2016
  • 2 replies
  • 609 views

I have a large KML file that I would like to split into several smaller equal size KML. My original KML file has 311,055 polygon records and is too large to open in Google Earth as is. I would like to create several sub files from this file (e.g. 5 KML files with 62,211 records each).

Best answer by todd_davis

Pass all features through ModuloCounter with Count Maximum set as 5. Then set "_modulo_count" as the fanout on the KML writer (e.g. @Value(_modulo_count).kmz ). You will get 5 output kmz called 0.kmz, 1.kmz, 2.kmz, 3.kmz, 4.kmz.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

todd_davis
Influencer
Forum|alt.badge.img+23
  • Influencer
  • Best Answer
  • August 14, 2016

Pass all features through ModuloCounter with Count Maximum set as 5. Then set "_modulo_count" as the fanout on the KML writer (e.g. @Value(_modulo_count).kmz ). You will get 5 output kmz called 0.kmz, 1.kmz, 2.kmz, 3.kmz, 4.kmz.


arnold_bijlsma
Enthusiast
Forum|alt.badge.img+15

And once you have split your big KMZ file into 5 smaller ones, you might want to create a single master KMZ file that references all 5 KMZ files using KML Network Links. This means your users will only be dealing with just one file, because the other 5 get loaded behind the scene.

Initially, it will be a bit tricky to get your head around how FME deals with KML, but basically:

  1. Create a Writer for your 'master.KMZ'
  2. In this writer, there is only 1 feature type, and the name must be set to 'NetworkLink', because this KMZ will not contain any features, only links to your 5 KMZ files.
  3. Before your Writer, you will need an AttributeCreator (or AttributeManager) where you set 'kml_id' and 'kml_name' to your group name, e.g. 'Group @Value(_modulo_count)' and your 'kml_link_href' attribute to 'MyDataFolder/@Value(_modulo_count).kmz'. I have attached a screenshot of the AttributeCreator in one of my workspaces, where I have created a separate KMZ for each PostcodeDistrict.

Also see Google Documentation on KML Network Links and an example how this KML Network Link is implemented in FME