kml

Basic Steps for Converting an ArcMap Shapefile to GeoJSON

The process of converting a shapefile to GeoJSON is straight forward – it just requires a few steps.  While GeoJSON can handle multiple types (e.g., points, lines, and polygons) simultaneously in one file, a single shapefile cannot.  Therefore, this overview asks you to select and use a single shapefile.

 

Step 0.  If necessary, create the point, line, or polygon that you wish to make into a shapefile. Then save as feature (e.g., Drawing -> Convert Graphics to Features -> Save as shapefile).

 

Step 1.  Select a shapefile that you wish to convert.  This shapefile may contain one or more records, but note that everything will be converted.  If you want select records, then you need to select these records and save them to their own shapefile first (e.g., Data -> Export Data -> Selected features to an output feature class).

 

Step 2.  Convert shapefile layer to KML using ArcToolbox (i.e., ArcToolbox -> Conversion Tools -> To KML -> Layer to KML; see Example 1). 

 

Step 3.  Use an online conversion tool to convert KML (.kmz) file to GeoJSON.  One tool is to use http://ogre.adc4gis.com/ to upload the KML (*.kmz) file and convert it to GeoJSON.  Using this web site, in the “Convert to GeoJSON” section, under “File*:” Browse to and choose your file. Then select “Convert to GeoJSON”.  This will generate GeoJSON code and display in a new window (Example 2).

 

Step 4. Clean up GeoJSON code and validate using online tool.  The online KML-to-GeoJSON tool will add some extra (and potentially unnecessary) code to the GeoJSON export file.  You can clean this up by trimming unnecessary stuff at the beginning of the code, if desired (Example 3).  Validate your KML-to-GeoJSON conversion by copying and pasting the GeoJSON code into window at http://geojsonlint.com/, then “Test GeoJSON”.  If code is correct, this will display your location on a map (Example 4).

 

 

Example 1 (for Step 2). ArcMap Layer To KML

 

Example 2 (for Step 3). GeoJSON output:

{

"type": "FeatureCollection",

"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },

"features": [

{ "type": "Feature", "properties": { "Name": "3N 2E 14", "Description": "<html xmlns:fo=\"http:\/\/www.w3.org\/1999\/XSL\/Format\" xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\"> <head> <META http-equiv=\"Content-Type\" content=\"text\/html\"> <meta http-equiv=\"content-type\" content=\"text\/html; charset=UTF-8\"> <\/head> <body style=\"margin:0px 0px 0px 0px;overflow:auto;background:#FFFFFF;\"> <table style=\"font-family:Arial,Verdana,Times;font-size:12px;text-align:left;width:100%;border-collapse:collapse;padding:3px 3px 3px 3px\"> <tr style=\"text-align:center;font-weight:bold;background:#9CBCE2\"> <td>3N 2E 14<\/td> <\/tr> <tr> <td> <table style=\"font-family:Arial,Verdana,Times;font-size:12px;text-align:left;width:100%;border-spacing:0px; padding:3px 3px 3px 3px\"> <tr> <td>FID<\/td> <td>0<\/td> <\/tr> <tr bgcolor=\"#D4E4F3\"> <td>TRS<\/td> <td>T 03 NR 02  E 014<\/td> <\/tr> <tr> <td>SECTION<\/td> <td>14<\/td> <\/tr> <tr bgcolor=\"#D4E4F3\"> <td>TOWNRANGE<\/td> <td>T 03 NR 02  E<\/td> <\/tr> <tr> <td>NAME<\/td> <td>3N 2E 14<\/td> <\/tr> <tr bgcolor=\"#D4E4F3\"> <td>SHAPE_area<\/td> <td>2614561.62831<\/td> <\/tr> <tr> <td>SHAPE_len<\/td> <td>6468.228208<\/td> <\/tr> <\/table> <\/td> <\/tr> <\/table> <\/body> <\/html>" }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -116.173349131967598, 43.592406515151097, 0.0 ], [ -116.173352859582806, 43.593335222258943, 0.0 ], [ -116.173396030892604, 43.596506495703117, 0.0 ], [ -116.173396357521995, 43.596978493872442, 0.0 ], [ -116.173429829365304, 43.600636779777894, 0.0 ], [ -116.1734632166457, 43.60429517589948, 0.0 ], [ -116.178454329840307, 43.604295613848862, 0.0 ], [ -116.183445427704896, 43.604296350172127, 0.0 ], [ -116.185447407007501, 43.604296599339797, 0.0 ], [ -116.188436440883095, 43.604296869883413, 0.0 ], [ -116.193427530174006, 43.604297409623172, 0.0 ], [ -116.193437078656203, 43.602773711537658, 0.0 ], [ -116.193442252650499, 43.60194291747883, 0.0 ], [ -116.193445231076893, 43.600678221453641, 0.0 ], [ -116.193469630636997, 43.597072124086402, 0.0 ], [ -116.193518556624994, 43.593476839137871, 0.0 ], [ -116.193567485386694, 43.589881552188587, 0.0 ], [ -116.188515271107704, 43.589833819143387, 0.0 ], [ -116.183463067880098, 43.589786194180107, 0.0 ], [ -116.178410776930804, 43.589738752944257, 0.0 ], [ -116.173358558431204, 43.589691012943547, 0.0 ], [ -116.173349131967598, 43.592406515151097, 0.0 ] ] ] ] } }

]

}

 

