2

I've got a KML file which I need converted to a web mercator projection. This file will go into Tilemill. What are some good open source tools to convert files to the web mercator projection?

3

Firstly, it's not necessary to project the data to webmercator, since tilemill can project on the fly. But if you have a large dataset, then it helps to have data in WebMercator.

You should note that according to the KML standard, the KML data can only be in WGS84 Latlong, i.e. EPSG:4326.

Hence we'll have to project this data to some other format. If you KML has data of only one type, (i.e. either points, Polygons etc) with the same fields, then I'll suggest that you project this KML to a shapefile.

You can use ogr2ogr from the Gdal toolset to project your KML with the following command:

ogr2ogr -t_srs EPSG:3857 output.shp input.kml

As Andre Jooste has warned in a comment below,

Keep an eye on attribute table names. These are restricted in shapefile format to 10 characters, and not a number only. ogr2ogr might truncate the field names if necessary

  • 2
    Keep an eye on attribute table names. These are restricted in shapefile format to 10 characters, and not a number only. ogr2ogr might truncate the field names if necessary. – AndreJ Jul 3 '14 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.