Tuesday, April 25, 2006

Shapefile Coordinate Systems and Google Maps

While I worked for the town parks and rec. committee, I met the GIS consultant who did the town's mapping. I realized he could give me an ArcView shapfile of the trails and bike routes to put on my Google Maps mashup. I used shp2text which is a handy utility to convert shapfiles into either xml, gpx, or csv that I could then load into MySQL.

Problem. Once converted, I could tell the data points for the lines were not right. I knew what the long/lat coordinates were for points in the town and none of these matched from the shapefile dump. Looking back at my email from the GIS guy, he said the shapefile was "coordinate base is Colorado State Plane, Central Zone, NAD1983, Feet" Googling around for info on coordinate systems pointed out that of course the ArcView export was CO state. The Google Maps API expects WGS84 longitude/latitude coordinates.

Lucky for me my friend could easily produce a new shapefile export with the WGS84 coordinates. You can see an example of the GPolyline from the shapefile by clicking on "Show Bike Routes" on the map.

Friday, April 21, 2006

Hacking Google Maps Geocoding

Geocoding - the process of converting a street address to longitude/latitude. Necessary because the Google Maps API expects longitude/latitude numbers based on the WGS 84. And in order for your points to resolve correctly on the map you are using (Google/Navteq in my case), you would hope to have geocoding from that same source. And as we know Google does not offer this service.

I'm sure Navteq is holding Google to some agreement not to provide this service with their APIs. Think of it. Navteq's business is providing this data. They spend lots money with their high-tech cruiser vans traveling every road to collect the data. They charge Google big bucks for it. They don't want Google giving it away for free.

So what are your options since Google offers no geocoding service?

US Census TIGER data

You can use the geocoder.us free web service that has loaded this data for the US. I loaded the data for my county into MySQL. Hey, it's for a database course, right? So why not load the data and play with it. But what I found was the data showed a number of inaccuracies and there was quite a bit of missing data. It didn't map well onto Google.

Yahoo! Maps REST API

Yahoo! offers a REST API for gecoding. It's easy to use and open. My friend that works at Yahoo! was eager for me to use it. :) But similar problem. It works best when placing points on a Yahoo! map, not a Google Map. The points end up being off just enough.

Hack Google

Not a good idea for a commercial app (I'm sure Google might complain), but for my grad school project, I thought it might be worth exploring. And sure enough there is various scripts out there on doing just that. If you call a url like http://maps.google.com/maps?q=[your address here]&output=js (note the output=js at the end), Google returns a Javascript function with the longitude/latitude that you are looking for inside. However, just to prove that this is not an ideal solution, Google has changed the format of this output so that any of the previous hacks would no longer work. It's not a public API afterall! :) My script is shown below.




<html>
<head>
    <title>Google Geocode</title>
</head>

<body>
<h2>Google Geocode</h2>
<form name="mainform" action="">" method="GET">
    <b>Address:</b> <input type="text" size="40" name="address" value="">">
    <input type="submit" name="geo" value="Google Geocode">
</form>

<hr />
<b>Geo-location:</b>
<ul>
<?php
if (array_key_exists('geo', $_REQUEST)) {
    $result = get_long_lat($_REQUEST['address']);
    print_r("<li>Longitude: ".$result["longitude"]);
    print_r("<li>Latitude: ".$result["latitude"]);
}
?>
</ul>
</body>
</html>

<?php

function get_long_lat($q) {
  $q = urlencode($q);
  $gm = fopen('http://maps.google.com/maps?q=' . str_replace('','+',$q) . '&output=js','r');
  $tmp = stream_get_contents($gm);
  fclose($gm);
  $x = preg_replace('/.*\{center: \{lat: ([^,]*),lng: ([^}]*).*/', "|$1|$2|", trim($tmp));
  list($dmy,$lat_value, $lng_value) = explode("|",$x );
  return(array('longitude'=>$lng_value, 'latitude'=>$lat_value));

}
?>


My Superior trails map project includes an address field that uses this code to geocode the provided address and insert a marker on the map.

Thanks to Dan Moore for his insights and feedback on geocoding options.

Tuesday, April 18, 2006

Superior Google Maps Mashup

I am wrapping up a semester project for my graduate database course. The assignment was to build a dynamic website driven by a backend database. I chose to build a Google Maps mashup for my town (Superior, CO). Overlaying data about parks, trails, bike routes onto a Google Map.

I got the idea from Chicago Bike Map mashup. I'm an avid cyclist and I thought something like this would be cool for my local area. And I volunteered for the town on parks, recreation, and trails. I got to know the GIS consultant for the town and realized he would be able to provide the data I needed to overlay on Google Maps.

So I'll be posting nerdy updates here on things I've done and learned. Once I have the app hosted somewhere more permanent (currently on iBook laptop), I'll put up a pointer to it.

Update: I've got this hosted now. Go to, http://gregz.is-a-geek.net/

Monday, April 10, 2006

It Was a Moth!