Example 3 (Step 4). Trimmed GeoJSON Code.

{ "type": "MultiPolygon", "coordinates": [ [ [ [ -116.173349131967598, 43.592406515151097, 0.0 ], [ -116.173352859582806, 43.593335222258943, 0.0 ], [ -116.173396030892604, 43.596506495703117, 0.0 ], [ -116.173396357521995, 43.596978493872442, 0.0 ], [ -116.173429829365304, 43.600636779777894, 0.0 ], [ -116.1734632166457, 43.60429517589948, 0.0 ], [ -116.178454329840307, 43.604295613848862, 0.0 ], [ -116.183445427704896, 43.604296350172127, 0.0 ], [ -116.185447407007501, 43.604296599339797, 0.0 ], [ -116.188436440883095, 43.604296869883413, 0.0 ], [ -116.193427530174006, 43.604297409623172, 0.0 ], [ -116.193437078656203, 43.602773711537658, 0.0 ], [ -116.193442252650499, 43.60194291747883, 0.0 ], [ -116.193445231076893, 43.600678221453641, 0.0 ], [ -116.193469630636997, 43.597072124086402, 0.0 ], [ -116.193518556624994, 43.593476839137871, 0.0 ], [ -116.193567485386694, 43.589881552188587, 0.0 ], [ -116.188515271107704, 43.589833819143387, 0.0 ], [ -116.183463067880098, 43.589786194180107, 0.0 ], [ -116.178410776930804, 43.589738752944257, 0.0 ], [ -116.173358558431204, 43.589691012943547, 0.0 ], [ -116.173349131967598, 43.592406515151097, 0.0 ] ] ] ] }

 

Example 4 (Step 4). Validated GeoJSON Code.

 

 

Create a Buffer for a KML in Google Earth

Create a user-defined buffer around point, line, or polygon KMLs has never been easier!

1) Make sure that your Google Earth data is saved as a KML, not KMZ

2) Open this website: http://www.geo-news.net/index_buffer.php

          

3) Select your buffer type (line, point, or polygon)

4) Select the KML you would like to buffer and choose a buffer distance (in meters). Click the globe with the up arrow to upload your KML file.

                                    

5) A new KML will be created and available via a link at the top of the screen.

            

6) Click the link, save the KML to a location of your choosing and open in Google Earth!

How to Load a Boundary (Track) File into a GPS Unit

 

Let’s say you would like to upload Game Management Unit 1 to your GPS. 

1) Download the Game Management Units KML from the IFWIS Open Data page, https://fishandgame.idaho.gov/ifwis/portal/opendata.

2) Open the KML in Google Earth. Right-click “1” in the gmu features list. Select “Save Place As…”

3) Save the feature as a KML (not a KMZ).

