Since Google released its Maps API last year, the mapping mashup has emerged as the new trend in online media. Journalists, amateurs and Web developers have all hopped on board. And, for better or for worse, many of them have spent countless hours reinventing the wheel.
Plotting shapes: Census tracts. School districts. Bike routes. If you’ve ever done it by hand in Google Maps, you know how long it takes. As any geographic information system (GIS) program user can tell you, most of this information is already available in the form of shape-ﬁles, the spatial data source of choice in programs such as ESRI’s ArcView. The trick is transferring the data from one form to another – a task that has, until recently, been obnoxiously difﬁcult.
Enter Shp2XML. Developed by Proximity, the easy-to-use Windows interface converts shapeﬁles into Google Maps-ready XML in about three clicks of the
You can download the program at no cost at www.proximityone.com/shp2xml.htm.
The beauty of Shp2XML is that it doesn’t require much know-how beyond the Maps API itself. Of course, there are alternatives, but most of them are confusing or require some programming expertise. One in particular – a program called Shp2text – essentially does the same thing from the command line, without a user-friendly interface.
Converting a ﬁle in Shp2XML is very straightforward. Open the program, then open a shapeﬁle or U.S. Census Bureau TIGER map. Name your output ﬁle, select coloring and name/id ﬁeld options, then click the Shp2Xml convert button. Presto.
Optionally, you can limit the shapes or lines selected into the exported XML by using the Criteria/Query Statement box. Similar to an ArcView SQL query, this allows you to exclude features based on criteria in their underlying tables. If you only want to see Census tracts with more than 5,000 residents, for example, this is where you do it.
An apparent shortcoming is that Shp2XML can only export two ﬁelds of attribute information for each shape. That means it will code two pieces of
information into XML as shape attributes – say tract name and population – but not more than that.
Adding further attributes – population, demographics, etc. – takes a little massaging, either by hand or using your utility of choice. Options include modifying the XML via a scripting language and pulling data from an underlying mySQL table. It’s not difﬁcult, just a hassle.
Something else to keep in mind: Google projects its maps using the Mercator projection, and, it is conventionally accepted, the WGS84 datum. Reprojecting your maps to these speciﬁcations using your GIS before you turn them into XML is strongly advised.
If you don’t already have an API key, sign up for one. You’ll need it to use the service. The code used to plot your newly created polylines is beyond the scope of this article, but you can see a sample at www.nicar.org/downloads/shp2xml.html.
It is also worth keeping in mind that Google Maps has limits. As they do when you plot thousands of points, browsers choke on maps awash in polylines. Census tracts, school districts, municipal boundaries – things like that work ﬁne. Map block groups at your own peril. Usually, the cutoff is several thousand lines. Larger numbers are possible but require complex workarounds.
Accuracy is also an issue. With the proliferation of online mapping services, it is easy to forget how hard it is to ﬁnd an accurate map. With Google
Maps in particular, the API community has been abuzz with talk that Google’s maps do not match up well with other maps, often plotting points several hundred feet away from accurate baseline data.
As a rule, I would rely on Google Maps only for basic approximations, and I would only use them in situations where precision is expendable. None of these issues fault Shp2XML. The program itself is solid, if not a little limited. The founder of Proximity, Warren Glimpse, is a Ph.D. econometrician and the former Census Bureau ofﬁcial who developed the prototype to what are now Census TIGER ﬁles.
Based on his experience, he knows what he’s doing. Proximity offers several other pieces of software, including a geocoding application and a shapeﬁle viewer/manipulator.Bottom line: Shp2XML is useful. It allows Google Maps hackers access to the expan-sive stores of available GIS data and quickly convert it into a useful format.
Contact Chase Davis by email at email@example.com.