KML file without coordinates - kml

Is it possible to create a KML file without coordinates in it? I have a list of addresses and I don't have the long/lat. I'd like to create a KML file and have Google Earth geocode and determine the long/lat for each placemark. Thanks in advance.

The geometry (e.g. Point, Polygon, etc.) in a KML Placemark is not required.
You can just have an address in your KML placemarks and Google Earth will automatically geodecode it for you if it can. Under the covers Google Earth will perform a lookup on that address and use the first match if any results are returned. Basically, the resolved address will be the same as if you entered an address via search panel in Google Earth or Google Maps.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>Google place</name>
<address>1600 Amphitheatre Parkway, Mountain View, CA</address>
</Placemark>
</kml>
After that if you save your KML then Google Earth will have inserted the coordinates for you into each Placemark.
<Point>
<coordinates>-122.083954,37.421998,0</coordinates>
</Point>

You can create KML file without coordinates when you have an address in your file. You can input the data from MS Excel for instance, if you are interested a batch operation. See the solution below:
http://www.mkrgeo-blog.com/input-a-multiple-address-list-in-google-maps-and-google-earth-the-quickest-way/
Then Google Earth will geocode your placemarks automatically when save it as a .kml file again.
It only works when you have no additional data in your excel column. If so, then you must import the Excel spreadsheet to the Google Earth directly, as per the explanation below:
https://gis.stackexchange.com/questions/298570/exporting-layer-from-google-my-maps-as-kml-has-no-geometries/332642#332642

Related

Not Time Slider for KML w/ Timestamps

I'm working with a large team to try and plot a series of events over time using Google Earth. We're trying to add timestamps to each event to enable us to filter the events we're viewing by time, but we can't get the time slider on Google Earth to open up and allow us to filter.
Right now, we're simply going in for every placemark and adding the timestamp under Placemark>Properties>View>Time/Date. We've successfully opened other KMLs with timestamped data and had the time slider show up, so we're not sure what we're doing wrong.
I've gone through the tutorial/instructions provided at https://developers.google.com/kml/documentation/time#gps
https://support.google.com/earth/answer/183758?hl=en
as well as did searches of the Google Earth help forums, but was unable to find any information that addressed our particular issue.
We're currently running Google Earth 7.1.1. Thanks for any help you can provide.
If you add time to a placemark in Google Earth using Placemark > Properties > View > Time/Date then you're actually setting the time by which historical imagery as the base map is viewed when the placemark is activated. This function in Google Earth adds a <gx:TimeStamp> or <gx:TimeSpan> to the placemark's view (LookAt or Camera) which doesn't define the time at which the placemark is visible. In other words, it sets the range of time slider not the placemark. The time slider controls historical imagery, sunlight, and visibility of time-stamped features.
The Google Earth and Google Earth Pro clients do not allow you to add times to your placemarks from which they become visible when the timer slider changes. This and other limitations of Google Earth with respect to editing KML is discussed in the KML Errata.
To add <TimeStamp> or <TimeSpan> elements to your KML you must edit the raw KML outside of Google Earth.
<Placemark>
<TimeStamp>
<when>2007-01-14T21:05:02Z</when>
</TimeStamp>
<Point>
<coordinates>-122.536226,37.86047</coordinates>
</Point>
</Placemark>

kml document auto refresh in google earth

I have an app that over time writes Placemarks to a kml file, slowly building up a route over time.
When I open the file in Google Earth, I can see the Placemarks already in the file, but any new ones added to the doc aren't shown on the map, until I reopen the document again.
Is there any way of getting the document to auto refresh in Google earth?
I've tried putting a NetworkLink into the document whose href points itself (the file) with a refreshMode of onChange, and that works, but the whole document is reloaded on each change and each point is displayed again, which is messy.
NOTE: I can't change the apps code, to generate single Placemark updates, which I believe is the proper way of using NetworkLinks.
The only way to perform incremental updates in KML is using the NetworkLinkControl element in conjunction with a NetworkLink.
NetworkLinkControl controls the behavior of files fetched by a <NetworkLink> in which you can change, add, or delete elements that you already fetched.
<NetworkLinkControl>
<cookie>cookie=sometext</cookie>
<linkName>link name</linkName>
<Update>
<targetHref>same-targethref-for-networklink</targetHref>
<Create>
<Document targetId="targetdoc">
<Placemark>
<name>Created place1</name>
</Placemark>
<Placemark>
<name>Created place2</name>
</Placemark>
</Document>
</Create>
...
</Update>
</NetworkLinkControl>
The NetworkLinkControl is tricky to get working such as the URLs in the NetworkLink and NetworkLinkControl must match exactly.
You can find a tutorial with an example to get started.
https://developers.google.com/kml/documentation/updates
So I guess you can't. I thought there might be some kind of structure within kml to achieve this, nut it would appear not.

