Importing Shapefiles (geojson etc) to Google Maps

If you want to import a shapefile to Google maps, the file format options are somewhat limited – you need to use Google’s KML format (i.e. what Google Earth uses). A lot of public datasets are available as geojson, which is a friendlier format to work with.

In addition, Google Maps has a maximum of 5MB, which is a pretty tight restriction. There are a bunch of websites that claim to convert geojson to KML, but do a generally poor job and blow up the file sizes.

The best option is, which uses an R program behind the scenes. It can simultaneously convert and dramatically reduces the file size, by simplifying some of the lines. What I do with this is to zoom in on an area I care about, and then simplify until I start seeing impactful changes.

Once you do that, export to KML:

If the file is under 5mb, it will work in Google maps. Google maps looks for a tile attribute named “name” in it’s UI (potentially useful documentation here). If everything comes through untitled, you can add this to the starting file, and it will render in a more useful way.

Leave a Reply

Your email address will not be published. Required fields are marked *