Fast Geocoding of Addresses in C# with MapPoint
By Peter Bromberg
Everybody is into geocoding today. Once you have the latitude and longitude of a location, you can start to do some really interesting things.
But the problem is that if you have a large database of addresses to geocode, the various web-based APIs are not your friend. Not only is there a lot of latency involved in each webservice call, they are also rate-limited and consequently geocoding several million or more addresses simply becomes unfeasible.
Microsoft MapPoint is a low cost, fast solution to geocoding needs. MapPoint 2010
can be found as low as $200, and an Academic edition as low as $60. MapPoint
North America holds every street address in the United States. Once MapPoint
is installed, it exposes a COM TypeLibrary, so using it from .NET is as simple
as setting a COM reference.
Here is some sample working code to illustrate how you can geocode an address:
MapPoint.Map map = new Map();
MapPoint.FindResults results= map.FindAddressResults("904 crescent pkwy", "Deland",null, "FL", "32724", GeoCountry.geoCountryUnitedStates);
object index = 1;
MapPoint.Location loc = results.get_Item(ref index) as MapPoint.Location;
double lat = loc.Latitude;
double lon =loc.Longitude;
// store in database here
Console.WriteLine(lat.ToString( ));
Console.WriteLine(lon.ToString());
Not only is this simple, its very fast - absolutely necessary when you have a large
number of addresses to geocode.
If you do this on a Threadpool, passing in the map object in the State parameter,
you can get an address geocoded in about 12.67 milliseconds. That means you could geocode 1 million addresses in about 3 1/2 hours.
Fast Geocoding of Addresses in C# with MapPoint (3071 Views)