MapPoint Forums

MapForums

Community of MapPoint and Bing Maps Users and Developers




Problems geocoding Canadian locations

This is a discussion on Problems geocoding Canadian locations within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi All, I'm in the process of creating a simple geocoder in Excel 2007 using data obtained from MapPoint 2009 ...


Go Back   MapPoint Forums > Map Forums > MapPoint Desktop Discussion

Today's Posts Twitter Feed Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-07-2009
Junior Member
White Belt
 
Join Date: Oct 2009
Location: USA
Posts: 9
Problems geocoding Canadian locations

Hi All,

I'm in the process of creating a simple geocoder in Excel 2007 using data obtained from MapPoint 2009 (NA version). I'm using the code below to pass a row of data containing ID, Address, City, "", State, Zip/Postal Code, and Country to MapPoint to create a pushpin. Once created, I'm retrieving the Lat & Lon properties of the pushpin and placing them beside the Country value on the row.

The code works great for US locations whether or not all fields are filled in. The problem is with Canadian locations. For example, 506 Woodcrest Avenue, Oshawa, "", ON, L1J-2T8, CANADA returns the coordinates (38.37860067, -75.54357243) which is located in Salisbury, MD 21804. If I simply type the address info in the MapPoint Advanced toolbar to search for the address, it finds it instantly.

If I enter only a Canadian city-state combination, it returns the city center. If I add anything else, especially postal code, I get all kinds of weird results.

Any suggestions on how I can obtain proper coordinates for Canadian sites?

Thanks

Edit: Here's what I'm passing from Excel

ID Address City State Zip/Postal Code CountryCode
C1 5039 Rue St. Dominique Montreal PQ H2K-4J7 CANADA
C2 506 Woodcrest Avenue Oshawa ON L1J-2T8 CANADA
C3 Oshawa ON L1J-2T8 CANADA


Dim oApp As MapPoint.Application
Private Sub CommandButton1()
'Capture Start Time
[f2] = Time

Set objApp = CreateObject("MapPoint.Application.NA.16")
objApp.Visible = True
Set objMap = objApp.NewMap

'Variable to house starting row number
NRow = 4

'Loop through records until break in column A
Do
On Error Resume Next

Set objloc = _
objMap.FindAddressResults( _
Worksheets("Sheet1").Cells(NRow, 2), _
Worksheets("Sheet1").Cells(NRow, 3), , _
Worksheets("Sheet1").Cells(NRow, 4), _
Worksheets("Sheet1").Cells(NRow, 5), _
Worksheets("Sheet1").Cells(NRow, 6))(1)

objMap.AddPushpin objloc, _
Worksheets("Sheet1").Cells(NRow, 1)
objMap.DataSets.ZoomTo
Lat = objloc.Latitude
Lon = objloc.Longitude
Worksheets("Sheet1").Cells(NRow, 7) = Lat
Worksheets("Sheet1").Cells(NRow, 8) = Lon
NRow = NRow + 1
Loop While Worksheets("Sheet1").Cells(NRow, 1) <> ""

'Capture End Time
[g2] = Time
'Exit out of MapPoint
objApp.ActiveMap.Saved = True
objApp.Quit
End Sub

Last edited by Eric Frost; 10-07-2009 at 09:29 AM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 10-07-2009
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 3,580
Blog Entries: 3
Re: Problems geocoding Canadian locations

I don't think if this could be a solution, but I have heard there is a glitch with Canada and it is better to specify "Multi-Country" instead of "Canada" sometimes.. see if that helps.
Eric
__________________
~ Now taking orders for MapPoint 2010 ~
~~
~ Upgrade to MapForums Plus membership ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 10-07-2009
Junior Member
White Belt
 
Join Date: Oct 2009
Location: USA
Posts: 9
Re: Problems geocoding Canadian locations

Thanks for the quick response Eric. Within the Country field I tried "Multi-Country" in place of "CANADA", but no joy.

Of the example rows provided earlier, my Canadian sites with addresses are showing up in MD and GA. The one without an address is geocoding in Oshawa, ON; but just the centroid, not the postal code location.

I've worked with MapPoint for a while, but am somewhat new to VBA. Are there other VBA statements I could try using that might allow me to obtain these coordinates?

Andy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 10-07-2009
Junior Member
White Belt
 
Join Date: Oct 2009
Posts: 5
Re: Problems geocoding Canadian locations

I am a beginner in MapPoint 10 and was trying to see if I could obtain geocodes for a list of US addresses provided to me in Excel. I have some programming background, but I am definitely not a pro.

I came across this link that you may find helpful.

Automate Excel Canadian Google Maps In Excel

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 10-07-2009
Junior Member
White Belt
 
Join Date: Oct 2009
Location: USA
Posts: 9
Re: Problems geocoding Canadian locations

Quote:
Originally Posted by bisi_mapuser View Post
I am a beginner in MapPoint 10 and was trying to see if I could obtain geocodes for a list of US addresses provided to me in Excel.

The code I provided does well geocoding US addresses. You might try using it for your purposes.

Thanks for the suggestion, but connecting to Google Maps or an online service requires internet connectivity and that may not always be practical.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 10-07-2009
Winwaed's Avatar
Mapping-Tools.com
Black Belt
 
Join Date: Feb 2004
Posts: 1,439
Blog Entries: 40
Re: Problems geocoding Canadian locations

Shouldn't the country parameter in FindAddressResults be a GeoCountry enum, and NOT a string??

So here, you should set it to GeoCountry.geoCountryCanada


If you know it is definitely Canada, you could hard code this.
Or you could have a series of IF statements mapping strings (Canada, USA, US,etc) into GeoCountry enum codes.


Richard
__________________
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
See the Geoweb Guru for online mapping
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 10-07-2009
Junior Member
White Belt
 
Join Date: Oct 2009
Location: USA
Posts: 9
Re: Problems geocoding Canadian locations

Richard,

Thanks for the response. I've been playing around with GeoCountry.geoCountryCaanada and GeoCountry.geoCountryUnitedStates and have had some success. If I change Worksheets("Sheet1").Cells(NRow,6) in my initial code to one of the GeoCountry options above, it will geocode for that one particular country.

However, when I use it within an if-statement, I can't get it to work properly (seems to only want to do Canada if any geocoding is done). I'm not too big into VBA yet, so I'm sure I've either not declared something or have the if-statement in a bind somehow. Here's my latest code.


Dim objApp As MapPoint.Application
Private Sub CommandButton1()
'Capture Start Time
[f2] = Time
Set objApp = CreateObject("MapPoint.Application.NA.16")
objApp.Visible = True
Set objMap = objApp.NewMap

'Variable to house starting row number
NRow = 4
'Loop through records until break in column A
Do
On Error Resume Next


xlCountry = Worksheets("Sheet1").Cells(NRow, 6)
If xlCountry = "USA" Or "US" Then
Set objLoc = _
objMap.FindAddressResults( _
Worksheets("Sheet1").Cells(NRow, 2), _
Worksheets("Sheet1").Cells(NRow, 3), , _
Worksheets("Sheet1").Cells(NRow, 4), _
Worksheets("Sheet1").Cells(NRow, 5), _
GeoCountry.geoCountryUnitedStates)(1)
End If
If xlCountry = "CANADA" Or "CAN" Then
Set objLoc = _
objMap.FindAddressResults( _
Worksheets("Sheet1").Cells(NRow, 2), _
Worksheets("Sheet1").Cells(NRow, 3), , _
Worksheets("Sheet1").Cells(NRow, 4), _
Worksheets("Sheet1").Cells(NRow, 5), _
GeoCountry.geoCountryCanada)(1)
End If

objMap.AddPushpin objLoc, _
Worksheets("Sheet1").Cells(NRow, 1)
objMap.DataSets.ZoomTo
Lat = objLoc.Latitude
Lon = objLoc.Longitude
Worksheets("Sheet1").Cells(NRow, 7) = Lat
Worksheets("Sheet1").Cells(NRow, 8) = Lon
NRow = NRow + 1
Loop While Worksheets("Sheet1").Cells(NRow, 1) <> ""

'Capture End Time
[g2] = Time
'Exit out of MapPoint
objApp.ActiveMap.Saved = True
objApp.Quit
End Sub

Last edited by Eric Frost; 10-08-2009 at 08:27 AM.. Reason: disable smilies
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 10-08-2009
Winwaed's Avatar
Mapping-Tools.com
Black Belt
 
Join Date: Feb 2004
Posts: 1,439
Blog Entries: 40
Re: Problems geocoding Canadian locations

I would have defined a country enum variable, set that with the if statement, then pass it in as a variable.

That is shorter than what you have, but I'd still expect your code to work. Is there a problem with case, possibly?


Richard
__________________
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
See the Geoweb Guru for online mapping
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 10-08-2009
Junior Member
White Belt
 
Join Date: Oct 2009
Location: USA
Posts: 9
Re: Problems geocoding Canadian locations

Richard,

Thanks again for the reply. I've looked into the possibility of wrong case, but that is not the issue as I entered the country code value in all caps and the code is set for all caps.

As a temporary workaround, I've gone ahead and created two worksheets -- one for Canadian locations, the other for US locations.


My next goal will be to look at the error handling process so it flags locations that were not found (currently it uses the same coordinates as the last geocoded site) or where it chose the first location (which may not always be the correct location).

Andy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 03-26-2010
Junior Member
White Belt
 
Join Date: Mar 2010
Posts: 1
Re: Problems geocoding Canadian locations

For anybody else having this issue, I've found the solution is to-
1. Check the ResultsQuality of the best match.
2. If it's not an exact match, only pass the first 3 digits of the postal code.

That got our success rate from something like < 20% to closer to 70% on at least 1 customer's data.

You can also try passing the postal code with the city parameter blank, or 3 digits with the city blank, and see what you get.

The reason we frequently didn't get an exact match for rural addresses in Canada is because MapPoint uses the name of the township (or whatever it's called up there) as the city for the pin, instead of the postal city.


Why MapPoint automatically picks the first result as being correct and changes the city name on its own but doesn't when using the API is beyond me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
canada, canadian, excel, geocode, geocoding, locations, problems, vba


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Creating Canadian territories using FSA gotegra MapPoint Desktop Discussion 6 11-20-2007 12:43 PM
MapPoint 2006 & Canadian PCs PaulD123 MapPoint Desktop Discussion 0 12-12-2006 12:03 PM
Newbie: Need help with plotting Canadian locations mdsawyer58 MapPoint Desktop Discussion 1 06-12-2006 07:06 PM
Low Cost European and Canadian Geocoding Option in Upgrade Anonymous News and Announcements 0 06-16-2003 11:02 PM
Canadian postal code updates AM MapPoint Desktop Discussion 0 09-10-2002 12:50 PM


All times are GMT -5. The time now is 05:01 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.0 RC3
MP2K Magazine
Visitor Map



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69