Export to Km l Arc Script

11
Exporting Shapefiles to KML using the ‘Export to KML’ ArcScript  Introduction Export to KML is an extension developed for ArcGIS 9.x by the City of Portland, Bureau of Planning. The extension allows ArcGIS users to export GIS data in “keyhole markup language” (KML) format for viewing in Google Earth. Any point, polyline, or polygon dataset, in any defined projection, can be exported. Features can be ex ported as either 2-dimensional features, or 3D feature s "extruded" upwards by an attribute or z-value. Some other features: ability to incorporate ArcMap layer symbology into the exported KML; labeling of point, line, and polygon features; "describe" individual features using the database attributes, store database attributes as "schema" items. The ‘Export to KML’ ArcScript is freely available from http://arcscripts.esri.com/details.asp?dbid=14273  . Note that while anyone can download the installation package, you must have administrator rights to install the ArcScript on a computer. Once installing the ArcScript, enable it by opening the ‘ Tools’ menu in ArcMap and clicking ‘Extensions... Check the checkbox next to ‘ Export to KML’ and click ‘Close.’ Now, right-click on any toolbar in ArcMap and, in the menu which opens, click ‘ Export to KML’ to turn on the necessary toolbar.  Choosing Input Shapefiles Before beginning, determine what your new KML needs to show, and then what Shapefile(s) you need as inputs. When choosing input Shapefiles, keep in mind that, while there is no maximum file size for KML files, these files are usually shared online, and therefore attempts should be made to minimize file sizes. As such, keep the following suggestions in mind when choosing Shapefiles: - Simplicity is key. Complicated feature layers do not show up well as KMLs. - Limit the number of features in your input Shapefile to: o 10,000, if using Google Earth as the KML client; o 1,000, if the input Shapefile contains points - if using Google Maps as the KML client OR if the KML is to be delivered online. o 500, if the input Shapefile contains polygons - if using Google Maps as the KML client OR if the KML is to be delivered online. - If your Shapefile has too many features in it, consider splitting it up into tiles to reduce the file sizes of individual KML outputs. - If your input Shapefile contains lines or polygons, consider simplifying it by: o Converting it to a Raster using the Feature to Raster  ArcToolbox geoprocessing tool (Conversion  -> To Raster )

description

Arcgis and Google Earth

Transcript of Export to Km l Arc Script

Page 1: Export to Km l Arc Script

7/17/2019 Export to Km l Arc Script

http://slidepdf.com/reader/full/export-to-km-l-arc-script 1/11

Exporting Shapefiles to KML using the ‘Export to KML’ ArcScript

IntroductionExport to KML is an extension developed for ArcGIS 9.x by the City of Portland, Bureau of Planning. Theextension allows ArcGIS users to export GIS data in “keyhole markup language” (KML) format for viewingin Google Earth. Any point, polyline, or polygon dataset, in any defined projection, can be exported.Features can be exported as either 2-dimensional features, or 3D features "extruded" upwards by anattribute or z-value.Some other features: ability to incorporate ArcMap layer symbology into the exported KML; labeling ofpoint, line, and polygon features; "describe" individual features using the database attributes, storedatabase attributes as "schema" items.

The ‘Export to KML’ ArcScript is freely available from http://arcscripts.esri.com/details.asp?dbid=14273 .Note that while anyone can download the installation package, you must have administrator rights toinstall the ArcScript on a computer.

Once installing the ArcScript, enable it by opening the ‘ Tools ’ menu in ArcMap and clicking ‘ Extensions... ’Check the checkbox next to ‘ Export to KML ’ and click ‘ Close .’ Now, right -click on any toolbar in ArcMapand, in the menu which opens, click ‘ Export to KML ’ to turn on the necessary toolbar.

Choosing Input Shapefiles

Before beginning, determine what your new KML needs to show, and then what Shapefile(s) you needas inputs. When choosing input Shapefiles, keep in mind that, while there is no maximum file size forKML files, these files are usually shared online, and therefore attempts should be made to minimize filesizes. As such, keep the following suggestions in mind when choosing Shapefiles:

- Simplicity is key. Complicated feature layers do not show up well as KMLs.- Limit the number of features in your input Shapefile to:

o 10,000, if using Google Earth as the KML client;o 1,000, if the input Shapefile contains points - if using Google Maps as the KML client OR

if the KML is to be delivered online.

o 500, if the input Shapefile contains polygons - if using Google Maps as the KML client ORif the KML is to be delivered online.

