Hack 28. How Big Is That, Exactly?

Explore the size of geographic regions in terms of those you already know.

A Google search for "roughly the size of" returns 398,000 results. Certainly this suggests that, when it comes to visualizing the size of faraway places, we feel the need to refer to the unknown in terms of the familiar. Take this newspaper quote, for example:

…when the Amazon shrank a record 11,200 square miles, an area roughly the size of Belgium, or the American state of Massachusetts….

I read that and get a vague sense of confusion and think, "Wow, I bet the people in Belgium and Massachusetts know what that means, but I sure don't." There's more:

"Huge iceberg menaces Antarctica…roughly the size of the island of Jamaica." (http://www.theregister.co.uk/2005/05/20/iceberg_penguin_menace/)

"The largest-known iceberg was from this region. It was roughly the size of the state of Rhode Island." (http://www.factmonster.com/ipka/A0781668.html)

"Months later, after I discussed what I had seen with the oceanographer Curtis Ebbesmeyer, perhaps the world's leading expert on flotsam, he began referring to the area as the 'Eastern garbage patch.' But 'patch.' doesn't begin to convey the reality. Ebbesmeyer has estimated that the area, nearly covered with floating plastic debris, is roughly the size of Texas." (http://www.naturalhistorymag.com/1103/1103_feature.html)

A search for "roughly the size of" reveals interesting things. The fact that the writer needed to find something, anything, to use to provide a measure of spatial context hints at something odd and interesting. An "Eastern garbage patch…roughly the size of Texas"? The image is vivid.

3.13.1. The Hack

The statement "roughly the size of…" demands the ability to compare the unknown with a known quantity. At http://www.mappinghacks.com/projects/gmaps/size_of.html you can select the outline of a state or country and pin it onto the map. Pick the shape from a drop-down box then scroll around on the map until you find a familiar place and click. Figure 3-25 shows an outline of Pennsylvania on top of Hungary.

State boundaries can have an historical basis, but often are rather arbitrary. There is no particular reason for us to respect the work of our forebearers, and with Google Maps we don't need to! Figure 3-26 shows an outline of the state of Delaware, rotated 90 degrees clockwise and pinned over the San Francisco Bay area.

Figure 3-25. Hungary is roughly the size of Pennsylvania

Figure 3-26. Delaware is roughly the size of the Bay Area

Depending on how you maneuver the outline, Delaware is roughly the size of the San Francisco Bay Area. Or perhaps the Bay Area is roughly the size of Delaware. Once you start doing comparisons like this, you need a fully declensed language, like Latin, so you can specify which place is nominative and which one accusative. (Oddly, neither would be locative.)

Pinning a state or country onto the world expands our understanding of geography. For example, people don't appreciate how very long Chile is. Figure 3-27 shows Chile on top of the west coast of Californiait goes from the southern tip of Alaska to the bottom of Baja California!

Figure 3-27. Chile flipped over and pinned to the west coast of North America

This image of Chile has been flipped, so southern Chile is near Alaska and northern Chile over Baja. The latitudes roughly match, and there is a general correspondence in climate. The north of Chile includes the Atacama desert, the driest place on earth. In parts of the Atacama, there has been no rainfall in recorded history. Baja California is not quite that dry, but it is pretty darn dry! The central part of Chile is a ripe agricultural region, analogous to California, then tending toward forests in the Southern Lakes district, which is evocative of the Inland Passage of Canada and Alaska. (Again, we have that nominative and accusative question: which one is analogous to the other, and which one is the defining instance?)

When we rotate Chile and lay it over the whole of the United States, it reaches most of the way from California to Florida, as shown in Figure 3-28.

Figure 3-28. Chile shows her length

You don't need Google Maps to demo this, but the ease with which the Google Maps API handles everything on the client side (from rendering the map background to overlaying the boundary outlines to handling the user interaction), made this interesting idea an implementation in just a few hours.

3.13.2. The Code

We started by taking outlines of our example regions from common sources in ESRI Shapefile format. We then used a simple Perl script to extract these outlines and calculate the bounding box of the coordinates in the outline. Taking the average of the corners of the bounding box, we estimated a centerpoint for each region, and then calculated the offset of each coordinate in the perimeter from that center point. This allows us to draw the outline of the country or state around any arbitrary point that a user might click on the map.

Also, we took this opportunity to quantize the coordinate valuesessentially snapping them to a grid of an arbitrary sizeand then removed the duplicate coordinates to get the region's outline down to a number of points that's manageable for Google Maps. Additionally, we scaled the longitudinal distances by the cosine of the center latitude, so that the areas display at more or less the right size anywhere on the map. These doctored outlines were then put in individual text files on our server. The JavaScript uses the GXmlHttp class from the Google Maps API to fetch the file for a given country or state from our server:

	function loadPolygonData (url, displayNow) {
	 if (!url)
	 url = document.forms['selectPoly'].area.value;
	 var xmlHttp = GXmlHttp.create();
	 msg.innerHTML = "Fetching " + url;
	 xmlHttp.open('GET', url, true);
	 xmlHttp.onreadystatechange = function () {
	 msg.innerHTML = "Fetching " + url + "(readyState "
	 + xmlHttp.readyState + ")";
	 if (xmlHttp.readyState == 4) { 
	 shape = parsePolygonData( xmlHttp.responseText ); 
	 if (displayNow) {
	 var center = map.getCenterLatLng(); 
	 drawPolygon(null, center); }

The URL of the file that gets fetched is pulled from the following select box:

	What's roughly the size of
	 CaliforniaTexasMinnesotaPennsylvaniaDelawareRhode IslandChileItalyMexicoAustraliaIndia 
	 ? Click on the map to find out.

As one example, the points file for California is at http://mappinghacks.com/projects/gmaps/size_of/california.txt and starts out like this:

	-3.93254 4.72960
	-0.58090 4.72519
	-0.58141 1.73040
	3.44982 -2.02319
	4.08442 -2.96202
	3.77594 -3.31706
	3.77654 -3.71225

This data is processed with the parsePolygonData( ) function:

	function parsePolygonData (txt) {
	 var rePoint = /^(S+)s+(S+)$/igm;
	 var match, pts = [];
	 msg.innerHTML = "Parsing polygon data…";
	 while (match = rePoint.exec(txt)) {
	 var lon = parseFloat(match[1]),
	 lat = parseFloat(match[2]);
	 pts.push(lon, lat); 
	 msg.innerHTML = "Click anywhere on the map to continue."; 
	 return pts;

This bit of code defines a regular expression to read the pairs of points as longitude and latitude, and push them onto an array called pts[]. Next, the drawPolygon( ) function is called when a user clicks on the map:

	function drawPolygon (overlay, point) {
	 msg.innerHTML = "Got click at " + point;
	 if (point && shape) {
	 var angle = parseInt(document.forms["selectPoly"].rotate.value);
	 var poly = makePolygon( point, angle, shape );
	 // msg.innerHTML = "Showing poly " + poly + " at " + point;
	 map.centerAndZoom(point, 13);

The drawPolygon( ) function takes the angle that you are applying to turn the state or country outline, and then calls makePolygon( ) to generate a polygon represents the state or country borders. Finally, the polygon is added to the map with map.addOverlay( ), and the map is recentered and zoomed in. The mathematical core of the code is in the makePolygon( ) function.

	function makePolygon (center, angle, ptsIn) {
	 var ptsOut = [];
	 if (isNaN(angle))

	 angle = 0;

	 var theta = - angle * Math.PI / 180;
	 for (var i = 0; i < ptsIn.length; i += 2) {
	 var x = ptsIn[i] * Math.cos(theta)
	 - ptsIn[i+1] * Math.sin(theta)
	 + center.x; 
	 var y = ptsIn[i] / phi * Math.sin(theta)
	 + ptsIn[i+1] * Math.cos(theta)
	 + center.y; 
	 var pt = new GPoint(x, y);
	 var poly = new GPolyline(ptsOut, 'ff0000', 3, 1);
	 msg.innerHTML = "Generated polygon centered at " + center;
	 return poly;

The makePolygon( ) function takes the requested angle, converts it from degrees to radians, and stores it in theta. The x and y coordinates are composed by scaling each point from the geographic outline by the horizontal and vertical components of theta, and then offsetting that point from the point where the user clicked on the map. These coordinates are used to create GPoint objects that are pushed onto an array, and then assembled into a GPolyline, which is returned and then displayed on the map by drawPolygon().

3.13.3. How Big Is "That Big"?

We would hope that this tool helps provide a bit of spatial perspective to address a weakness in geographical literacy. Problems of cultural referents remain. For example, it is said that one difference between America and England is that Americans think 100 years is a long time, and the English think 100 miles is a long way. Perhaps the tool needs the addition of a set of radio buttons, modeled after a Slashdot poll.

When faced with a 100-mile trip, I will:

  • Happily drive down in the morning and back that night
  • Try to schedule it for the best time
  • Go for a week-long trip
  • Consider it an absurdly extreme ordeal
  • The Bentley hardly gets up to speed in 100 miles
  • Cowboy Neal/I'm on a home release program, you insensitive clod

Humor aside, calibrating perceived distances is an important task. The Jhai Project http://www.jhai.org/ is installing computers and Wi-Fi relays to allow people in remote villages to connect with each other and the world. Farmers can see what the current market prices are before deciding to take their goods to market, because a 10-mile trip can take hours, and the the difference between selling on a bad-price day and a good-price day has an enormous effect on the well-being of an extended family. By getting current market prices and dealing directly, farmers and craftspeople are able to double their income.

I can drive from Sebastopol, CA down to San Francisco International Airport, fly to Los Angeles, and return in less time than it takes to get to the nearest market town in the mountains of Laos. A mile (or kilometer) may be the same distance the world round, but it doesn't mean the same thing to me as it does to a Laotian farmer. Even though (for some people) our world is getting smaller every day, areas and distances still matter to humanity a great deal.

Google Maps Hacks
Google Maps Hacks: Tips & Tools for Geographic Searching and Remixing
ISBN: 0596101619
EAN: 2147483647
Year: N/A
Pages: 131
Simiral book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net