Comments may be back…

March 3rd, 2007

depending on how well this akismet plugin works.  I’d love to have this be a conversation…I just can’t have a conversation and deal with all of the spam.

Geocoding ‘Hgwy’’s

December 15th, 2006

Geocoder.us has always taken a bit of a powder when faced with addresses like ‘US Hwy 12′  Now thanks to the detective work of geocoder.us user Wes Winters we have an answer to at least some of these.

Try geocoding this address:

1443 United States Highway 22, Mountainside, NJ 07090

I don’t know who ‘Dave’ is, but Wes says this is the location of ‘Famous Dave’s.  Here is a link to call geocoder.us on it directly

I don’t like that you need to write out ‘United States Highway’ instead of ‘US Hwy’ or some other reasonable abbreviation, so I’ll try to extend that soon, but Wes has given us all a work around.

Thanks Wes!

Truth in email/blogging statement

November 15th, 2006

Hi All,

I just went through my email.  I use Gmail.  I like it.  The spam filters are pretty good.  They caught 1,562 spams in the last 21 hours.  They missed another 71.  I’ve received 1,633 spams in 21 hours (actually some more that slipped through the filters before I went to bed last night).

In that mess I miss emails.  Important emails.  In that mess I put other emails aside, thinking ‘oh yes, that is important, I must focus on that’ and then the flood flushes my attention span down the bloody toilet.

I just went to ‘moderate comments’ on this blog.  There are 3091 comments to be moderated.  The most prolific contributor is named ‘porn,’ who is quite interested in geocoding, having commented 65 times.

I don’t know if ‘porn’ is a friend of ‘free porn,’ but free porn had 53 comments.  In fact, 105 of our ‘readers’ have porn in their name.  Cartoon porn, Disney porn, fat porn, clip porn, anime porn, on and on.

I feel a servant of my email.  That would not be that bad, heck, people emailing are engaging me in conversation.  I like people, I like conversation.

Except I don’t want to have these particular conversations.

Calculating proximity-find your closest pizza place

October 31st, 2006

I just got a request for a write up to explain “given a database of
geocoded locations, how one could find all the locations within X miles/km/what
ever of some arbitrary point.”

It is a good question…so good it was hack #82 in our book Mapping Hacks, and you can read more mapping related goodies on the Mapping Hacks Block.

The approach which I use is:

1) Create a bounding box X miles high, and X miles wide

2) Query the database for points within this bounding box

3) walk that list of points and calculate the real distance using spherical trib

4) there is no step 4.

A bounding box describes the latitude and longitude of the four corners of an area of interest. We know that at the equator 1 degree = 69 miles, so we can create a bounding box that includes all points within 69 miles of an arbitrary point by looking at the area defined by the points:

Upper Left: lat + 1 degree, long + 1 degrees

Upper Right: lat + 1 degrees, long - 1 degrees

Lower Left: lat - 1 degree, long + 1 degree

Lower Right: lat - 1 degree, long - 1 degree

Conceptually that is right, but since we specify Longitudes west of 0 as negative just doing that math will have left and right flipped :-) I’ll leave it as an excercise to the reader to correct that.

What if you want say everything within 25 miles of your arbitrary point? Use the relationship that 1 degree = 69 miles, so we want 25/69 degrees, a tad over 1/3 of a degree
So if our center point is 38.393, -122.834 then an SQL query that will return all points within that area:

select * from zipcodes
where latitude between 38.393 - 25/69 and 38.393 + 25/69
and longitude between -122.834 - 25/69 and -122.834 + 25/69

That query will return all points within 25 miles of our point, but it will also include additional points (for reasons that may be obvious, but if not they don’t really matter-trust me :-) we could improve the bounding box a bit, but the point of the bounding box is to filter out most of the data, to do an initial grand simplification. Assuming our bounding box doesn’t cover the whole area of our database we have lowered the number of records where we need to do the more computationally intensive distance calculation described in the previous post (and in Mapping Hacks :-) .

I’ll leave with a shout out to the perl module Geo::Distance, which calculates distance without that bother of doing it yourself…

Blog comment spammers are scum

August 17th, 2006

And I have made blog comments harder.  Sorry.  You can email me, contact@geocoder.us, and I will be happy to add a comment.

Calculating Distances

April 21st, 2006

In the post on how many digits are enough Tom Watson wrote in to remind me that I neglected to follow up on East West distances. Moving North South 1 degree = about 69 miles regardless of the latitude, but that is not true of East West distances.

