Email or username:

Password:

Forgot your password?
OpenCage πŸ‘‰πŸŒ

Time for this week's geothread, a dose of #geoeducation rather than #geoweirdness

Today we thought we'd cover a common geocoding use case: extracting the coordinates from images πŸ“Έ and geocoding the location the image was taken.

1/n

19 comments
OpenCage πŸ‘‰πŸŒ

2/ When you take a picture by default most digital cameras record all sort of meta info, and store that data in the resulting image file.

Things like type of camera, exposure time, etc.

This is known as "EXIF data". Exif stands for "Exchangeable image file format"

en.wikipedia.org/wiki/Exif

#geoeducation

OpenCage πŸ‘‰πŸŒ

3/ Most photo editing software lets you see or write to the Exif data, for example you can fill in fields like copyright and name of the photographer

#geoeducation

OpenCage πŸ‘‰πŸŒ

4/ There are also many sites online that let you see a photo’s Exif data. Here’s an example: jimpl.com

#geoeducation

OpenCage πŸ‘‰πŸŒ

5/ These days the most widely used cameras πŸ“Έ are mobile phones πŸ“± and phones generally know their location (from GPS, cell, wifi, etc).

Many phones record this location info in the exif data. We can extract and reverse geocode the location the photo was taken.

#geoeducation

OpenCage πŸ‘‰πŸŒ

6/ How? Two steps:

1. get the coordinates from the exif data in the image

2. reverse geocode the coordinates into useful location information

Let's show a code example in javascript

#geoeducation

OpenCage πŸ‘‰πŸŒ

7/ Step 1 is accessing the exif data in the image.

There are software libraries in almost every programming language to do this. In our example we'll use the javascript "exif-js" library.

github.com/exif-js/exif-js

OpenCage πŸ‘‰πŸŒ

8/ 🚨 note: an image might not have this data.

It may not have been recorded or might have been removed later. Newer operating systems make it easy to turn geolocation recording on and off, in general or for a specific photo

#geoeducation

OpenCage πŸ‘‰πŸŒ

9/ Exif standard specifies that the location be stored as longitude and latitude in DMS (degrees minutes seconds) format. So we need get the location info and turn it into decimal format.

Some exif libraries have the option to do this conversion for you.

OpenCage πŸ‘‰πŸŒ

10/ Now we pass the decimal coordinates to our geocoding API and get the location πŸ™Œ

#geoeducation

OpenCage πŸ‘‰πŸŒ

11/ 🚨 WAIT!!! 🚨

The precision of the Exif coordinates depends on the tech (GPS, cell, etc) used to capture the location. So they may not be perfectly precise.

But also showing a precise location might not be appropriate or have privacy implications.

See our guide on how to show less precise location like just the city or neighbourhood:

opencagedata.com/guides/how-to

#geoeducation

OpenCage πŸ‘‰πŸŒ replied to OpenCage

12/ Precise geocoding might not make sense. Example: a tourist taking a picture right by the Eiffel Tower πŸ—Ό in Paris πŸ‡«πŸ‡·, probably wants their image geocoded as "Eiffel Tower" not the exact street address.

We offer this as a service to several large image processing customers.

#geoeducation

OpenCage πŸ‘‰πŸŒ replied to OpenCage

13/ Now you know how to turn Exif data from images into useful geographic information.

You can find the javascript code example and more background info over in our guide to reverse geocoding images:

opencagedata.com/guides/how-to

#geoeducation

OpenCage πŸ‘‰πŸŒ replied to OpenCage

14/ Thanks for reading (and sharing), we hope you enjoyed this #geoeducation thread.

We have many more threads about the #geoweirdness of specific countries, border disputes, geocoding, etc on our blog. Some still on twitter, but week by week we are moving them to mastodon (and writing new threads)

Enjoy: blog.opencagedata.com/geothrea

Bruno Girin replied to OpenCage

@opencage assuming you have that info in EXIF data, can you identify that the camera was pointing towards the Eiffel tower rather than away from it? Just to make sure that this is really what's in the frame. Focusing distance might be useful too.

OpenCage πŸ‘‰πŸŒ replied to Bruno

@brunogirin Yes, can be done, but a simpler solution is just provide the user with both responses (precise address and nearby POI) and let them then choose which one is appropriate for the situation

Derick Rethans

@opencage Writing EXIF readers is a pain the proverbial behind though. As with so many standards all camera manufacturers add their own proprietary extensions :-/

OpenCage πŸ‘‰πŸŒ

@derickr yes, this is why you should use an open source library where we can all work together.

It's never easy, Derick.

Bruno Girin

@opencage and some cameras like my DSLR allow you to automatically set the photographer's name on every photo you take with it.

frank :anarchy_bi: (he / they)

@opencage This could be practical for OSIRTβ€”open source investigative research techniques (fka OSINT) !!

Go Up