SpatiaLite 2.3.1          supporting EXIF GPS


back
SpatiaLite directly supports EXIF GPS. The EXchangeable Image file Format represents the de facto standard widely supported by the photographic industry; quite any digital camera implements this standard.
You can get some useful information about EXIF at:
http://en.wikipedia.org/wiki/Exchangeable_image_file_format

EXIF defines a large set of metadata encapsulating a picture in the popular JPEG format; not all JPEGs supports the EXIF metadata, but you can see any EXIF picture using a plain JPEG viewer.
The vast majority of EXIF metadata is finalized to describe the photographic settings [i.e. lens focal length, aperture, shutter speed ...].
Anyway [and this is most exciting in a GIS context], EXIF metadata can contain a GPS position as well, if the camera was connected to some GPS device when shooting.
For long time this GPS option was available on expensive high end professional digital SLRs [and this required connecting the camera to some external GPS device using a cable], but in very recent times a large number of inexpensive compact digital cameras are directly mounting a GPS chip on-board.
And that's not all: the i-Phone come first integrating both a GPS chip and a digital camera, and now an increasing number of power cell phone models are able to produce EXIF GPS pictures.


Importing EXIF pictures in a SpatiaLite DB

You can download the EXIF GPS samples required by following examples.
This sample contains an half dozen pictures I've shot in Arezzo using a Nikon P6000 digital camera [a recent model mounting a GPS chip].

exif-1
We can now create an empty DB and the load the EXIF GPS pictures simple using the ad hoc tool supported by spatialite-gui.
After performing this task we can notice that now the database contains several new tables: Alternatively, you can use the exif_loader CLI tool to import EXIF pictures into a SpatiaLite DB.

cd exif-gps-samples
exif_loader -d exif.sqlite -D .

exif_loader: cannot open file './.': Permission denied
exif_loader: cannot open file './..': Permission denied
file './DSCN0010.JPG' succesfully loaded
file './DSCN0012.JPG' succesfully loaded
file './DSCN0021.JPG' succesfully loaded
file './DSCN0025.JPG' succesfully loaded
file './DSCN0027.JPG' succesfully loaded
file './DSCN0029.JPG' succesfully loaded
file './DSCN0038.JPG' succesfully loaded
file './DSCN0040.JPG' succesfully loaded
file './DSCN0042.JPG' succesfully loaded
file './exif.sqlite' doesn't seems to be a valid EXIF


*** 9 EXIF photos where succesfully inserted into the DB



And we'll not quickly explain just two simple examples.
The following are the complete EXIF metadata for one single picture; a really impressive data collection, isn't it ?

SELECT *
FROM ExifMetadata
WHERE PhotoId = 1

PhotoIdTagIdTagNameGpsTagValueTypeTypeNameCountValuesValueIndex ByteValueStringValueNumValueNumValueBisDoubleValueHumanReadable