Schuyler, Jo, and I wrote about this in Mapping Hacks as Hack 27 “Calculate the Distance betweeen points on the earths surface.”  But just in case you have not yet run out and bought the book, here is the scoop…

At the equator 1 degree from East to West is about 69 miles. At the poles 1 degree is obviously 0. So what mathematical function has the characteristic of being 1 at 0, and 0 at 90?

Yes, our friendly Cosine. A local guy has the very coolest license plate: ‘COS 0 = 1′

The distance from East to West for one degree of longitude is pretty close to:

cos(latitude) * 69

Read the rest of this entry »

Added Degrees-Minutes-Seconds view to demo

March 24th, 2006

The demo.cgi script that you can run at Geocoder.us has returned the coordinates in Decimal Degrees. Now I’ve added the display of the coordinates in Degrees-Minutes-Seconds form.

Latitude

34.101509 °
N 34 ° 6′ 5.4″

Longitude

-118.32691 °
E -118 ° 19′ 36.9″

How many digits are enough?

March 23rd, 2006

38.2?  38.23?  38.234?  How many digits of precision do we need?

1 degree of latitude (and 1 degree of longitude at the equator) equals
60 nautical miles.   A nautical mile is 6,076.11549…(it goes on!)
feet in length.  Close enough to 1.15 statute miles, which makes 1
degree equal to 69 statute miles.

(nautical miles are interesting-1 minute = 1 nautical mile, so the
world is 60*360 nautical miles North South, and around the equator.
Or 21600.  This gives rise to the expression that I don’t find on
Google but I know I’ve heard that ‘a minute’s a mile the world round’)

That leads to this chart:


decimals        degrees miles-statute   feet    inches
0       1       69      364320  4371840
1       0.1     6.9     36432   437184
2       0.01    0.69    3643.2  43718.4
3       0.001   0.069   364.32  4371.84
4       0.0001  0.0069  36.432  437.184
5       0.00001 0.00069 3.6432  43.7184
6       0.000001        0.000069        0.36432 4.37184

For example, for the White House we return a Latitude of 38.898748.
The difference between 38.898748 and 38.898749 is 4.4 inches.   Four
digits, or around 36 feet, is really about all you need for normal
navigation.  GPS units are not really that accurate (though that opens
up a whole new discussion-I will attempt to restrain myself :-) There
are applications that need more precision, adding two digits to eight
digits of precision you get precision of about 0.11 mm.

The other side of things is accuracy.  It doesn’t matter how many
digits of precision you represent if they are not accurate!  Tiger
includes a higher level of precision than their accuracy warrants
because they can then insert features with a ‘fake’ positioning.  If I
know that feature A is at 38.000 and C is at 38.001, and I know that B
is between the two, but I don’t know it’s exact position, then I can
assign it to 38.0005, for example, and know that I am not more than
182(ish) feet off, no matter how close B is to either A or C.

That relationship, of A to B to C will hold even if it turns out that
A is not really at 38.000, but is, say, at 38.02.

I hope that offers some clarification.

The SOAP Request Perl Sample

March 21st, 2006

It turns out that Perl is not everyone’s native language.

I know, I was also shocked when I realized that fact…but it is true. It is also true that (cough) Perl’s syntax does not resonate with the mental model of the universe that is held by most people, even most technically savvy people…

I just got an email from someone wanting help in trying to figure out the SOAP sample from the front page: http://geocoder.us/dist/eg/clients/soap.pl

 Read the rest of this entry »

Geocoding using Google Maps

March 16th, 2006

How to get Latitude and Longitude from Google Maps

1) Go to http://maps.google.com/

2) Enter your address, or zip code, or airport code, or whatever you
wish to geocode.

3) click on a point a small distance from the marker (this is not always
necesary, but it never hurts).

4) click on the link that says ‘link to this page’ It is on the right
side, just above the upper right corner of the map.

5) The address bar (URL) will change. Copy the full link. For example:
http://maps.google.com/maps?f=q&hl=en&q=241+Florence+Ave,+Sebastopol,+CA\

&ll=38.407263,-122.828865&sp

6) The latitude and longitude are contained in those URL parameters. Look for this:
&ll=38.407263,-122.828865

7) The latitude is: 38.407263 and longitude: -122.828865

8) Wasn’t that fun?