Calculating Distances by post code.

  • Thread starter Thread starter Rain
  • Start date Start date
R

Rain

I have been asked to provide functionality for users to sumbit expense
applications on line. The customer would like to be able to enter post code
information for start and end locations and have returned the milage between
them.

The requirement for the accuracy should be to 0.01 miles.

So, does anyone know of a web service which we can pay for or an internal
application we can purchase to allow us to get this information.

Thanks.
 
hi,
The requirement for the accuracy should be to 0.01 miles.
This is not possible as post codes cover areas greater than 0.001 square
miles.
So, does anyone know of a web service which we can pay for or an internal
application we can purchase to allow us to get this information.
You can do this with Google Maps. I assume you can do it also with Live
Maps.




mfG
--> stefan <--
 
OK, thanks. Straight distance would not be good enough as the route is of
importance. I guess I should have been more explicit because I need the
shortest route ( Distance ) between them.
 
Stefan said:
This is not possible as post codes cover areas greater than 0.001 square
miles.

Even more important is to know how accurately postcodes are mapped. In
the UK, a postcode is mapped to a grid of points with a 500m space
between each point and its neighbour. The postcodes are merely snapped
to the nearest point. At least that’s how it is when you buy PostZon
data from Royal Mail, which I’m pretty sure is the most accurate you’ll
get without collecting it yourself.

This means that you can only get accuracy to within 500m, which is of
course 0.31 miles.
 
It's not possible to do with postal codes with that kind of accuracy. The
problem is that postal codes can cover many square miles. In more rural
areas, one postal code can cover several towns. But what you can do, is get
a copy of some FIPS data. This includes Zipcodes, cities, states, and
LAT/LONG coordinates for cities. Using the LAT/LONG coordinates, it's simple
to calculate the relative distance between two cities. It's not going to
have the accuracy that you're looking for, and will be "As the Crow Flies"
distances. The only other way I know to do this would be through a mapping
OCX like Pepperwhite
http://www.pepperwhite.com/

or MS MapPoint
http://msdn.microsoft.com/en-us/cc905749.aspx

These solutions are going to be much more expensive, but much more accurate
and give you many more features.

Marty

BTW... If you're wanting to go the FIPS Route, the formula is something like
this...


public double distance(double lat1, double lng1, double lat2,double lng2)

{

double PI = 3.14159265358979;

double EARTH_RADIUS = 3963;

lat1 = lat1 * PI / 180;

lng1 = lng1 * PI / 180;

lat2 = lat2 * PI / 180;

lng2 = lng2 * PI / 180;

double dist = Math.Sin(lat1) * Math.Sin(lat2) + Math.Cos(lat1) *
Math.Cos(lat2) * Math.Cos(lng2 - lng1);

dist = EARTH_RADIUS * (-1 * Math.Atan(dist / Math.Sqrt(1 - dist *
dist)) + PI / 2);

return (dist);

}
 
Rain said:
I have been asked to provide functionality for users to sumbit expense
applications on line. The customer would like to be able to enter post code
information for start and end locations and have returned the milage between
them.

The requirement for the accuracy should be to 0.01 miles.

So, does anyone know of a web service which we can pay for or an internal
application we can purchase to allow us to get this information.

Thanks.

In addition to the other comments regarding the postal code sizes, which
makes the accuracy requirment unattainable, I would point out that between
any two points, there are other concerns that make picking "the shortest"
route unreasonable. The shortest route from my home to work "probably"
avoids the main interstate, and goes through many subdivisions and school
zones. Penalizing the expensee (?) because they chose the fastest versus
shortest is sure to anger many.

Mike
 
Michael Covington said:
Well said. And what if the route doesn't even exist -- what if a
straight-line route would be across a bay or a mountain or something?

0.01 mile is 52.8 feet! Even British postal codes probably aren't
locatable to that degree of precision. (My front door wouldn't have a
different post code than my side door...) US ZIP codes typically span a
radius of a few miles -- considerably more out in the country. There are
probably western ones that are 50 miles in diameter.

I've used Microsoft MapPoint and VB.net to find shortest, quickest and
scenic routes. Its amazing it can find routes to some locations and it will
use a ferry over water if it exists. Many US Alaskan towns are not connected
to any road system which MapPoint can detect and report.
 
OK.

Well, what about using door numbers as well as post codes. This should
surley then be able to give this kind of accuracy ?

Not sure who would provide that service, obviously SAT Nav in car does, but
im not sure if there is a service out there which would do the same ?
 
Rain said:
OK.

Well, what about using door numbers as well as post codes. This should
surley then be able to give this kind of accuracy ?

Not sure who would provide that service, obviously SAT Nav in car does,
but im not sure if there is a service out there which would do the same ?


In the US, databases exist to determine where along a road the house number
"should" be located. Bear in mind that the way this works in my experience
is there is an address_from and address_to field for the road segment. If
your house number is 12, and the address_from field is 1, and the address_to
field is 99, then roughly 12% of the way down the segment you can find the
approximate location of the address. This is only an estimate and will
almost always be off by more than 0.01 miles which was your original
requirement.

GDT, Etak and ESRI have different datasets for the US and other areas of the
world which may work for you if you go down this road.
 
Back
Top