Skip to main content

KML

KML is a file format that is commonly used in Google products. KML is similar to GeoJSON and can store points, lines, polygons, and other vector data. Unlike GeoJSON, it's based on XML rather than JSON.

You can upload a KML file to Mapbox Studio to create a vector tilesets, which you can then use in a custom map style to display data on a map.

It is important to note that when you create a KML file, the additional custom attributes go into an <extendedData> element. Mapbox is unable to use the contents of that element to create attributes for the tileset, so if you want to upload a tileset with custom attributes, GeoJSON may be a more appropriate format. You can use a tool like togeojson, or QGIS to convert your file from a KML to a GeoJSON.

Below is an example of a KML file that contains two points with custom attributes representing two music venues in New York City.

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<ExtendedData>
<Data name="LOCATION"><value>Radio City Music Hall</value></Data>
<Data name="Map"><value>(-73.97858810595615,40.759533832684184)</value></Data>
</ExtendedData>
<Point>
<coordinates>-73.97858810595615, 40.759533832684184</coordinates>
</Point>
</Placemark>

<Placemark>
<ExtendedData>
<Data name="LOCATION"><value>Webster Hall</value></Data>
<Data name="Map"><value>(-73.98917174706688, 40.73168230020167)</value></Data>
</ExtendedData>
<Point>
<coordinates>-73.98917174706688, 40.73168230020167</coordinates>
</Point>
</Placemark>
</Document>
</kml>

If you would like to download a sample KML file with a larger set of points, click the download button below. It contains a set of farmers markets, listing their locations and which days they are open:

arrow-downDownload sample KML

Related resources:

Was this page helpful?