I will show you in this article how you could convert shapefile (.shp) to KML file for use in Google Earth or Google Maps. Many government entities release some portion of their GIS data for public use. But many of them doesn’t provide them in .kml format. Google Earth and Google Maps only works with .kml file. There are many applications available for doing conversion, such as Google Earth Pro, shp2kml, KML2KML, Arc2Earth, and many others. I used Geospatial Data Abstraction Library(GDAL) utilities, OGR , which is very simple command line utility to convert wide variety of file types, including CSV, PostGRES/PostGIS databases, and a variety of other formats.
You can download various boundary shape files like State, County, Congressional District, Zipcode from US Census website here.. It is free, reliable and accurate source available from US Census.
Let’s have the fun begin.
- Download the .shp file that you need to convert to .kml file from US Census website.
- Download and install GDAL utility from here. I used gisinteranals sdk created by Tamas Szekeres which is listed under Windows section. You can pick the latest release version from section “GDAL and MapServer latest release versions”. Unzip the folder and run SDKShell.bat file which will open command prompt where we will type command to convert .shp file to .kml file.
- Here is how you could convert zipcode boundary shape file to kml file.
ogr2ogr -f “KML” “c:kmlzipcode.kml” “c:shapefilezipcode.shp”
Little odd here is that output file comes first. You can use -where clause to output only portion of shape file content to .kml.
That’s it. It is so simple. If this post really helps you, please click the Google +1 button to show it really helps you save your time.