Is there any maximum size for KML files to open in Google Earth/

I have created a kml file with 15.439 contour and each one has 360 coordinates. The file size is 369Mb.
When I try to open the file, Google Earth shows a message saying:
"Google Earth encountered a problem and needs to close. We are sorry for the inconvenience."
Is there any size restrictions for KML files? I have verified the kml code and it's ok. It works perfectly with 950 contours and 16Mb.
Is there any other program able to open this kml file?
Thanks for the help!
jluiz20
Your KML file has over 3 million coordinates which is hitting some upper limit for a single KML file in Google Earth. You can scale to that number of contours/features and more if you break it up into smaller KML files, load them in a parent KML via NetworkLinks, and use Regions to only load those features that are in view.
Google Earth can scale up to millions of points and features but not all at once.
If the 15,439 features are geographically separable then you can break up the KML by some geographic grouping or fixed gridded area each in its own KML. Maybe 15 KML files each with 1000 features might be a good starting place.
The parent KML should have each NetworkLink with the appropriate Region and Level of detail (Lod) element to prevent all of the KML files from loading all at once.
Here's the structure of the parent KML file:
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<NetworkLink>
<name>area 1</name>
<Region>
<LatLonAltBox>
<north>xx</north>
<south>xx</south>
<east>xx</east>
<west>xx</west>
</LatLonAltBox>
<Lod>
<minLodPixels>32</minLodPixels>
</Lod>
</Region>
<Link>
<href>1.kml</href>
</Link>
</NetworkLink>
<NetworkLink>
<name>area 2</name>
...
</NetworkLink>
...
</Document>
</kml>
Yes there are restrictions. Check out the docs under
https://developers.google.com/kml/documentation/mapsSupport?csw=1
I ran into similar problems with a 60mb file.
You can use the workaround using Network links but according the docs they only support less than 10.

How does a KML file help in loading maps in the Google Earth?

https://developers.google.com/kml/documentation/kml_tut
KML uses a tag-based structure with nested elements and attributes and is based on the XML standard.
So, KML is basically a "text" file, it doesn't contain the maps.
How does Google Earth use KML files to show maps? Does it treat KML file as an "index" to know which of its maps to pick when user presses x button?
KML is an XML language used to annotate the Earth with points, lines, polygons, 3d models, and overlays.
As an analogy, HTML is a language to structure and represent textual information and multi-media in a 2-D document context within a web browser. Likewise, KML is a language to structure and represent geospatial and temporal entities on a map and show in "earth browsers" such as Google Earth.
Specifically KML allows you to :
Specify icons and labels to identify locations on the surface of the planet
Create different camera positions to define unique views for geographic features
Define image overlays to attach to ground or screen
Define styles to specify KML feature appearance
Organize KML features into hierarchies
Locate and update retrieved KML documents from local or remote network locations
KML is a structured format of data that tells Google Earth how to display the data (point, line, icons, colors, styles, etc.) and where to draw it (longitude and latitude optionally at a given altitude). KML is simply a data exchange format.
Here's a simple KML file:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>New York City</name>
<description>New York City</description>
<Point>
<coordinates>-74.006393,40.714172</coordinates>
</Point>
</Placemark>
</Document>
</kml>
As an "index", a KML file by default will load at the center point that covers all includes features in the KML, but that can be overridden if a LookAt or Camera is defined. If you click on a Placemark it will fly to that feature as defined by its coordinates.
Clicking on such a placemark in Google Earth will fly to that location, which for the example above happens to be New York City.
KML is a "text" file that can also be packaged and distributed in a "KMZ" file, which is a ZIP file with .kmz file extension.
More details about KML can be in the OGC KML Standard # 07-147r2 .

How to display a moving boat in Google Earth?

