<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tim Showers - Web Development, Design, and Data Visualization &#187; Geocoding &amp; Mapping</title>
	<atom:link href="http://www.timshowers.com/category/geocoding-mapping/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.timshowers.com</link>
	<description>Tutorials, Polemics, and Discussion about all things web-nerdy</description>
	<lastBuildDate>Mon, 18 May 2009 21:30:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Transparency for Feature Highlighting</title>
		<link>http://www.timshowers.com/2008/12/using-transparency-for-feature-highlighting/</link>
		<comments>http://www.timshowers.com/2008/12/using-transparency-for-feature-highlighting/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 15:46:39 +0000</pubDate>
		<dc:creator>Tim Showers</dc:creator>
				<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Geocoding & Mapping]]></category>

		<guid isPermaLink="false">http://www.timshowers.com/?p=400</guid>
		<description><![CDATA[Axis maps blog is sharing an interesting technique for adding another dimension of data to maps by using transparency.  Somewhat like a cartogram, they&#8217;ve taken each county in the US and modified it based on population density, but instead of stretching it to a new size, they&#8217;ve increased the alpha transparency to make more populated [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.axismaps.com/blog/2008/12/election-map-follow-up/"><img class="alignleft size-full wp-image-401" style="margin: 15px; float: left;" title="US Election Map with Transparency scaled by Population" src="http://www.timshowers.com/wp-content/uploads/2008/12/cartogram-alternative-small.png" alt="" width="210" height="143" /></a></p>
<p><a href="http://www.axismaps.com/blog/2008/12/election-map-follow-up/">Axis maps blog</a> is sharing an interesting technique for adding another dimension of data to maps by using transparency.  Somewhat like a <a href="http://www.timshowers.com/2008/12/creating-effective-cartograms/">cartogram</a>, they&#8217;ve taken each county in the US and modified it based on population density, but instead of stretching it to a new size, they&#8217;ve increased the alpha transparency to make more populated areas brighter and less populated areas faded out.<span id="more-400"></span></p>
<p>It looks like a challenge to get the color mapping right, especially in light of data that has a few outliers compared to a large area of uniform low density like population.  Perhaps a logarithmic scale would be more useful for data like this.</p>
<p>Regardless it&#8217;s a novel highlighting method, and definitely one to keep in the toolbox in the future.  I could also see this being useful for highlighting in non-map visualizations such as <a href="http://en.wikipedia.org/wiki/Treemapping">treemaps</a>.</p>
<p>There are a few more examples over at the <a href="http://www.axismaps.com/blog/2008/12/election-map-follow-up/">original post</a>, so check it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.timshowers.com/2008/12/using-transparency-for-feature-highlighting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Effective Cartograms</title>
		<link>http://www.timshowers.com/2008/12/creating-effective-cartograms/</link>
		<comments>http://www.timshowers.com/2008/12/creating-effective-cartograms/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 05:22:25 +0000</pubDate>
		<dc:creator>Tim Showers</dc:creator>
				<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Geocoding & Mapping]]></category>
		<category><![CDATA[cartograms]]></category>
		<category><![CDATA[infographics]]></category>

		<guid isPermaLink="false">http://www.timshowers.com/?p=374</guid>
		<description><![CDATA[
Cartograms, or visualizations of an area skewed by some variable, are a powerful tool to control for disparities over a large area, especially with respect to politics.
A relatively large but sparsely populated area will dominate a standard projection, whereas a cartogram allows populated areas to be warped to show their true influence (See sidebar).
Applications of [...]]]></description>
			<content:encoded><![CDATA[<div style="width: 220px; float: right;">
<div id="attachment_375" class="wp-caption alignright" style="width: 220px"><br />
<a href="http://www-personal.umich.edu/~mejn/election/2008/"><img class="size-full wp-image-376" title="2008 Election State Map" src="http://www.timshowers.com/wp-content/uploads/2008/12/2008-election-standard-small.png" alt="" width="210" height="128" /></a><br />
<a href="http://www-personal.umich.edu/~mejn/election/2008/"><img class="size-full wp-image-375" title="2008 Presidential Election Cartogram" src="http://www.timshowers.com/wp-content/uploads/2008/12/2008-election-cartogram-small.png" alt="A Standard 2008 Election Map (Upper), and a Cartogram skewed by Population (Lower)" width="210" height="150" /></a><p class="wp-caption-text">A Standard 2008 Election Map (Upper), and a Cartogram skewed by Population (Lower)</p></div>
</div>
<p><a href="http://en.wikipedia.org/wiki/Cartogram">Cartograms</a>, or visualizations of an area skewed by some variable, are a powerful tool to control for disparities over a large area, especially with respect to politics.</p>
<p>A relatively large but sparsely populated area will dominate a standard projection, whereas a cartogram allows populated areas to be warped to show their true influence (See sidebar).</p>
<h3>Applications of Cartograms:</h3>
<p>Socio-economic data is the most obvious use case for cartograms, particularly data from the <a href="http://www-personal.umich.edu/~mejn/cartograms/">United Nations</a> and <a href="http://www-personal.umich.edu/~mejn/election/2008/">National Elections</a>.</p>
<p><span id="more-374"></span>The cartogram strategy can be applied to just about any area visualization, and works particularly well where there are major disparities between area size and overall effect.</p>
<h3>Algorithms and Tools:</h3>
<p><a href="http://www.style.org/iowacaucus/"><img class="size-medium wp-image-382 alignright" title="Iowa Election Cartogram" src="http://www.timshowers.com/wp-content/uploads/2008/12/style-iowa-small.png" alt="" width="210" height="139" /></a>A general outline of the cartogram creation process, as well as some excellent alternatives to the standard &#8217;skewed border&#8217; approach can be found at &#8220;<a href="http://www.style.org/iowacaucus/">Scaling Counties in a Checkerboard State</a>&#8221; over at <a href="http://www.style.org">style.org</a>.</p>
<p>Actual implementation of cartograms seems to often follow the algorithm first published <a href="http://www.pnas.org/content/101/20/7499.abstract">here</a>. Desktop versions in Java (with code) are available <a href="http://chorogram.choros.ch/scapetoad/index.php">here</a> and <a href="http://people.cas.sc.edu/hardistf/cartograms/home.htm">here</a>.  There&#8217;s a rundown of more methods at <a href="http://indiemaps.com/blog/2008/03/free-cartograms/">indiemaps</a>.</p>
<div id="attachment_386" class="wp-caption alignright" style="width: 220px"><a href="http://www.style.org/mappingvotes/"><img class="size-full wp-image-386" title="Style.org county election cartogram" src="http://www.timshowers.com/wp-content/uploads/2008/12/style-redesign-small1.png" alt="A rescaled election cartogram. Can you identify the state?" width="210" height="207" /></a><p class="wp-caption-text">A Rescaled Election Cartogram. Can You Identify the State?</p></div>
<p><a href="http://www.style.org/mappingvotes/">Another post</a> at style.org looks at alternate skewing methods, namely squarifying the areas in question, and then expanding them by a fixed ratio with respect to the data.</p>
<h3>Non-Standard Cartograms:</h3>
<p>Some of the most beautiful work in cartograms comes from the <a href="http://www.sasi.group.shef.ac.uk/publications/pandpexamples.htm">SASI group</a> and <a href="http://www.shef.ac.uk/geography/staff/dorling_danny/">Dr. Daniel Dorling</a>.</p>
<p><a href="http://indiemaps.com/blog/">Indiemaps blog</a> has a number of posts on cartograms, including the promise of python source code, and some great visuals.</p>
<p>I think cartograms are an untapped resource for commerical data, especially for geographically disbursed figures like sales or conversion rates. Hopefully in the future we&#8217;ll see more tools centered around this resource, as well as a decent online generator.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.timshowers.com/2008/12/creating-effective-cartograms/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Geocoding tutorial with the Google Maps API &#8211; Part One</title>
		<link>http://www.timshowers.com/2008/08/php-geocoding-tutorial-with-the-google-maps-api-part-one/</link>
		<comments>http://www.timshowers.com/2008/08/php-geocoding-tutorial-with-the-google-maps-api-part-one/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 16:49:30 +0000</pubDate>
		<dc:creator>Tim Showers</dc:creator>
				<category><![CDATA[Geocoding & Mapping]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Geocoding]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://www.timshowers.com/?p=85</guid>
		<description><![CDATA[So unless you live under a non-Web 2.0-enabled rock, you&#8217;ve probably heard of the magic of the Google maps API and google maps mashups. If you&#8217;re saavy, you&#8217;ve probably even heard that now Google Maps offer translation of addresses into latitude and longitude, aka Geocoding. 
What you may not know is that the folks at [...]]]></description>
			<content:encoded><![CDATA[<p>So unless you live under a non-Web 2.0-enabled rock, you&#8217;ve probably heard of the magic of the Google maps API and google maps mashups. If you&#8217;re saavy, you&#8217;ve probably even heard that now Google Maps offer translation of addresses into latitude and longitude, aka Geocoding. </p>
<p>What you may not know is that the folks at google exposed this geocoding as a regular old URL-based webservice, which means that whatever Nifty mashups your devious little minds can come up with (as long as they fly with google&#8217;s TOS) can be powered on the backend without ever loading a google map!<br />
<span id="more-85"></span><br />
So lets cut the chit-chat and jump to some code&#8230; I&#8217;m going to use PHP here, but do whatever fuels your nerding.</p>
<p>First, <a href="http://code.google.com/apis/maps/signup.html">sign up</a> for a key, put in whatever URL you happen to own, it won&#8217;t matter (i&#8217;ll explain later).</p>
<p>next, add this to your php file, making SURE to replace the key with your own:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #666666; font-style: italic;">//Three parts to the querystring: q is address, output is the format, key is the GAPI key</span>
<span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;YOUR KEY HERE&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$address</span> <span style="color: #339933;">=</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;columbia MO&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//If you want an extended data set, change the output to &quot;xml&quot; instead of csv</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://maps.google.com/maps/geo?q=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$address</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;output=csv&amp;key=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Set up a CURL request, telling it not to spit back headers, and to throw out a user agent.</span>
<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Change this to a 1 to return headers</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_USERAGENT<span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTP_USER_AGENT&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_FOLLOWLOCATION<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Data: &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Supposing all goes well you should see the following: (if not check the PHP CURL manual)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">Data<span style="color: #339933;">:</span> <span style="color: #cc66cc;">200</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span><span style="color:#800080;">38.951667</span><span style="color: #339933;">,-</span><span style="color:#800080;">92.333889</span></pre></div></div>

<p>You&#8217;ll notice that the first number is the return code, the second the relative accuracy (there 4 we see here is quite low as a result of the broad input. 8 is street-level address accuracy), third the latitude, and fourth the longitude.</p>
<p>So now that we&#8217;ve seen the magic.. let&#8217;s get it all nicely formatted:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Check our Response code to ensure success</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;200&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$precision</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$latitude</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$longitude</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Error in geocoding! Http error &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And that&#8217;s it! Less than 40 lines of code to give you a powerful resource for mapping and usability. Just how powerful? You&#8217;ll have to wait for part two to find out&#8230;</p>
<p>*Note on locations and API keys: In my experience thus far, the Geocoding service doesn&#8217;t actually check that the api key is being called from the originating server. This may change in the future at some point, so keep your eyes open.<br />
FULL CODE LISTING:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #666666; font-style: italic;">//Set up our variables</span>
<span style="color: #000088;">$longitude</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$latitude</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$precision</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Three parts to the querystring: q is address, output is the format (</span>
<span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;YOUR KEY HERE&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$address</span> <span style="color: #339933;">=</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;columbia MO&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://maps.google.com/maps/geo?q=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$address</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;amp;output=csv&amp;amp;key=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_USERAGENT<span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTP_USER_AGENT&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_FOLLOWLOCATION<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Data: &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$data</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;lt;br&amp;gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Check our Response code to ensure success</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;200&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$precision</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$latitude</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$longitude</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Latutide: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$latitude</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;lt;br&amp;gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Longitude: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$longitude</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;lt;br&amp;gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Error in geocoding! Http error &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>Update:</h4>
<p>A few people have mentioned that after some number of requests (between 100-300) in quick succession google will kill your access for the day, so you may want to insert a</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To stagger the requests a little.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.timshowers.com/2008/08/php-geocoding-tutorial-with-the-google-maps-api-part-one/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
