CLGeocoder geocoding is hopelessly inaccurate
Asked Answered
D

1

16

I have an App that does forward geocoding (get coordinates given address) to display a bunch of pins on an MKMapView. The app was developed well before iOS supported forward geocoding using CLGeocoder (first available in iOS 5). As such my app uses the Google Maps Geocoding API, which is generally very accurate. Given a full address with a street number it will generally give you the exact location of that address within a couple of metres.

I'm doing some updates to my App to support iOS 6 and decided to switch from using the Google API to using CLGeocoder provided the app was running on iOS 5 or above. However in my tests (all with addresses in Portugal, where I live) it is so inaccurate as to be totally unusable.

I'm using – geocodeAddressString:completionHandler: and, for example, given the address "Avenida da Liberdade 195, Lisboa, Portugal" it gives me an "Avenida da Liberdade" in the city of Sintra, not Lisboa (Lisbon). That's about 15km away from the real address. Avenida da Liberdade is one of the biggest and most well known avenues in Lisbon. The equivalent of, say, 5th Avenue in NYC. It's not some obscure little side street.

Is there anything I'm doing wrong to get such terrible accuracy? Are others having similar accuracy issues, especially with addresses outside the US?

For the time being it looks like I'll have to stick with the Google Maps API. Incidentally, I've been using the iOS 6 simulator and there the results are no better. Putting the same search string into the search box on the iOS 6 Maps app gives the same totally inaccurate results.

EDIT: added CLGeocodercode:

    CLGeocoder *fgeo = [[[CLGeocoder alloc] init] autorelease];
    NSLog(@"Geocoding for Address: %@\n", address);
    [fgeo geocodeAddressString:address completionHandler:^(NSArray *placemarks, NSError *error) {
        if (!error) {
            // do stuff with the placemarks

            for (CLPlacemark *placemark in placemarks) {
                NSLog(@"%@\n %.2f,%.2f",[placemark description], placemark.location.horizontalAccuracy, placemark.location.verticalAccuracy);
            }
        } else {
            NSLog(@"Geocoding error: %@", [error localizedDescription]);
        }
    }];

EDIT 2: I've discovered that if I use – geocodeAddressDictionary:completionHandler: and pass in an Address Dictionary with the street address, postal code (zip code) and as much detail as I can possibly provide, it gives me reasonably accurate coordinates, but still with an accuracy radius of more than 400m which is unacceptable.

Dendroid answered 23/7, 2012 at 14:37 Comment(6)
You should post your CLGeocoder code.Sylas
@Sylas I've added the code as you suggested, all though I think it's not really relevant, as it's not the invocation of CLGeocode that's causing me problems, but the results it delivers.Dendroid
@Dendroid I am having the same problem here in Australia. When I type the best accuracy address it works fine; however if I try something a bit vague it doesn't work.Concussion
@Concussion yep, see my EDIT 2 above. Looks like I'll have to keep using the Google API for now until Apple gets its international Maps data up to scratch.Dendroid
I got the same problem, the results are not always accurate. I was thinking of using the maps API but the Google Terms of service forbid the usage of these information without displaying a Google map (see developers.google.com/maps/terms). How did you manage this ? ThanksPhonometer
@Machine_a_coder I'm aware of the Google Maps API terms and I am, ahem, ignoring them and hoping they won't notice :) My app now makes very few Maps API requests. If I'm forced to change, I'll just switch to CLGeocoder for iOS6 and above.Dendroid
D
12

Well, it would appear that yes, Apple's CLGeocoder is nothing like as accurate for forward geocoding (address -> coordinates) as the Google Maps Geocoding API, particularly outside of the USA. Using an Address Dictionary with all the fields filled out as fully as possible works a lot better than a simple address string, but it's still no where near good enough. Where Google will (usually) give you coordinates within 5-10m of the street number, Apple will give you coordinates somewhere in the right street, if you're lucky.

EDIT: Found Apple Developer Technical Note TN2289 which details Supported Countries for CLGeocoder. It would appear that Portugal is in its list of Partially Supported Regions, which it describes as:

The following are territories are not fully supported, either because coverage is more limited or for other reasons. For example a location may only be able to be geocoded to road level as opposed to a specific address point on that road.

Which matches my results with CLGeocoder in Portugal. I guess I'll just have to wait for improved coverage.

Dendroid answered 7/8, 2012 at 14:17 Comment(2)
As of today, Apple's still not working correctly event in the US. Have you had any problem with using Google's but without display on their map?Lymphocytosis
@Lymphocytosis I have had no problem at all with this. YMMV.Dendroid

© 2022 - 2024 — McMap. All rights reserved.