I am trying to use the google earth pro desktop application for visualizing IoT sensor data at different locations. Unfortunately, due to the limitations of google earth, I am unable to visualize 4GB of kml file at a time, as it throws the error "empty KML file".
I tried changing the memory cache limits under Tools -> Options -> Cache and there was no use.
I tried splitting the 4GB kml file into multiple smaller 70MB files and opening multiple files in google earth. It is becoming unresponsive and is loading very slow after opening two files.
The data is timeline data with sensor values from different locations. We need to visualize all (at least half) data so that we can use the timeline slider and see the changes over time.
It would be great to get some suggestions/alternatives to solve the issue.
Thanks.
If a KML file is very large then trying to display all the features at once can crash Google Earth Pro, affect performance with sluggish response, etc. Large KML files can be viewed in Google Earth if all or some of these techniques are applied to the KML.
NetworkLink
Folder Radio style or explicit visiblity=0
Number of Points per feature and geometry simplification
NetworkLink
A root .kml file can reference all the sub-KML files, but the referenced sub-files should have the visibility off so the user must manually check it to be visible. This will prevent all the data from being displayed all at once.
Here is the structure of the root KML file:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<NetworkLink>
<name>NetworkLinked sub-item1</name>
<visibility>0</visibility>
<Link>
<href> kml1.kml </href>
</Link>
</NetworkLink>
<NetworkLink>
<name>NetworkLinked sub-item2</name>
<visibility>0</visibility>
<Link>
<href> kml2.kml </href>
</Link>
</NetworkLink>
...
</Document>
</kml>
Radio Folder
You can further restrict what is displayed at a given time using radio folders.
Here's a radio folder example allowing the user to only choose one of the NetworkLinks at a time. This is used when the content is mutually exclusive and only one set of features should appear at any given time.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="rf">
<ListStyle>
<listItemType>radioFolder</listItemType>
</ListStyle>
</Style>
<Folder>
<name>One at a time example</name>
<open>1</open>
<description>Link 1 visible by default</description>
<styleUrl>#rf</styleUrl>
<NetworkLink>
<name>NetworkLinked sub-item-1</name>
<Link>
<href> kml1.kml </href>
</Link>
</NetworkLink>
<NetworkLink>
<name>NetworkLinked sub-item-2</name>
<visibility>0</visibility>
<Link>
<href> kml2.kml </href>
</Link>
</NetworkLink>
</Folder>
</Document>
</kml>
Number of Points per feature and geometry simplification
Size of the KML file and number of features is not the only issue to consider. A KML file with a single hi-res polygon having 350K points and 7000 inner holes can cause Google Earth performance issues. Such geometries would need to be simplified and the number of points reduced. You can use QGIS to open a KML file then apply a simplify algorithm on the polygon. In QGIS, select Vector menu -> Geometry tools -> Simplify then save the result.
Related
I have seen examples where it is possible to display a bitmap as a vertical profile in Google Earth. Like this:
However, I have not been able to find any kml/kmz examples of this. Does anyone have a simple example of how to do this?
Does it include using the dae (collada) file format too?
One method to do this would be to use a KML "Photo Overlay". They are designed to place landscape photographs vertically in the world, so that they can be viewed with the Earth terrain & imagery as matching background. You could use that technique to place images like these on vertical planes. There is a basic tool in Earth Pro to create Photo Overlays (Add menu >> Photo). Or you can create them manually or programmatically by writing the appropriate KML (reference links below), though it can get pretty complex with all the placement and field of view parameters. Also note that Photo Overlays work in Earth Pro (Earth v7.x), but do not currently work in Earth for web & mobile (Earth v9.x).
You could also do this using 3D models (yes, collada based) where you have a model representing your vertical plane(s), and the images as textures on the models. 3D models also only work in Earth Pro at this time. Which technique is easier will depend on the tools and skills you have available.
https://developers.google.com/kml/documentation/photos
https://developers.google.com/kml/documentation/kmlreference#photooverlay
My PhotoOverlay example is just here.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document id="7">
<visibility>0</visibility>
<PhotoOverlay id="8">
<name>PhotoOverlay Test</name>
<visibility>0</visibility>
<Camera>
<longitude>-122.3599987260313</longitude>
<latitude>47.62949781133496</latitude>
<altitude>100</altitude>
<heading>-90</heading>
<tilt>90</tilt>
<roll>0</roll>
</Camera>
<Icon id="10">
<href>foo.png</href>
</Icon>
<ViewVolume>
<leftFov>-45</leftFov>
<rightFov>45</rightFov>
<bottomFov>-45</bottomFov>
<topFov>45</topFov>
<near>20000</near>
</ViewVolume>
</PhotoOverlay>
</Document>
</kml>
My kml example using collada is here.
You have to prepare your_prepared_square.dae and your_prepared.png in same folder. The square size is 1m x 1m. This model is scaling base.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document id="1">
<Placemark id="2">
<name>My billboard</name>
<Model id="3">
<altitudeMode>absolute</altitudeMode>
<Location>
<longitude>140.037</longitude>
<latitude>36.84895</latitude>
<altitude>500</altitude>
</Location>
<Orientation>
<heading>90</heading>
<tilt>0</tilt>
<roll>0</roll>
</Orientation>
<Scale>
<x>1</x>
<y>10000</y>
<z>3500</z>
</Scale>
<Link id="4">
<href>your_prepared_square.dae</href>
</Link>
<ResourceMap>
<Alias>
<targetHref>your_prepared.png</targetHref>
<sourceHref>mapping.png</sourceHref>
</Alias>
</ResourceMap>
</Model>
</Placemark>
</Document>
</kml>
And mapping.png is texture filename in the collada model. This has
to be defined in the model. following fragment is a part of your_prepared_square.dae. But you don't need to prepare mapping.png. KML replaces it to your_prepared.png.
:
:
<library_images>
<image id="texture" name="texture">
<init_from>mapping.png</init_from>
</image>
</library_images>
:
:
folllowing image is applied this method.
Using the below format as starting point I would like to know how to solve the following problem. This is an example for a Root KML file that links to other KMLs. My problem is that people modifying sub1.kml might change the name from sub1.kml to sub1-05-OCT-16.kml or want to add another KML called sub1-a.kml. Once this occurs the network link is no longer valid. I can't link to a folder from what I have seen and I do not want o have to change this file everytime. Is there an esiaer solution I'm overlooking?
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<NetworkLink>
<name>NetworkLinked sub-item</name>
<Link>
<href> kml/sub1.kml </href>
</Link>
</NetworkLink>
<NetworkLink>
<name>NetworkLinked sub-item</name>
<Link>
<href> kml/sub2.kml </href>
</Link>
</NetworkLink>
</Document>
</kml>
A network link must point at a specific KML (or KMZ) file. Unfortunately there's no way to point it at a folder or directory and somehow get the list of files and pick out all the KML/KMZs. So you'll need to either make sure that the target file names stay the same, or update your NetworkLinks when they change.
I want to get coordinates every second and update the track on google earth in the kml file
I know i need a network link with an update that is added coordinates with the time and refresh it every second but i couldn't find any complete examples that show this and the update part is confusing me. I was wondering if someone could write out a simple example?
If you want to generate KML and update on a regular interval then you create a root KML such as this:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<NetworkLink>
<name>NetworkLink example</name>
<Link>
<href>http://...</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>5</refreshInterval>
</Link>
</NetworkLink>
</kml>
If your area of interest is a "small" or locallized then you may want to add a Region to the NetworkLink and viewRefreshMode element with onRegion value to only refresh when the region is active (e.g., within the current view).
<NetworkLink>
<name>NetworkLink example with Region</name>
<Region>
</Region>
...
<Link>
<href>http://...</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>5</refreshInterval>
<viewRefreshMode>onRegion</viewRefreshMode>
</Link>
</NetworkLink>
For NetworkLinkControl a tutorial can be found here with a working example.
https://developers.google.com/kml/documentation/updates
I have created a network link that references another KML file with actual data to be loaded into Google Earth. My issue is that the number of points in the referenced KML file is so large that it crashes Google Earth if the KML file folder underneath the Places tab in Google Earth is set to "Allow this folder to be expanded" (right-click KML, properties). By default, this checkbox is checked. I want to make it so that for every network link I create the folder by default will not be expandable.
I have looked up checkHideChildren in Google Earth KML tutorials, but that line provides no results, and I am not entirely sure where I am supposed to place the line in the Network Link KML.
Here is example code, if you could point me in the direction where to place this line of code, or an entirely different approach, it would be greatly appreciated!
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<NetworkLink>
<name>
CPU
</name>
<refreshVisibility>1</refreshVisibility>
<Link id="GPS_Plotter Updater">
<href>CPU.kml</href>
<Style id="style1"><ListStyle>
<listItemType>checkHideChildren</listItemType> <-- this is the line that should be hiding the children points of the KML!
</ListStyle>
</Style>
<styleUrl>#style1</styleUrl>
<refreshMode>onInterval</refreshMode>
<refreshInterval>1</refreshInterval>
<viewRefreshMode>onRegion</viewRefreshMode>
<viewRefreshTime>1</viewRefreshTime>
</Link>
</NetworkLink>
</kml>
Try putting the Style element in the NetworkLink, not the Link element. Link doesn't take a style selector, but NetworkLink does. If that doesn't work, try a listItemType of radioFolder instead.
In addition to Mano Marks' suggestions you also need to move the styleUrl element to the NetworkLink otherwise it won't apply. Note in your example you have viewRefreshMode=onRegion but don't have a region defined for it.
Here's the complete working example to suppress the NetworkLink contents.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<NetworkLink>
<name>CPU</name>
<styleUrl>#style1</styleUrl>
<Style id="style1">
<ListStyle>
<listItemType>checkHideChildren</listItemType>
</ListStyle>
</Style>
<Region>
<!-- define region here -->
</Region>
<refreshVisibility>1</refreshVisibility>
<Link id="GPS_Plotter_Updater">
<href>CPU.kml</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>1</refreshInterval>
<viewRefreshMode>onRegion</viewRefreshMode>
<viewRefreshTime>1</viewRefreshTime>
</Link>
</NetworkLink>
</kml>
You can catch errors like this by validating your KML. Try using the Galdos KML Validator.
I am developing an application that launches Google Earth with a KML file that links to other local files via <NetworkLink>, which does Time Interval refreshing. I'm trying to define a KML file that will center the map (fly to) a specific location.
Network Link has a tag which flies to the first placemark or FlyTo within the file. However, this would execute the fly to whenever the file is refreshed, which in my case, is when the Time Interval expires. Is there some way that I can have the fly-to command execute only when the linked network file changes, rather than every time? Is there any way to have the Fly To process only once until the linked file is changed somehow? My NetworkLink file is defined as follows:
<NetworkLink>
<name>My Fly To Request</name>
<Link>
<href>MyFlyTo.kmz</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>2</refreshInterval>
</Link>
</NetworkLink>
The application will frequently update the the specific placemark to be centered on when the user requests. It is not a static placemark that needs to be centered on, but one that will change frequently.
I believe you could achieve this by using a combination of ID attributes and the NetworkLinkControl and Update element in Kml.
The MyFlyToRequest.kml file contains the NetworkLink that loads the data file, which contains your data, it has the flyToView element set to true. Notice too the network link also has an id of request
MyFlyToRequest.kml
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<NetworkLink id="request">
<name>My Fly To Request</name>
<Link>
<href>http://www.yourserver.com/MyFlyTo.kmz</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>2</refreshInterval>
</Link>
<flyToView>1</flyToView>
</NetworkLink>
</kml>
The second file, MyFlyTo.kmz, is the one loaded. It has your current data as is..,However, it would also have an additional NetworkLink that loads a new third file.
MyFlyTo.kmz - Edited
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document id="data">
<visibility>1</visibility>
<NetworkLink>
<name>Update MyFlyToRequest</name>
<Link>
<href>http://www.yourserver.com/TurnOffFlyTo.kml</href>
</Link>
</NetworkLink>
<Placemark>
<name>This is flown to once (hopefully)</name>
<Point>
<coordinates>52,0,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
The new third file TurnOffFlyTo.kml is part of the key to the set up, it contains a NetworkLinkControl that targets the request NetworkLink in the first MyFlyToRequest.kml file. It simply sets flyToView element to 0.
TurnOffFlyTo.kml
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<NetworkLinkControl>
<Update>
<targetHref>http://www.yourserver.com/MyFlyToRequest.kml#request</targetHref>
<Change>
<NetworkLink id="request">
<!-- turn off the flyto behaviour -->
<flyToView>0</flyToView>
</NetworkLink>
</Change>
</Update>
</NetworkLinkControl>
</kml>
The final file TurnOnFlyTo.kml simply retoggles the flyto behaviour again.
TurnOnFlyTo.kml
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<NetworkLinkControl>
<Update>
<targetHref>http://www.yourserver.com/MyFlyToRequest.kml#request</targetHref>
<Change>
<NetworkLink id="request">
<!-- turn off the flyto behaviour -->
<flyToView>1</flyToView>
</NetworkLink>
</Change>
</Update>
</NetworkLinkControl>
</kml>
The logic is as follows.
MyFlyToRequest.kml loads MyFlyTo.kml
flyto is enabled so the view moves the first first placemark, etc, in MyFlyTo.kml
The link in MyFlyTo.kml loads TurnOffFlyTo.kml.
The Update in TurnOffFlyTo.kml three disables flyto in MyFlyToRequest.kml.
File one, refreshes, loads file two...
If you need to re-enable the flyto, you would simply load File four. If the data in MyFlyTo.kmz is being generated by you it would be a simple case of loading TurnOnFlyTo.kml right where TurnOffFlyTo.kml was called.
All that said, this is not tested and as such might not work as is, although in principal I don't see why it wouldn't.
If it sounds like something you might try here are a few resources that should help.
NetworkLinkControl Reference
http://code.google.com/apis/kml/documentation/kmlreference.html#networklinkcontrol
Using Updates
http://code.google.com/apis/kml/documentation/updates.html