Importing a spreadsheet
Tip: Want to import a spreadsheet directly to Mapbox.com? See the documentation for import CSV & other types of files directly into the editor.
One of the many geo formats that TileMill supports is a spreadsheet, specifically a comma-separated values (CSV) file. We want to start by working with a basic spreadsheet to show how easy it is to make a simple point map.
Your CSV spreadsheet
To import data into TileMill as a CSV file you need column headings on the first row. The CSV must also contain columns with latitude and longitude geographic coordinates. We have hard coded TileMill to look at the column headers for any mention of “lat” or “latitude”, so something like “geo_longitude” will even work.
If your CSV contains place names or addresses instead of lat/lon coordinates, you will have to geocode the data before it will work in TileMill. We have a plugin for Google Docs that makes geocoding easy.
In this crash course, we’ll use earthquake data from the USGS to make a map showing points for earthquakes that have occurred.
- Start TileMill and click on the “New project” button on the main screen.
- Enter a “Filename” for your project and click “Add”. You can leave the other fields alone for now.
- Click on the new project to open it. The project contains a default layer called
#countriesstyled with some example CartoCSS code.
- To add a CSV layer, first click the “Layers” button located on the bottom left to bring up the Layers panel.
- Now click “Add layer”.
earthquakesin the “ID” field. You’ll use this ID to to reference this layer in CartoCSS selectors.
- Enter the URL
http://earthquake.usgs.gov/earthquakes/feed/csv/2.5/weekinto the “Datasource” field.
- Click the “Save & Style” button. This will add the layer to your project and insert a default CartoCSS rule for the layer.
- Preview the result in the map preview pane.