- If your Shapefile has too many features in it, consider splitting it up into tiles to reduce the filesizes of individual KML outputs.

- If your input Shapefile contains lines or polygons, consider simplifying it by:o Converting it to a Raster using the Feature to Raster ArcToolbox geoprocessing tool

(Conversion -> To Raster )

Page 2: Export to Km l Arc Script

7/17/2019 Export to Km l Arc Script

http://slidepdf.com/reader/full/export-to-km-l-arc-script 2/11

o Generalizing the Shapefile using Dissolve (Data Management -> Generalization ), oro Simplifying the geometry, using Simplify Line or Simplify Polygon (Data Management ->

Generalization ).

Preparing FeaturesFor the purposes of this tutorial, we will be working in ArcMap with files that have been alreadyprepared for you. Please double click on ‘ Google Earth Tutorial Project.mxd’. The program will openautomatically.

Since some of you may not be familiar with this software program, the features of the map have beenalready symbolized for you. If you’re interested in changing the colours of your map features, double

click on the symbol of each layer in the table of contents (under layers).

This is the stage where we customize the geographical extent and the appearances of the features.What we see on the screen is essentially what will be exported into KML format.

If you want to show 3D features , determine what the height of each feature should represent. If thevalue you want to use as heights for features is contained in a field in the Shapefile’s attribute table,make a note of that field name. In this tutorial, we will not be using the 3D features, but at least youknow that it exists.

Exporting to KML

Once your Shapefile is symboliz ed appropriately, click the ‘ Export to KML ’ shortcut button ( ) to openthe ‘Export to Google Earth KML’ dialogue box. You will need to repeat this step for every shapefile youwant to export.

Page 3: Export to Km l Arc Script

7/17/2019 Export to Km l Arc Script

http://slidepdf.com/reader/full/export-to-km-l-arc-script 3/11

From the ‘Select the layer to export’ d ropdown box, choose the symbolized Shapefile, and ensure thecheckbox next to ‘Group and colour features using the layer’s symbology’ is checked.

Lets’ first begin with the School layer. If desired, choose an attribute by which features will be labelled.If you don’t want labels, choose ‘<NONE>’ from this lis t. I recommend trying out labels for the school

name

Finally, enter an appropriate name and location for the output KML:

Now, click the ‘Options’ button to set some advanced options for the output KML. Note that there are

six tabs in the Options window. Only three will be discussed here.

Page 4: Export to Km l Arc Script

7/17/2019 Export to Km l Arc Script

http://slidepdf.com/reader/full/export-to-km-l-arc-script 4/11

Export OptionsThe instructions in this tab are fairly self-explanatory. For reference, the image below shows therelationship between the options in this tab, and the resulting KML file properties, as shown in GoogleEarth.

A horizontal shift may be necessary to properly align your data to Google Earth’s, but should generallybe left at ‘0’ unless the data is significantly out of alignment.

Page 5: Export to Km l Arc Script

7/17/2019 Export to Km l Arc Script

http://slidepdf.com/reader/full/export-to-km-l-arc-script 5/11

For the KML Description (HTML), we will use simple html code which will include an image of aschool. Open the wordpad file ‘Description_KML’ and copy and paste into the LayerDescription, as seen below.

The html code will show the header “Schools in the City of Waterloo”, as well as an image of aschool which you will see shortly.

Labelling and Description OptionsThese options are a bit more complicated to set up, and are therefore explained in some detail below.

Page 6: Export to Km l Arc Script

7/17/2019 Export to Km l Arc Script

http://slidepdf.com/reader/full/export-to-km-l-arc-script 6/11

Labelling Options

First, set the options for labels for your KML features. Skip this step if you don’t want labels. Note that toaccess all of the labelling options, you must have specified a label field in the first Export to Google EarthKML dialogue box – if you did not, click ‘OK’ to exit the advanced options window, set this field, and then

return to the advanced options.

1. Set the field by which features will be labelled (again!):

2. Set the additional label properties:

a. will produce white labels for each

feature, while will cause each

label to receive the same colour as its associated feature:

b. will pro duce a label reading “Null” or “<NULL>”for features where the label field is not populated. Generally, this should be leftunchecked, unless you want to make a specific point of letting users know that a givenfeature doesn’t have the label field populate d.

c. will produce labelswhich might cross polygon boundaries. Labels will always be within polygons if checked:

d. For polygon and line features, labels will always be exported to a separate KML layerwithin the output KML file. For point features, you have the option whether or not toexport labels to a separate layer. The default setting for this option is usually OK.

Feature Descriptions

Page 7: Export to Km l Arc Script

7/17/2019 Export to Km l Arc Script

http://slidepdf.com/reader/full/export-to-km-l-arc-script 7/11

The Export to KML ArcScript is particularly advantageous over other KML export tools in that it allowscomplete customization of pop- up feature descriptions using HTML. Here’s a very basic pop -up,displayed in Google Earth, using basic HTML tables:

The HTML use d to create this table is below, but is also available for copying in the wordpad file ‘feature

descriptions’.

<a href="http://www.wrdsb.ca/"> Waterloo Board of Education</a>

<table border="1" width="300">

<tr>

<td colspan="2" align="center"><b>Waterloo Schools</b></td>

</tr>

<tr>

<td align="left">FID</td>

<td align="center">[FID]</td>

</tr>

<tr>

<td align="left">Name of School:</td>

<td align="center">[NAME]</td>

</tr>

<tr>

<td align="left">Type of School:</td>

<td align="center">[TYPE]</td>

</tr>

<tr>

<td align="left">Address of School:</td>

<td align="center">[ADDRESS]</td>

</tr>

</table>

Page 8: Export to Km l Arc Script

7/17/2019 Export to Km l Arc Script

http://slidepdf.com/reader/full/export-to-km-l-arc-script 8/11

This guide does not endeavour to be an HTML tutorial, but the basics can be learned quickly fromhttp://www.w3schools.com/html/default.asp .

Note that you can alter the colours of the pop-up box, add images, add video and other dynamiccontent, load external websites – anything you can display in a web browser, you can add to the pop-upbox.

Please copy and paste the HTML into the description window. You can use the ‘Save’ button to save anHTML file containing your f eature description, and then in the future you can use the ‘Import’ button toload a feature description from an existing HTML file. For today, you will not need to save.

3D OptionsThis step is FYI only.

Note that you must have selected a field from which to extract height values in the first Export to KML dialogue box – if you didn’t, click ‘OK’ to exit the advanced options window, choose a field, and thenclick ‘Options’ to return to the advanced options window.

First, set the Altitude Mode:

Using ‘Relative to ground’, a feature with a height of 500m will show in Google Earth as (500m PLUS theactual ground elevation at the base of that feature) high.

Using ‘Absolute’, a feature with a height of 500m will show in Google Earth as 500m above se a level.

This means that if two adjacent features both have a height of 500m, their actual height as displayed inGoogle Earth may differ slightly if ‘Relative to ground’ is used, but will be exactly the same if ‘Absolute’ isused.

Generally, ‘Relative to ground’ will produce good results. If you find the slight height differencesproblematic, though, switch the Altitude Mode to ‘Absolute.’

You may notice that ‘Clamped to ground’ is disabled – if 3D features are enabled, this setting will always be disabled.

Page 9: Export to Km l Arc Script

7/17/2019 Export to Km l Arc Script

http://slidepdf.com/reader/full/export-to-km-l-arc-script 9/11

Next, set offsets for your features. Basically, setting a feature offset will extrude all features by the valueof the feature offset, and then further extrude each feature by its individual height setting (Seeexamples below):

You can apply feature offsets either dynamically – by using the value of an attribute for each feature asthe offset – or by using a constant value.

If desired, apply a surface offset by altering the values above.

Feature offset of ‘0’ – each feature isextruded ONLY by its individual height

Feature offset of ‘500’ – each featureis extruded to (500 + its individual

height)

Page 10: Export to Km l Arc Script

7/17/2019 Export to Km l Arc Script

http://slidepdf.com/reader/full/export-to-km-l-arc-script 10/11

Export the KML!

Once you’ve set the Export, Labelling and Description, , click ‘OK’ to exit the advanced options window.

Now, click ‘OK’ to generate the KML.

Repeat the steps for the remainder of the Shapefiles.

Remember that you can turn your labels on and off in Google Earth. Also be aware thatthere are files hidden in the folders (i.e. streets), so make sure to look through them all tocustomize your view.

When successfully completed, your Google Earth map should look similar tothe following:

Page 11: Export to Km l Arc Script

7/17/2019 Export to Km l Arc Script

http://slidepdf.com/reader/full/export-to-km-l-arc-script 11/11

Eva Dodsworth, September 2009