Since my kids have been old enough to ask, they have wondered "Daddy, what kind of bugs do you have in your computer? Are they spiders! Or beetles! Tee Hee!" :)

Leave it to a thorough entry in the Wikipedia to answer the question. While the term bug has been around since engineers built things (Edison used the term as long ago as 1878), The first computer bug is popularly attributed to a 1947 Relay Calculator being tested at Harvard. You can see the actual bug at the Smithsonian. Here is a picture:So, the answer is "It was a moth!" that actually got stuck in the relay.

Friday, April 07, 2006

Solar Eclipse as Seen from Space

Check out this very cool photo of recent solar eclipse as captured from the International Space Station.

Saturday, March 18, 2006

Suspicious Inquires Into Climate Science

As previously mentioned, the Bush administration attempts to silence science is deeply troubling. Now U.S. Senator Jame Inhofe is making some suspicious inquiries into the research going on at the National Center for Atmospheric Research (NCAR, up the road in Boulder). Inhofe is chairman of the Senate Committee on Environment and Public Works and is asking for a review of NCAR's 40-year old contract from NSF. A review of this contract and NCAR's compete bid with NSF is reasonable, however there are numerous reasons for suspicion:
  • the Senate Committee on Commerce, Science & Transportation has jurisdiction for science inquiries, not Inhofe's committee.
  • he is asking for a list of all NCAR and UCAR staff and job titles, a list of NCAR and UCAR employees under contract with non-National Science Foundation agencies and organizations including salary information; and a list of research projects including funding for the past three years, among other information. This is information outside the scope of a compete review.
  • Inhofe in a quote from 2003, "With all of the hysteria, all of the fear, all of the phony science, could it be that manmade global warming is the greatest hoax ever perpetrated on the American people? It sure sounds like it." NCAR is one of the world's top climate-change research institutions.
Credit to Todd Neff from Daily Camera for reporting on this.

Friday, March 17, 2006

Bleaching coral reefs continues

Ghostly coral bleachings haunt the world's reefs
Rising sea temperatures (due to global warming) cause coral reef to expel the algae living in coral polyps which provide food and the vivid color that make them so beautiful. This limit is 84F. If ocean temperatures cool, coral can recover from a bleaching, however extended bleaching kills the coral. Bleaching occurred in 1998 and 2002 on the Great Barrier Reef. 2005 saw bleaching in the Caribbean and now the Keppel Islands.

Ignoring the obvious ecological disaster when coral is bleached or killed (coral ecosystems are often called "the nurseries of the seas"...anyone that saw Finding Nemo know this.), there is an obvious visual impact. Bleached coral is ugly. No one wants to scuba or snorkel through a bleached coral reef. This impacts tourism in all areas affected. Not to mention leaving us with a sad, empty feeling looking at these ghostly reefs.

Wednesday, March 08, 2006

Cardboard Box Entered into Toy Hall of Fame

First, I had no idea there was such a thing as the Toy Hall of Fame.

The National Toy Hall of Fame® was established in 1998 by A.C. Gilbert’s Discovery Village, a children’s museum in Salem, Oregon, to recognize toys that have achieved longevity and national significance in the world of play and imagination. The hall quickly outgrew its original home and in 2002, Strong Museum, which houses the world’s largest and most comprehensive collection of toys and dolls (more than 70,000 items), acquired it and moved it to its permanent home in Rochester, New York. The hall serves as an interpretive gateway to Strong Museum’s world-renowned collection and provides additional opportunities for both hands-on experiences and intergenerational memory sharing among guests.

Second, how cool!? The cardboard box has been inducted. Who doesn't remember making believe a cardboard box was a rocket, fort, castle, ship, house, whatever.

The Chinese invented cardboard in the 1600s. The English played off that invention and created the first commercial cardboard box in 1817. Pleated paper, an early form of corrugated board, initially served as lining for men’s hats. By the 1870s, corrugated cardboard cushioned delicate glassware during shipment. Stronger, lined corrugated cardboard soon followed. American Robert Gair produced the first really efficient cardboard box in 1879. His die-cut and scored box could be stored flat and then easily folded for use. Refinements followed, enabling cardboard cartons to substitute for labor-intensive, space-consuming, and weighty wooden boxes and crates. Today, cardboard boxes are widely appreciated for being strong, light, inexpensive, and recyclable.

Over the years, children sensed the possibilities inherent in cardboard boxes, recycling them into innumerable playthings. The strength, light weight, and easy availability that make cardboard boxes successful with industry have made them endlessly adaptable by children for creative play. Shoe boxes serve as ideal settings for scenes and dioramas. Small boxes take on alternate roles as dollhouse furniture. Wheels drawn on the side turn a box into a car. Really large boxes—from washers, stoves, big-screen TVs, or refrigerators—can offer children even greater opportunity for creativity. With nothing more than a little imagination, those boxes can be transformed into forts or houses, spaceships or submarines, castles or caves. Inside a big cardboard box, a child is transported to a world of his or her own, one where anything is possible.

