views:

251

answers:

3

How do I take shapefiles and extract lat/lng coords so I can plot polygons on Google Maps?

http://www2.census.gov/cgi-bin/shapefiles/national-files

I asked this question here:

http://groups.google.com/group/Google-Maps-API/browse%5Fthread/thread/18763b4b0cb996c7

and they told me WHAT to do, but not HOW to do it =P

Thx!

A: 

I had better luck using the ARC files at http://www.census.gov/geo/www/cob/index.html I can't find the webpage right now, but I did find one that had actual code. Google something like "arc to kml" and go from there.

Gary Kephart
+1  A: 

It depends on how you need to accomplish this. If you just need a few shapes, you can look up the coordinates in those files yourself. You can use those coordinates to create a GPolygon in Google Maps.

If you need lots of shapes - you'll need to do it programmatically. I would suggest using your favorite language to parse the XML file and retrieve the coordinates for each shape.

Chris B
+1  A: 

I had a similar problem last year when I was developing a screensaver to render presidential polling data. I didn't really want to invest the time to parse the Shapefiles data on the census site (The spec is here if you missed it).

Not sure if I actually saved any time here, but I ended writing a python app to render the 50 states onscreen, trace the edges and then store the data in a simple text format. Not sure if my data is high res enough for your application, but you can grab the data I generated here:

http://www.cannonade.net/pnt.zip

N.B. The data I generate are not latitude/longitudes, but with some scaling you should be able to translate them.

Good luck.

Cannonade