Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using KML, XML, and XSL to Create Google Earth Applications: A Tutorial Betsy Page Sigman and William Garr Georgetown University Southeast Decision Sciences.

Similar presentations


Presentation on theme: "Using KML, XML, and XSL to Create Google Earth Applications: A Tutorial Betsy Page Sigman and William Garr Georgetown University Southeast Decision Sciences."— Presentation transcript:

1 Using KML, XML, and XSL to Create Google Earth Applications: A Tutorial Betsy Page Sigman and William Garr Georgetown University Southeast Decision Sciences Institute Conference Orlando, Florida February 22, 2008

2 Overview 1.The benefits of displaying data using Google Earth/Google Maps (GE/GM) 2.KML and the creation of placemarks in Google Earth/Google Maps 3.Use an Access database to create many placemarks simultaneously 4.Create different styles of placemarks based on the value of an attribute.

3 Why Use Google Earth/Maps to Show Data 1) Allows the viewer to understand the data more fully. 2) Can enable the viewer to use the data more easily. 3) Gives a more comprehensive view about how the data presented relate to each other. 4) Can aid in decision support, due to the properties discussed above.

4 Getting Information from a Placemark 1.From information listed on the placemark (i.e. Address, Contact person, Phone, Email, etc.) 2.From the geographic location of the placemark. 3.From an attribute of the icon used (i.e. shape, color)

5 XML XML stands for “eXtensible Markup Language.” Extensible means that it can be extended to create whatever tags you want.

6 How it differs from HTML XML holds data HTML presents data XML is about what data is HTML is about how data looks XML is for data description HTML is for data display

7 Example of XML Rebecca Donald Remember Don’t forget your MIS final Right now, this doesn’t do anything. You’d have to send it or display it.

8 Simple KML File 1. 2. 3. Washington, D.C. 4. Washington, D.C. 5. 6. -76.5427,38.583314,0 7. 8. 9.

9 Ways to Create a KML File 1) Use Google Earth’s placemark creator. 2) Use a plain text editor such as Notepad or an XML editor. Output data from a database in the correct format. Later, we show how to do this with an Access database and an XSL transform.

10 Creating a Placemark Open up Google Earth. Click on yellow pushpin icon. Cursor over yellow box until cursor turns into a pointing finger. Now move the box where you want to put the placemark. Fill in a description. Click “OK.” Look over at sidebar on left; you should see a label with whatever you called your placemark.

11 Creating a Placemark (cont.) Click on the link on the left to go to the placemark. Right click and go to “Properties.” Click on icon in upper right corner of box to select a different icon.

12 Creating a Placemark (cont.) Experiment with changing the following: –Shape –Color of placemark –Scale –Opacity –Color, Scale and Opacity of Label –View –Altitude

13

14

15

16

17 Examine the KML After you’ve changed the settings, close out of the placemark by clicking “OK.” Now find your file over on the left, right click, select “Copy” and paste it into a Notepad file. You will see the KML for the placemark you just created.

18 KML Placemark (Page 1) KmlFile 1.3 http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png normal #sn_ylw-pushpin2

19 KML Placemark (Page 2) highlight #sh_ylw-pushpin1 1.1 http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png Test Placemark One Here is where test placemark one is located.

20 KML Placemark (Page 3) 26.41145107108635 12.13590310050818 0 7891159.275852153 1.397977576698283e-014 11.99119024368262 #msn_ylw-pushpin0 26.41145107108635,12.13590310050818,0

21 Changing an Access Database to XML Pick fields from the Access database to include in your placemarks. Rename fields if they have spaces and characters such as underscores (that don’t translate well to XML). Create and save a query using those fields. Export that query to a XML file, by going to the “External Data” tab, then going to the “Export” tab, and going to “More,” then selecting “XML File.” Notice that each record becomes an element encompassed by tags bearing the name of the query. This above has just been to show you how to change the data to XML. To create KML you’ll need an XSL stylesheet.

22 XSL XSL stands for eXtensible Style Language. XSL gives instructions for how data should be displayed. Since KML is a subset of XML, we can use XSL to transform KML to look the way we want.

23 Using XSL with Access As you output the Access records to XML, you can transform them by selecting an XSL stylesheet. You can use this to: –Choose elements –Make decisions about elements based on values – Embed HTML to structure the data the way you wish –Automatically create placemarks formatted the way you like.

24 Steps to Creating an XSL Transform Include information on the XML version and encoding: Call the xml namespace for xsl transforms: Say go to the root element: Indicate the version of kml that will be used: Put in document and name tags: KmlFile

25 Steps to Creating an XSL File (cont.) 1.1 http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png 1.3 http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png Add formatting for the pushpin icon. You can copy and paste from creating one by clicking on the yellow icon and reformatting it the way you like.

26 Steps to Creating an XSL File (cont.) normal #sn_ylw-pushpin highlight #sh_ylw-pushpin

27 Steps to Creating an XSL File (cont.) Next, we will set out a statement that will select every data record. Notice that here the exported KML file was built from a query called “ExportQuery.” Then we give instructions on how to structure the placemarks. For the name element, we select each value of “Organization”.

28 Steps to Creating an XSL File (cont.) Then we start the description tags. The xsl:value-of tag tells to select the value of “Community.” Notice how we use CDATA to create breaks. ]]> ]]>

29 Steps to Creating an XSL File (cont.) ]]> What is going on here?

30 Steps to Creating an XSL File (cont.) Below, we’ve asked the program to create placemarks circling the equator. These can then be moved by hand into appropriate positions. Another, more exact, way to position placemarks is to merge your Access file with latitude and longitude positions for places, towns, and cities. There are free and paid sources available for latitude and longitude.,0,5 After you’ve completed your xsl stylesheet, save it in Notepad with a.xsl extension.

31 Using an XSL Transform To export your Access data to KML in Microsoft Access 2007 by using an XSL transform, carry out the following steps: 1) Select table or query to export; 2) Click “External Data” tab; 3) Under Export, click “More” to show more export options, then “XML File”; 4) Browse to find the location you want to export the data to (being sure that it will be saved as an XML file), click “OK”; 5) Be sure that the “Data” box is checked; 6) Click “More Options” and then click “Transforms.” 7) Click “Add” and find the.xsl file where you stored the code to transform your data into XML. Click “OK.” 8) Be sure that “Export Data” is checked and under “Records to Export”, the “All Records” radio button is selected. 9) Click “OK” to transform the data set to XML.

32 Creating a KML file The file you just created will be output as an XML file. You will need to change it to a KML file by: Finding the file (using Windows Explorer) and selecting it. Right clicking and renaming it as a.kml file.

33 Open the file in Google Earth Be sure that Google Earth is installed on your computer. Select the KML file you created. Right click and select “Open with” and “Google Earth.” Your placemarks should appear. This file can be posted on a web site and downloaded so that others can make use of the KML file you’ve created.

34 Creating Different Placemark Styles and Assigning Them Based on an Attribute Often there is a need to create different types of placemarks to differentiate between types of organizations, places, etc. This can be done using an xsl:choose statement in combination with xsl:when test statements. An example of an xsl spreadsheet that was used to create blue ranger station icons (that look similar to schoolhouses) to represent high schools and red ranger station icons to represent colleges is shown below.

35 STAND

36 ffff5500 1.2 http://maps.google.com/mapfiles/kml/shapes/ranger_station.png

37 normal #sn_ranger_station highlight #sh_ranger_station

38 ffff5500 1.4 http://maps.google.com/mapfiles/kml/shapes/ranger_station.p ng

39 normal #sn_ranger_station_copy1 highlight #sh_ranger_station_copy1

40 ff0000ff 1.4 http://maps.google.com/mapfiles/kml/shapes/ranger_stat ion.png

41 ff0000ff 1.2 http://maps.google.com/mapfiles/kml/shapes/ranger_stat ion.png

42

43 #sn_ranger_station ]]> ]]> ]]> ]]>

44 ,,0 #sn_ranger_station_copy1 ]]> ]]> ]]> ]]>

45 ,,0

46 Conclusion There are many ways to use Google Earth and Google maps to portray information easily. We are just beginning to see the ways that this application will be able to more easily convey information. For more information on Google Earth and KML, go to http://earth.google.com/userguide/v4/tutorials/in dex.html and http://code.google.com/apis/kml/documentation/ kml_tut.html http://earth.google.com/userguide/v4/tutorials/in dex.html http://code.google.com/apis/kml/documentation/ kml_tut.html

47 Thank you! Please contact me at: Betsy Page Sigman McDonough School of Business Georgetown University 412 Old North Washington, D.C. 20057 bps@georgetown.edu


Download ppt "Using KML, XML, and XSL to Create Google Earth Applications: A Tutorial Betsy Page Sigman and William Garr Georgetown University Southeast Decision Sciences."

Similar presentations


Ads by Google