Monday, March 06, 2006

Hummingbirds rock!

Small brains, long memories - the tiny hummingbird

Too cool. They migrate 2000 miles twice a year (Canada to Mexico, and back). And this new study shows they have really good memory about specific flowers and when they last visited the flower. Guess it's good news if you get a hummingbird to visit your yard. Chances are he/she will remember and return!

Thursday, March 02, 2006

Wind decision takes gusts

Aspen Ski Company (they runs Aspen's four mountains and two hotels) has made the biggest wind energy purchase ever in the ski industry. They are going 100% wind. They will need to draw wind power down the grid from Wyoming wind farms because this is such a big order. They follow on the heels of other big corps that are doing so, Whole Foods, Fedex Kinkos, Starbucks, Nike, Patagonia, and my favorite New Belgium Brewery (Fort Collins).

Sunday, February 26, 2006

Silencing Science

The Bush administration is rife with failures and travestries, but for scientists this has to be one of the most concerning. Not necessarily news, but this pair of interviews from NPR (NPR : Bush Science Push Fails to Transform Critics) clearly lays out the issues of how the adminstration has injected policy into issues that are clearly dictated by science. As Dr. Kennedy states, while this has been the case for quite some time in politics, "We have hit a new watermark."

Thursday, February 09, 2006

Cold-weather microbes

CO2 producing microbes like cold

In an interesting twist for ecology, it appears that reduced snow cover in the mountains causes cold-weather microbes to produce less CO2. Reduced snow cover is attributable to global climate change (higher tempatures, less precipitation). But ironically that results in these cold-weather microbes producing less CO2 (and thus contributing less to global warming).

It all starts with the microbes in dirt. Not something most people think about, but each handful of dirt is full of them. And these particular microbes like the temperature right around freezing in the moist soil beneath the snow. And the emit CO2. Nature is cool.

Sunday, February 05, 2006

End of telegram. Stop.

LiveScience.com - Era Ends: Western Union Stops Sending Telegrams

Wow. The changes you see in a lifetime. The impact the telegraph (and the railroad) had on settling this country. And now you can't send a telegram anymore, and can't take a train most places.

Here is the message on Western Union's website.

Tuesday, January 31, 2006

Chewy's Blog

UUUHHHGGG-rrrrRRR!

This is too funny for words. I almost peed in my pants.

A Boom, but not a Bubble

Interesting piece in Wired 14.02: The New Boom explaining the state of internet tech companies. Suggesting the boom is back, but in a healthy way with no bubble. "Bubbles are inflated with hot air and speculation. They end with a wet pop, leaving behind messy splatters. Booms, on the other hand, tend to have strong foundations and gentle conclusions." He sites 3 points:
  • technology adoption has continued despite the bust (e.g. broadband, iPods, digital media).
  • all the investment of the 90's boom makes the economics of entrepreneurship more favorable today
  • open source software and cheap hardware means start-ups can run lean and turn a profit quicker (without the need for IPO)

Tuesday, January 24, 2006

Road to Nowhere

Global climate change update. Balmy winter stings natives in Canada. Seems certain communities in northern Canada depend on seasonal roads that are built on frozen lakes and bogs each winter. The road is usually open Janurary through March. This year it has been too warm and they may not be able to build the road at all or will have to limit traffic because of thin ice. Not a problem you usually think of when you are wearing shorts in the winter...warm winter weather is just a fashion problem. For these folks it's a bit more serious.

Monday, January 23, 2006

So long and thanks for all the fish

Sad to hear about London's whale. But unfortunately, probably not too surprising. More surprising would have been if it had survived. Any whale that far away from the open water was obviously in distress. Likely distressed by something we men did.

Scientists have said fluctuating ocean temperatures, predators, lack of food and even sonar from ships can send whales astray into potentially dangerous waters.

"So long and thanks for all the fish"

Wednesday, January 18, 2006

Web 2.0 Hype

A funny piece on the Web 2.0 hype.

As the first properly valued “Web 2.0” properties began to find buyers, a frenzy like the old one popped hideously back to life. Yahoo spent how much? Google bought what? Here was real blood in the water.

But how to persuade the other sharks in the tank that this blood feast was different from the previous boom-and-bust? Easy: Dismiss everything that came before as “Web 1.0.”

Friday, January 13, 2006

iPod jeans

Levi Strauss debuts iPod-ready jeans - Yahoo! News

Special jeans for your iPod. Wonder if they will have different styles for different size iPods? Wonder if anybody will actually buy them? :)

Polar bears drown as ice shelf melts

Polar bears drown as ice shelf melts - Sunday Times - Times Online

Global climate change alert.

Those cute cuddly polar bears. They are drowning because the ice is receding in their habitat. This study showed that it is normal for them to swim 15 miles (up to possibly 100 miles). However when the ice receded 200 miles further north, that proved too much for some of the bears and they died of exhaustion, hypothermia, and just plain drowning.