11GPSLatitudeRef12STRING20NULLNNULLNULLNULLNULL
12GPSLatitude15RATIONAL30NULLNULL43143.000000NULL
12GPSLatitude15RATIONAL31NULLNULL28128.000000NULL
12GPSLatitude15RATIONAL32NULLNULL2814000001000000002.814000NULL
13GPSLongitudeRef12STRING20NULLENULLNULLNULLNULL
14GPSLongitude15RATIONAL30NULLNULL11111.000000NULL
14GPSLongitude15RATIONAL31NULLNULL53153.000000NULL
14GPSLongitude15RATIONAL32NULLNULL6455999991000000006.456000NULL
15GPSAltitudeRef11BYTE10BLOB sz=1 UNKNOWN typeNULLNULLNULLNULLNULL
17GPSTimeStamp15RATIONAL30NULLNULL14114.000000NULL
17GPSTimeStamp15RATIONAL31NULLNULL27127.000000NULL
17GPSTimeStamp15RATIONAL32NULLNULL7241007.240000NULL
18GPSSatellites12STRING30NULL06NULLNULLNULLNULL
116GPSImgDirectionRef12STRING20NULLNULLNULLNULLNULL
118GPSMapDatum12STRING100NULLWGS-84 NULLNULLNULLNULL
129GPSDateStamp12STRING110NULL2008:10:23NULLNULLNULLNULL
1270ImageDescription02STRING320NULL NULLNULLNULLNULL
1271Make02STRING60NULLNIKONNULLNULLNULLNULL
1272Model02STRING140NULLCOOLPIX P6000NULLNULLNULLNULL
1274Orientation03SHORT10NULLNULL1NULLNULLNormal
1282XResolution05RATIONAL10NULLNULL3001300.000000NULL
1283YResolution05RATIONAL10NULLNULL3001300.000000NULL
1296ResolutionUnit03SHORT10NULLNULL2NULLNULLInches
1305Software02STRING210NULLNikon Transfer 1.1 WNULLNULLNULLNULL
1306DateTime02STRING200NULL2008:11:01 21:15:07NULLNULLNULLNULL
1531YCbCrPositioning03SHORT10NULLNULL1NULLNULLNULL
133434ExposureTime05RATIONAL10NULLNULL43000.0133331/75 sec
133437FNumber05RATIONAL10NULLNULL59105.900000F 5.9
134665Exif IFD Pointer04LONG10NULLNULL268NULLNULLNULL
134850ExposureProgram03SHORT10NULLNULL2NULLNULLNormal program
134853GPSInfo IFD Pointer04LONG10NULLNULL926NULLNULLNULL
134855ISOSpeedRatings03SHORT10NULLNULL64NULLNULL64 ISO
136864ExifVersion07UNDEFINED40BLOB sz=4 UNKNOWN typeNULLNULLNULLNULLNULL
136867DateTimeOriginal02STRING200NULL2008:10:22 16:28:39NULLNULLNULLNULL
136868DateTimeDigitized02STRING200NULL2008:10:22 16:28:39NULLNULLNULLNULL
137121ComponentsConfiguration07UNDEFINED40BLOB sz=4 UNKNOWN typeNULLNULLNULLNULLNULL
137380ExposureBiasValue010SRATIONAL10NULLNULL0100.0000000.00 EV
137381MaxApertureValue05RATIONAL10NULLNULL29102.900000F 2.7
137383MeteringMode03SHORT10NULLNULL5NULLNULLMultiSegment
137384LightSource03SHORT10NULLNULL0NULLNULLUnknown
137385Flash03SHORT10NULLNULL16NULLNULLNo Flash
137386FocalLength05RATIONAL10NULLNULL24124.00000024.0 mm
137500MakerNote07UNDEFINED32980BLOB sz=3298 UNKNOWN typeNULLNULLNULLNULLNULL
137510UserComment07UNDEFINED1260BLOB sz=126 UNKNOWN typeNULLNULLNULLNULLNULL
140960FlashpixVersion07UNDEFINED40BLOB sz=4 UNKNOWN typeNULLNULLNULLNULLNULL
140961ColorSpace03SHORT10NULLNULL1NULLNULLsRGB
140962ExifImageWidth04LONG10NULLNULL640NULLNULL640 pixels
140963ExifImageLength04LONG10NULLNULL480NULLNULL480 pixels
140965Interoperability IFD Pointer04LONG10NULLNULL896NULLNULLNULL
141728FileSource07UNDEFINED10BLOB sz=1 UNKNOWN typeNULLNULLNULLNULLNULL
141729SceneType07UNDEFINED10BLOB sz=1 UNKNOWN typeNULLNULLNULLNULLNULL
141985CustomRendered03SHORT10NULLNULL0NULLNULLNULL
141986ExposureMode03SHORT10NULLNULL0NULLNULLAuto exposure
141987WhiteBalance03SHORT10NULLNULL0NULLNULLAuto
141988DigitalZoomRatio05RATIONAL10NULLNULL01000.000000NULL
141989FocalLengthIn35mmFilm03SHORT10NULLNULL112NULLNULL112 mm
141990SceneCaptureType03SHORT10NULLNULL0NULLNULLStandard
141991GainControl03SHORT10NULLNULL0NULLNULLNone
141992Contrast03SHORT10NULLNULL0NULLNULLNormal
141993Saturation03SHORT10NULLNULL0NULLNULLNormal
141994Sharpness03SHORT10NULLNULL0NULLNULLNormal
141996SubjectDistanceRange03SHORT10NULLNULL0NULLNULLUnknown



And this is an example of the ExifPhoto table content:
SELECT PhotoId, Photo, PixelX, PixelY, CameraMake, CameraModel,
    DateTime(ShotDateTime), AsText(GpsGeometry), Srid(GpsGeometry),
    GpsDirection, GpsSatellites, DateTime(GpsTimestamp), FromPath
FROM ExifPhoto

PhotoIdPhotoPixelXPixelYCameraMakeCameraModelDateTime
(ShotDateTime)
AsText
(GpsGeometry)
Srid
(GpsGeometry)
GpsDirectionGpsSatellitesDateTime
(GpsTimeStamp)
FromPath

1BLOB sz=161713 JPEG-EXIF-GPS image640480NIKONCOOLPIX P60002008-10-22 16:28:39POINT(11.885127 43.467448)4326NULL062008-10-23 14:27:07./DSCN0010.JPG
2BLOB sz=159137 JPEG-EXIF-GPS image640480NIKONCOOLPIX P60002008-10-22 16:29:49POINT(11.885395 43.467157)4326NULL062008-10-23 14:28:17./DSCN0012.JPG
3BLOB sz=157382 JPEG-EXIF-GPS image640480NIKONCOOLPIX P60002008-10-22 16:38:20POINT(11.884538 43.467082)4326NULL062008-10-23 14:36:47./DSCN0021.JPG
4BLOB sz=150301 JPEG-EXIF-GPS image640480NIKONCOOLPIX P60002008-10-22 16:43:21POINT(11.881635 43.468365)4326NULL052008-10-23 14:41:49./DSCN0025.JPG
5BLOB sz=157723 JPEG-EXIF-GPS image640480NIKONCOOLPIX P60002008-10-22 16:44:01POINT(11.881515 43.468442)4326NULL052008-10-23 14:42:29./DSCN0027.JPG
6BLOB sz=150085 JPEG-EXIF-GPS image640480NIKONCOOLPIX P60002008-10-22 16:46:53POINT(11.880172 43.468243)4326NULL052008-10-23 14:45:20./DSCN0029.JPG
7BLOB sz=157569 JPEG-EXIF-GPS image640480NIKONCOOLPIX P60002008-10-22 16:52:15POINT(11.879213 43.467255)4326NULL042008-10-23 14:50:40./DSCN0038.JPG
8BLOB sz=152893 JPEG-EXIF-GPS image640480NIKONCOOLPIX P60002008-10-22 16:55:37POINT(11.879112 43.466012)4326NULL042008-10-23 14:54:00./DSCN0040.JPG
9BLOB sz=156695 JPEG-EXIF-GPS image640480NIKONCOOLPIX P60002008-10-22 17:00:07POINT(11.881478 43.464455)4326NULL042008-10-23 14:57:41./DSCN0042.JPG



back