4) Convert the KML to a GPX file.  There are many open-source software options.  I like KML2GPX.exe (download from https://groups.google.com/forum/?fromgroups=#!msg/kml-support-getting-started/5K7vcIGUz6s/_EvtN-YqXuwJ) and GPSBabel (download from http://www.gpsbabel.org/).

5) Upload the GPX file as a track to your GPS.  NOTE: for those GPS units with smaller data storage space or without a data storage card the track may be too large to upload without simplifying.  Using GPSBabel, you can apply a “Filter” to the Routes & Tracks to simplify the boundary.  For units such as the etrex Vista Cx, I know that the track point upload limit is 500 (otherwise it will give you a message that says “track truncated”. The Minnesota DNRGPS Application also works well for uploading data but I have not found a way to simplify the track using this software (http://www.dnr.state.mn.us/mis/gis/DNRGPS/DNRGPS.html). 

There are many different tactics for completing this process but these are the steps that have given me the least amounts of difficulties for a number of different Garmin GPS units.  These steps have not been tested on Magellan, Lowrance, TomTom, etc.

Do you have another method that works better for you?  Please share in the comment below!

Create GPX (gps files) from ArcGIS Shapefiles or GoogleEarth KML files

For some, DNR garmin (http://www.dnr.state.mn.us/mis/gis/tools/arcview/extensions/DNRGarmin/DNRGarmin.html) may be enough for converting shapefiles to gpx files but this program may not always work - especially for large files. I have found it easiest to convert ArcGIS shapefiles to KML and then to GPX files.

Shapefile to KML

Depending on the content of your shapefile, there are two different options for creating a KML.

1)      Open-source Shp2kml, available at: http://www.zonums.com/shp2kml.html .  This would be my first choice.  The GUI is very straightforward and gives you quite a few options for customizing your KML, such as: the color scheme, roll-over effect, and which attributes are displayed.  NOTE: The list of acceptable Datums is kind of short.  Found it easiest to just re-project shapefiles to WGS84.  Also, found that this tool would not always work for shapefiles with especially long text attributes and/or multi-part polygons. (This is discussed in more detail in a past blog called Shapefile to Google Earth kml - Customize Symbol Properties and Labeling (NO PROGRAMMING REQUIRED!).

2)      Create a layer file of your shapefile and use the ‘Layer to KML’ tool in ArcGIS.  You have less authority over the output with this method.  Limited customization of color scheme can be done in Google Earth (unless you would like to program some fancy customizations).  NOTE: Actually saves the file as a KMZ; resave the KMZ as a KML for conversion to GPX in GoogleEarth.  If you are using this options, delete all of the attribute fields that you do not want to show up in Google Earth – this information pops up when the feature is clicked.

KML to GPX

Lots of options. 

1)      Open-source KML2GPX, available at: http://groups.google.com/group/kml-support-getting-started/msg/ec5e2ae637ed4bfc

3)      Open-source GPSbabel, available at: http://www.gpsbabel.org/

4)      Built-in tool on gpsies.com, available at: http://www.gpsies.com/convert.do

I know that DNR garmin and the tool on gpsies.com are not good for very large datasets.

 

 

 

Shapefile to Google Earth kml - Customize Symbol Properties and Labeling (NO PROGRAMMING REQUIRED!)

Although there is a tool in ArcToolbox (Layer to KML) that allows you to convert your ArcGIS file to a Google Earth KML file, this tool gives you no options for customizing how the information is displayed.

Let me present to you the opensource (aka FREE) Shp2kml tool:

http://www.zonums.com/shp2kml.html

Note:  The Download link is actually half way down the webpage, the large Start Download button at the top of the page is part of an ad for a different product.

Step 1:  Choose your input file and coordinate system.

Step 2: Decide which attribute you want to use as the label and check 'Mouse Roll over Effect' if you want to highlight a feature when the mouse is moved over it.

Step 3: Decide what color and transparency (opacity) you features will be.

Step 4: Decide what attribute information you would like in the pop-up balloon when a feature is clicked or selected and customize the balloons symbology.

Step 5: Give the kml layer a name and any descriptive information you would like and your done!

BRILLIANT!