Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Add Best Practices for Geospatial Data Standards (KML, KMZ files) #364

Open
@Jelfff

Description

@Jelfff

I am an online map developer working with the Google map API and am outside of government looking in.

Lots of agencies produce KML/KMZ files. A well-prepared KML/KMZ file is easy to display with either Plain Old Google Maps (POGM) or the Google map API. However, far too often the story that these files would tell remains untold when they fail to display on Google maps.

Suggestion: There should be a policy someplace saying that unless the 3D features of Google Earth are really needed in order to properly present the data, KML/KMZ files should comply with the 2D Google map specifications Google has published at:
https://developers.google.com/kml/documentation/mapsSupport
https://developers.google.com/kml/documentation/kmlelementsinmaps.

Note: Per a Google engineer, the “Maximum number of total document-wide features” is much higher than 1,000 for the Google map API.

In my experience the most common reason that a KML/KMZ fails to display on Google maps is because the file is full of what I refer to as “junk” KML tags. I define a junk KML tag as one that (1) is 3D-specific and (2) is not needed to convey the data’s story to the user. These junk tags often break the KML parser used by Google maps (despite Google’s claim that such KML tags are ignored by its parser).

Another common problem is KML/KMZ files that exceed Google’s size limits. (See above links.) I have been successful at solving this problem by (1) breaking a large dataset into smaller KML/KMZs, (2) hosting these files on a reasonably fast server, (3) making a small KML file that uses a networklink tag for each data file and (4) displaying the small KML file.

It is super quick and easy to test a KML/KMZ to see if Google maps can display it. Just put the file online and paste its URL over the underline in the following:
https://www.google.com/maps?output=classic&q=______________

And just to show you that the above technique does, in fact, work, here is a KMZ file from the fish and wildlife folks that displays fine.
https://www.google.com/maps?output=classic&q=http://www.fws.gov/gis/data/national/FWS_CMT_locations.kmz

However, if you use POGM to test your files then you are not going to see the actual error message that the KML parser sends to POGM when something goes awry with your file. To solve that problem people can use the Gmap4 enhanced Google map viewer I developed. When Google’s KML parser sends an error message (which is in all caps) Gmap4 shows it to you. Below is the syntax for using Gmap4. Put your KML/KMZ file online and replace the underline with the link to your file.
http://www.mappingsupport.com/p/gmap4.php?q=___________

Suggestion: There should also be a policy to require that KML/KMZ files pass a syntax validation check. There is a free online validation tool at http://kmlvalidator.com/home.htm. But note that some files will be too large for this validation tool.

Suggestion: There needs to be a policy telling everyone to not zip KMZ files! The definition of a KMZ file is a KML file that has been compressed. I make my KMZ files by compressing the KML into a zip file and then changing the extension from zip to kmz. For example, the following is silliness:
http://www.epa.gov/waters/data/beach_act_kmz.zip

Below are just a few examples of KMZ files that do not display or do not display correctly with the Google map API for various reasons. Many more examples can be found on federal sites.

Too big: http://www.mappingsupport.com/p/gmap4.php?q=http://www.srh.noaa.gov/gis/kml/hurricanetrack/Atlantic%20Hurricanes.kmz

Invalid file:
http://www.mappingsupport.com/p/gmap4.php?q=http://www.epa.gov/enviro/html/frs_demo/geospatial_data/region_02.kmz

Map legend repeats:
http://www.mappingsupport.com/p/gmap4.php?q=http://maritimeboundaries.noaa.gov/downloads/USMaritimeLimitsAndBoundariesKML.kmz

Joseph Elfelt

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions