Julien's Blog : Getting Location Data for an UIImage

The images you get from the imagePickerController:didFinishPickingMediaWithInfo: UIImagePickerController delegate method do not contain location data. To access this metadata you have to go through the AssetsLibrary framework and the latitude and longitude can then be found under the {GPS} key of the metadata dictionary.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSURL *url = info[@"UIImagePickerControllerReferenceURL"];
    if (url) {
        ALAssetsLibrary *lib = [[ALAssetsLibrary alloc] init];
        [lib assetForURL:url resultBlock:^(ALAsset *asset) {
            NSDictionary *metadata = asset.defaultRepresentation.metadata;
            if (metadata) {
                NSNumber *longitude = metadata[@"{GPS}"][@"Longitude"];
                NSNumber *latitude = metadata[@"{GPS}"][@"Latitude"];
                if (longitude && latitude) {
                    CLLocationCoordinate2D coord = CLLocationCoordinate2DMake([latitude doubleValue],
                        [longitude doubleValue]);
                    // do something with coordinate
                }
            }  
        } failureBlock:^(NSError *error) {
            //User denied access
            NSLog(@"Unable to access image: %@", error);
        }];
    }
}

The first time assetForUrl:resultBlock: is called the user will be asked to authorize the access.

You can contact me on Twitter or at julien@caffeine.lu