I have a proof-of-concept I'm trying to put together but am flailing a bit.
Here's what I want to achieve:
- Input tool: reading an existing .kml file
- Formula tool: add <color></color> attribute
- Formula tool: set color to green
- Output tool: save as .kml
I've created a .kml file with the following schema:
<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document><Folder><name>TestLocations</name>
<Schema name="TestLocations" id="TestLocations">
<SimpleField name="Name" type="string"></SimpleField>
<SimpleField name="Address" type="string"></SimpleField>
<SimpleField name="City" type="string"></SimpleField>
<SimpleField name="ST" type="string"></SimpleField>
<SimpleField name="Latitude" type="float"></SimpleField>
<SimpleField name="Longitude" type="float"></SimpleField>
<SimpleField name="Comments" type="string"></SimpleField>
</Schema>
<Placemark>
<name>ABC123</name>
<description>123 MAIN AVE</description>
<ExtendedData><SchemaData schemaUrl="#TestLocations">
<SimpleData name="Name">ABC123</SimpleData>
<SimpleData name="Address">123 MAIN AVE</SimpleData>
<SimpleData name="City">NEW YORK</SimpleData>
<SimpleData name="ST">NY</SimpleData>
<SimpleData name="Latitude">45.4133</SimpleData>
<SimpleData name="Longitude">-74.0794</SimpleData>
<SimpleData name="Comments"></SimpleData>
</SchemaData></ExtendedData>
<Point><coordinates>-74.0794,45.4133,0</coordinates></Point>
</Placemark>
I recognize there needs to be a <color>green</color> attribute added after the <Placemark>. Before I get to this step, I've tried to read the file using a .csv format but get an error saying there are too many fields. So here's where I'm flailing. How do I read it, edit it, then save it?
My end goal is a .kml file which will be used in ESRI's ArcExplorer.
For reference, this is a sample Google .kml file:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Placemark>
<Style id="WhateverYouWantHere">
<BalloonStyle>
<color>ff007db3</color>
</BalloonStyle>
</Style>
<name>The Great Sphinx of Egypt</name>
<description>The Great Sphinx of Egypt</description>
<LookAt>
<longitude>31.1376421035748</longitude>
<latitude>29.97531730109229</latitude>
<range>197.0202883013975</range>
<tilt>27.35354524205621</tilt>
<heading>-140.3945943869927</heading>
</LookAt>
<styleUrl>#WhateverYouWantHere</styleUrl>
<styleUrl>root://styleMaps#default+nicon=0x307+hicon=0x317</styleUrl>
<Point>
<coordinates>31.13764210357481,29.97531730109229,0</coordinates>
</Point>
</Placemark>
</kml>
Thanks for the input in advance!
Todd