I am new to the KML format and try to figure out how to display a boat (a png), moving from a place to another along a path (a simple line drawn composed of several lines).
I can see how to display a Placemark, even with an icon, and a Path, separately.
What I would like to see when I click on the KML file is :
the boat appearing at the departure point;
the path drawing itself until the arrival;
the boat icon moving at a comfortable speed (bonus point it I can set a ration time / progress, extra bonus if I can click on start, pause or rewind) from departure to arrival along the path.
Is that even possible ? I know it is with Google Map, but you can program it with Javascript, which eases things a lot.
This is an old question, and there is now a better way to move a placemark (or even better a model) along a pre-determined linestring. Look into using this feature:
http://code.google.com/apis/kml/documentation/kmlreference.html#gxtrack
Sample code:
<?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">
<Folder>
<Placemark>
<gx:Track>
<when>2010-05-28T02:02:09Z</when>
<when>2010-05-28T02:02:35Z</when>
<when>2010-05-28T02:02:44Z</when>
<when>2010-05-28T02:02:53Z</when>
<when>2010-05-28T02:02:54Z</when>
<when>2010-05-28T02:02:55Z</when>
<when>2010-05-28T02:02:56Z</when>
<gx:coord>-122.207881 37.371915 156.000000</gx:coord>
<gx:coord>-122.205712 37.373288 152.000000</gx:coord>
<gx:coord>-122.204678 37.373939 147.000000</gx:coord>
<gx:coord>-122.203572 37.374630 142.199997</gx:coord>
<gx:coord>-122.203451 37.374706 141.800003</gx:coord>
<gx:coord>-122.203329 37.374780 141.199997</gx:coord>
<gx:coord>-122.203207 37.374857 140.199997</gx:coord>
</gx:Track>
</Placemark>
</Folder>
</kml>
The only way I've been able to make this work in static KML is to interpolate between the start and stop points and add placemarks for each frame I want to animate. So, from t=0 to t=1, draw a placemark at the start point. From t=1 to t=2, draw a placemark at the next point, etc.
This gives you the temporal player bar in Google Earth and you can rewind or advance the animation. However it is a little annoying because you wind up with every interpolation point in your placemark tree. Putting the placemarks in their own folder keeps them out of the way, but there's no way to hide them from the user.
Take a look at http://code.google.com/apis/kml/documentation/time.html#animating
The whale shark example does more or less what you want for the placemark. (The URL for the marker icon is broken). Animating the progress along the track can be done using the same trick.
If you want to try something much more difficult, you can try serving dynamic KML. Have Google Earth load a network link to your initial data. Then load another network link with an that sends an update for your placemark at every time tick.
http://code.google.com/apis/kml/documentation/kmlreference.html#link
http://code.google.com/apis/kml/documentation/updates.html
This approach has some serious disadvantages because it requires an external program to drive Google Earth and it does not give the user access to the built-in Google Earth temporal player bar. It also requires that all the data be loaded over a network link -- KML data from a file cannot be updated. That means your driver program needs to act as a http server. Also, in this model it is very hard to know exactly when Google Earth has finished loading and drawing the update. Really I don't recommend doing this; you can make it work using the Google Earth COM API, but it will always be a fragile solution.
There's a browser plug-in that lets you embed Google Earth into a browser page. From there you can use JavaScript to animate your placemark, change your paths, etc. Check out the Google Earth API Developer's Guide.
If you are going to display a boat on Google Earth, a 3D model would be a better approach then an image, since the users can change the viewing angle.
You might want to look into tours: http://code.google.com/apis/kml/documentation/touring.html
I've seen something like this done using a combination of (a number of) <gx:AnimatedUpdate> tags to move a previously created placemark representing your boat and <gx:FlyTo> tags to move the view (I think) all within a <gx:Playlist>.
Hope this helps.
I'm presuming this functionality did not exist when originally answered, but you can achieve the effect using a tour. The following shows a placemark moving in this fashion.
<?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>
<Placemark id="boat">
<Point>
<coordinates>0,0</coordinates>
</Point>
</Placemark>
<gx:Tour>
<name>Play me!</name>
<gx:Playlist>
<gx:FlyTo>
<gx:duration>5.0</gx:duration>
<LookAt>
<longitude>0</longitude>
<latitude>0</latitude>
<altitude>0</altitude>
<heading>-95</heading>
<tilt>65</tilt>
<range>250000</range>
<altitudeMode>relativeToGround</altitudeMode>
</LookAt>
</gx:FlyTo>
<gx:AnimatedUpdate>
<gx:duration>5.0</gx:duration>
<Update>
<targetHref/>
<Change>
<Placemark targetId="boat">
<Point>
<coordinates>1,1</coordinates>
</Point>
</Placemark>
</Change>
</Update>
</gx:AnimatedUpdate>
<gx:Wait>
<gx:duration>6.0</gx:duration>
</gx:Wait>
</gx:Playlist>
</gx:Tour>
</Document>
</kml>
The path could be marked with points whose visibility is altered by the tour at the appropriate time.
I have following sample in Google site. Hope this help.
(details inside : https://sites.google.com/site/canadadennischen888/home/kml/auto-refresh-3d-tracking)
prepare a RestFul service to generate KML file from DB
(sample as in https://sites.google.com/site/canadadennischen888/home/kml/3d-tracking)
My other code will generate a KMZ file which has a link to my Restful service
(sample as in this page)
KMZ file has onInterval
Web page allow user to download KMZ file which has URL that link to my Restful service
When Google Earth open KMZ file, Google Earth will auto refresh to get new data from that Restful service
Just google for "kml time animation"
KML: Time and Animation
KML: Animation
Animation and Dynamic Updates with KML

Resources