Archive for the ‘GIS’


Points on KML/KMZ Polygons Created From Shape Files

For work I’ve been using a lot of freely available GIS data to plot on Google Earth and sometimes Maps (if the resulting file is small enough).

I have also helped out the Minnesota Cache Reviewer, Surfer Joe (along with some help from Paul Falstad) with plotting the Minnesota DNR’s AMA boundaries on Google Earth.

The DNR likes to put the coordinate system into something other than WGS84, so you have to use ogr2ogr like this: ogr2ogr -s_srs EPSG:32615 -t_srs WGS84 out.shp in.shp

After that, the out.shp will contain the coordinate system we are all so accustomed to :)

The first file I sent to him just included the polygon boundaries (very similar to the County boundaries in KML/KMZ I did before) but that was only useful in telling that it was or wasn’t in an AMA. It was very difficult to determine which AMA it was actually located in. The Minnesota DNR has a KMZ available of their Wildlife Management Areas (available here) which includes information points for each of the WMAs.

Using a script available as part of the ShapeLib tools, shpcentrd, I was able to determine the centroid of the polygon in the shape files and create a new shape file of points that could be converted with shp2kml.

If you would like to see the final product of the AMAs, please check here and for the Minnesota School Districts, click here.

Minnesota County KMZ Overlay for Google Maps

At work I play around with plotting interest levels for both our prospective students and our applicants. I have numerous scripts that I run that plot high school locations, zip code locations, individual address locations, etc. I recently was searching around for a county line map based on what you are able to do with your geocache finds (see here).

Well, I don’t format the data I pull from work into a GPX so that wouldn’t really work and I wanted to automate the process w/o having to play around with curl… So I located the shape files available from the 2000 Census and used an OSS utility to convert shape files to KML (used with Google Earth).

This OSS shp2kml utility was a bit cumbersome and I didn’t feel like having to futz around with installing Java at work, etc. I instead found another utility that does shp2kml and used that with great success.

After I got a decent KML out of the utility, I tried to load it into Google Maps via the search bar but found out that it was entirely too large to load in that way. I zipped the KML, creating a KMZ and then it was small enough to load (see here for an example — it can take a while to load and may require you to zoom or reload to see properly).

Next I needed to figure out how to use it with the Google Maps API. There are some undocumented API features that you can access in order to play the KMZ overlay on top of other points. It took me a little while but I did end up figuring it out.

The result can be seen here. This *will* take a while to load as there are 100s of points to plot for MN and WI.

I’m still trying to work out a way to modify the KML/KMZ directly to change the color of the counties based on the interest levels inside each. Unfortunately the XML is ugly and I don’t feel like playing around with it much anymore. If anyone has an easy solution (xmlstarlet didn’t get it done for me — too cryptic of an interface) that can be done on the Linux commandline, please let me know :)