spacer1
spacer2 1_1 1_2
2_1
 Subscribe
 The MP2K Update!
 
 
 
 Magazine
Front Cover
What's New
Articles
News
Sample Data
Gallery
Advertise
About
 Features
MapPoint 2009
Press Releases
MapPoint Forums
Companies
Link to MP2Kmag
Wish List
MapPoint Trial
Authors
 Earlier Content
Past News Items
Past What's New Announcements
 Sponsors
 Order

MapPoint 2009

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
SVG Tutorials
MapPoint

Map Visitors

 Direct Media

Travel Insurance Compare over 450 travel insurance policies (inc. annual multi-trip, single trip & winter sports)

  ARTICLES  


Reverse Geocoding, Pt. III

Walt Cygan, a frequent contributor of late, submits this solution for tackling reverse geocoding

My code to do reverse geocoding was intended to answer the need to able to find an address near a location virtually all of the time. Compared with Gilles Kohl's approach in http://www.mp2kmag.com/articles.asp?ArticleID=47, mine is more brute force in nature. I use the ObjectsFromPoint method repeatedly at slightly different locations to attempt to find an address.

In the code I use data on a SQL Server 2000 database where I have lat and lon stored. The steps I go through to get the address are:

  1. Use the GetLocation method with the database lat and lon.
  2. Check the Location object from step 1 with the ObjectsFromPoint method to see if the best match has a street address. If so, I'm done. If not, move on.
  3. Round the database lat/lon to 4 digits after the decimal and get use those coordinates with GetLocation
  4. Check the Location object from step 3 with the ObjectsFromPoint method to see if the best match has a street address. If so, I'm done. If not, move on.

Now is where the fun starts: I start working outward in squares (spherical rectangles really) each 1-ten thousandth of point of latitude and longitude larger that the one before. The center point is the location found after rounding to 4 digits. The first square has 8 points, the next has 16, then 24, 32, etc. I have the code set to do 10 squares before giving up, giving a total of 442 attempts, including the one with the original latitude and longitude. The idea here was to find the nearest possible address without ever testing the same point twice.

For each point the same process as in steps 1-4 is followed: GetLocation followed by ObjectsFromPoint.

I tested this code on 22 locations in and around Minneapolis and St. Paul, Minnesota. Most of these points had been moved slightly to more accurately place their pushpin on the map before getting their latitudes and longitudes that were stored on the database. Addresses were found for all 22 locations in just over a minute using the ActiveX control in a VB app. The majority of this time was used to find 2 of the addresses, 1 in a more rural area, 1 next to a golf course (therefore fewer available nearby streets and addresses). 10 addresses were found on the first attempt; 18 were found in 7 or fewer attempts; the rest in 18, 39, 112 and 403 attempts. When run only with the 18 addresses that were found in fewer than 10 attempts, the process ran in about 10 seconds.

The code is as follows (Note to folks who saw a preview of this: I made a small change adding "Exit For" statements for each inner loop for the sides of the "squares"):

Discuss this story in the forum.

Author: Walt Cygan
Email: wcygan(AT)macrogroup.net
URL: http://www.macrogroup.net
Walt is a consultant for The MACRO GROUP, Inc. in Minneapolis, Minnesota. The MACRO GROUP, Inc. is an information systems consulting firm whose customers include public, private and non-profit organizations of all sizes.



Google
 
MP2Kmag Internet


 Recent Discussion
-bingmaps: @redwanhuq I mean, what exactly is inaccurate? Can you provide the info you're searching for? Slowness could be connectivity.
-BingMapsDev: Reading @Chrispendleton article 'The world according to Bing' http://bit.ly/9mmoWy
-Easy game maker to make games like day of the tentacle or platform games?
-bingmaps: "The Thing About Bing" CP interview published in @gim_intl mag: http://bit.ly/b4l6eJ. Avail free online. ^CP
-bingmaps: Add Bing (Maps) to Your Safari Browser Extensions: http://bit.ly/aFeDsd. ^CP
-bingmaps: Here's a fun video: 10 Places not on Google Earth: http://bit.ly/bTcx1Y. ^CP
-MapPoint or alternative for Haiti?
-bingmaps: RT @gim_intl: ^JB We have published an interview with #Microsoft #Bing #Maps's @chrispendleton - now available online! http://ht.ly/2ik9f
-Problem with FindAddressResults
-Map multiple layers on one map
-bingmaps: Nice to see @MSFTResearch project Street Slide outside the firewall: http://j.mp/bUUYTu. ^CP
-SpatialImportDll_Feature colour Display
-bingmaps: See the updated Bing Twitter Map App? Photo pins, sharing, tabbed searches walk thru embedded maps: http://bit.ly/9rnCaL ^CP
-bingmaps: @redwanhuq Whatchu talkin' bout Willis? Details of your setup please...
-bingmaps: @zafeuer Pretty sure that's comScore rankings. ^CP
-Copying thematic maps from MapPoint 2010 to Excel/Word 2007
-Export territory data
-bingmaps: @mackenziepricee @TravisPearl MSR built Destination Maps as a Bing Map App. ^CP
-bingmaps: My IEEE article, "The World According to Bing" has gone syndicate. You can read it online now: http://bit.ly/apUnNL. ^CP
-bingmaps: @natelawrence You would think so...updates are coming, tho. The pump is certainly primed. ^CP
-bingmaps: RT @IncaX: IncaX, ONR, Pelican Racing and @BingMaps feature in GIS Professional magazine. http://tinyurl.com/34kjch7 ^CP
-bingmaps: @zafeuer Surprisingly, MQ is still number two in Map Search...for now. Do people still use AOL to connect to the intertube? ^CP
-bingmaps: @blakey15 Always a chance. Do you WANT a Silverlight experience or something within the SL experience?
-How up-to-date are the zip codes in MapPoint?
-MapPoint Business-Suite - freeware
 Resources
Browse GIS books and periodicals
Find a MapPoint Partner or Consultant
Real Estate Columbia, MO


Want Your Site To Appear Here?

   © 1999-2009 MP2K. Questions and comments to: website@mp2kmag.com
  Microsoft and MapPoint 2002/2004/2006/2009 are either trademarks or registered trademarks of Microsoft.

Improve your career with a computer degree LocalEDU.com
• Buy Toner Cartridges at Marquee Office Solutions
• Looking for Dry Erase Boards? See Dry Erase Boards • The Search Starts Here Used Cars
• 5339 - We Know Bikes: Road Bikes / Triathlon Bikes / Mountain Bikes / BMX Bikes
• Buy Your Car Used Cars UK, Car Lease and Contract Hire