The <Camera> element, new to KML 2.2, provides a way to define your observer’s viewpoint in terms of position and viewing direction, and is a child element of any <Feature>. Features can include Placemark, NetworkLink, Folder, Document, PhotoOverlay, ScreenOverlay, and GroundOverlay. In previous KML versions (2.1 and earlier) a similar element, <LookAt> was used to define the placement and orientation of the camera.
Differences Between <Camera> and <LookAt>
Let’s take a look at these two elements to determine how they differ.
As you can see from these figures the two elements look quite similar, but they have some fundamental differences. Let’s start with the <longitude> and <latitude> child elements. In <LookAt>, these elements refer to the point the camera is looking at, whereas in <Camera> these elements refer to the virtual camera (eye point). This is an important distinction. <LookAt> specifies the view in terms of the point of interest while <Camera> specifies the view in terms of the viewer’s position and orientation. Similarly, the <altitude> element refers to the altitude of the point of interest for <LookAt> whereas it refers to the distance of the camera from the earth’s surface for <Camera>.
There are some additional differences between the two elements. For instance, <LookAt> contains a <range> child element that specifies the distance in meters from the point of interest specified by <longitude>, <latitude>, and <altitude> to the LookAt position. The <Camera> element does not contain this particular element. In addition, the <Camera> element also provides additional functionality for controlling the tilt of the camera view. The <tilt> element in <Camera> can be any value between 0 and 180 which gives you the ability to tilt the camera above the horizon into the sky, whereas in <LookAt> you are limited to a value between 0 and 90. In either element, a value of 0 indicates that viewing is from directly above, while a value of 90 indicates viewing along the horizon. Because <LookAt> can contain only values between 0 and 90 you are limited to viewing from directly above through a horizontal view. As I mentioned above, the <tilt> values for <Camera> can range from 0 to 180 with values greater than 90 indicating a view that is pointed above the horizon toward the sky. Finally, the <roll> element on Camera gives you the ability to rotate the camera around the Z axis and can contain any value between -180 and +180 degrees.
Now we’ll take a look at a few examples that illustrate different <Camera> settings taken from the San Diego Convention Center and Petco Park. You can download the file containing all examples here. You’ll want to make sure you turn on the 3D buildings in the Google Earth layers panel before opening the file.
This first example shows a <Camera> with a heading of 90 degree (East) and a tilt of 90 degrees (toward horizon). Remember that headings can be any value between 0 (north) and 360. The default is 0 or north. The Camera in this case is placed at an altitude of 100 meters.
In the next example, we set the <tilt> value to 0 which will set the camera to look straight down toward the earth. We’re also setting the <heading> to north and the <altitude> to 500 meters.
Now let’s try something a little different. In this next example, we’re going to take a look inside Petco Park from the viewpoint of a major league baseball platter in the batter’s box. In this case we are setting the <tilt> to 110 which points slightly up into the sky. We’re also setting the altitude to slightly above sea level.
Finally, we’ll examine the <roll> element which rotates the camera around the Z axis with values ranging from -180 to +180. Sticking with our Petco Park example, assume that the pitcher has thrown a wild pitch and hit the batter! The batter has subsequently fall down. Ouch! Using the <roll> element with a value of 45 which will roll the camera to the left we can simulate the viewpoint of the batter who is now lying on the ground.
Hopefully these examples have helped illustrate how you can use the Google Earth <Camera> element to control the user viewport and using your imagination you can come up with some creative ways to use these features in your analysis of geographic data.
For detailed information about KML, Google Earth, or Google Maps please see the following e-learning courses provided by GeoSpatial Training Services.