standard Converting Shapefiles to Google Fusion Tables

Share:

  

Google Fusion Tables provides a relatively easy way to display geographic data on top of Google Maps.  Data can be uploaded in .csv, .tsv, or .txt file formats and the geocoded based on a field (or fields)  that is designated as having location information (address, city, country, lat/long, etc.).  This process works well for point data and for creating heat maps based on countries.  If you have specialized polygon or line data that you want to overlay onto Google Maps, Google only allows for the importing of KML files for geographic data.

Importing a shapefile into Google Fusion Tables

If you have a shapefile that you want to import directly into Google Fusion Tables without having to take the extra step of first converting it to a KML file, Shape Escape provides the most straightforward way to do this. Shape Escape was developed by Josh Livni  (source code: http://code.google.com/p/shpescape/) and provides options to convert shapefiles to either Google Fusion Tables or GeoJSON and TopoJSON.  While using Livni’s Shape Escape is a relatively straightforward method of importing shapefiles for use in Google Fusion Tables, there are a couple of factors you have to ensure before you do the conversion.

Prepping a Shapefile for Conversion to Google Fusion Tables

Update: more detail in the comment from Josh Livni below but if you supply a .prj, Shape Escape will reproject your data into the proper projection for you.

Since Google Maps uses a a spherical mercator projection based on WGS84 known as Web Mercator Auxiliary Sphere (WMAS), make sure your shapefile is in this projection before uploading to Shape Escape.  If it’s not, you will need to reproject your shapefile and create a new shapefile in the correct projection in order to properly align your geographic data with Google Maps.  If you have access to ArcGIS, the easiest way to accomplish this is to load your shapefile into a data frame that already has its project set to WMAS and then export out a new shapefile in the new projection.

To set the correct data frame projection, first load an instance of ArcGIS.  Then right click on the layers icon in the table of contents and select “properties”.  Navigate to the coordinate system tab.  From there, find the “select a coordinate system box” and drill down through the folders: Predefined –> Projected Coordinate Systems –> World.  In the World folder, scroll down until you find WGS 1984 Web Mercator Auxiliary Sphere to select.

dataframe


Now add the shapefile you need to reproject.   Right click on the shapefile and navigate to Data –> Export data.  Then export the shapefile and check the box that says “use the same coordinate system as the data frame”.  Designate the location on your computer where you want to save your new shapefile to.

Once you have the shapefile in the correct format, you need to package it so it can be uploaded to Shape Escape.  In order to be uploaded for conversion, shapefiles have to be zipped and contain four required files: prj, shp, shx, and dbf.  These files contain the projection information (.prj), geometry (.shp), shape index (.shx), and attribute information (.dbf) for your shapefile.  Compress all four files into a Zipped file.  Now you are ready to upload your shapefile for conversion.

Using Shape Escape to Convert Shapefiles to Google Fusion Tables

Visit the Shape Escape site( http://www.shpescape.com/).  Click on the Shp2FusionTables option.  The first step is to authorize Google to allow Shape Escape to access your Fusion Tables.  Click on the “continue” button to sign in to your Google account to authorize access.  Once access has been successfully authorized, you will be redirected to a screen with an upload button.  Click on the button, and navigate to the location on your computer where your zipped file is stored.  Two optional choices are to produced a simplified (generalized) geometry field in addition to your geometry field.  This is a KML field that will generalize your geographic data, i.e. produced a more simplified boundary or line.  There is a second option to also create a geometry of centroids for polygon data.  Click the “upload” button to be added to the processing queue.

The queue can vary greatly over the course of a day from no wait to 20-30 jobs waiting in the queue.  How long the queue takes to process depends on the number of jobs and the sizes of those jobs.  The conversion tool can process up to 100k records in a shapefile (a limitation set by Google).  Additionally, Google has a 200mb limit for all data stored for Fusion Tables.  The status screen will refresh every few seconds to provide you will an update on where your job is in the queue.  Once your job has reached the front of the queue, you will see a status report on how many lines have been processed.  Once the job is complete, a link to the Fusion Table will be provided.  Click on the link to be taken to your newly converted Fusion Table.

Take a look at the tabular information.  The first columns on the left show the geometry type (KML) and geometry information.  If you select the simplify option, you will see a second set of columns with that information.  To see a map, simply click on the tab marked “Map of geometry…”.

assemblyshape

The end result is a shapefile seen in the top image in ArcGIS to its KML counterpart in Google Fusion Tables:

arcmapshape

fusiontablesshape


Like this article and want more?

Enter your email to receive the weekly GIS Lounge newsletter:


4 Comments

  1. Hi – I am trying to download a shapefile of US congressional districts (the available one in google is 112th, I am looking to download the 113th.) Unfortunately shapefile only lets me download less than half of the lines of data….is there a way around? Or another more technical way to get the shapefile into google fusion tables?

    Thanks for any help or advice.
    Sincerely,
    Hannah

  2. Cool, thanks for the awesome writeup on Shape Escape.

    One thing to note is that you can upload your shapefile in just about any projection; as long as you include a .prj (which is the metadata required to know what projection your data is in) the site will convert your geometries to epsg:4326 (e.g. plate carree, or standard lat/lng in wgs84) as part of the conversion to KML, which is what Fusion Tables expects.

    On a related note, although the basemap tiles are displayed in the spherical mercator projection, your overlay data, whether brought in via KML to Fusion Tables, or something like GeoJSON into the Maps API, should not be reprojected.

    Fortunately in this particular case of using Shape Escape you generally don’t have to worry about projections at all since it takes care of that under the hood before uploading.

    1. i tried to upload my shp which contains chinese to GFT,but the converted result has unrecognized characters,what’s wrong?is there any way to fix the problem?

Comments are closed.