Many thanks to Giuseppe Maldera at Planetek Italia for providing an original model to perform this task. That model used third-party programs executed using the Command Line operator. With the release of ERDAS IMAGINE 2020 Update 2 the basic model functionality could be re-implemented using just native operators and is presented here.
|Point locations (magenta circles) of photos derived from EXIF GSP coordinates converted to a shapefile|
The desire was to take a directory containing JPEG photographs (taken with a hand-held camera, e.g of fire-hydrants, road signs, etc) and create a point Shapefile with a point representing the geospatial location of each photo. The location would be mined from EXIF tag information stored in the photos (GPSLatitude and GPSLongitude), along with other attributes (such as date and time of taking the photo - DateTime) and the full path to the file that point represents. Such a shapefile can be further manipulated in GIS applications such as GeoMedia.
The main spatial model starts by requesting the Directory to search. The Multi Filename Input operator scans that directory for files matching the criteria provided and produces a List of filenames.
That List of filenames is passed into an Iterator sub-model which processes each file individually and performs the heavy lifting of parsing out the EXIF information (using a Dictionary Item operator) and creating a point geometry feature per file. The Iterator therefore outputs a List of Features and that list is passed into the Union Features operator to combine them into a single Features stream containing multiple point features (each containing a point geometry). That then is output to a Shapefile.
There are a couple of tricks performed in the Spatial Model using the Report operator to produce desired files. At lower right of the main model a Report operator is used to create a .prj file with the same rootname as the shapefile being produced, This is to provide georeference information on the shapefile. As provided it is assumed that the model is pulling EXIF tags to create the point geometry coordinates in Lat/Lon WGS 84 and the .prj is defined to reflect that. If you modify the model to use coordinates in a different coordinate reference system you would need to provide an appropriate string for the .prj information.
The other use of Report is within the Iterator. There it is used to produce a temporary CSV file populated with the titles of the attribute fields and the corresponding attributes mined from EXIF tags. The temporary CSV file created is ingested by a Features Input operator to turn the data into IMAGINE.Features containing the one point geometry.
Note that this means that if you wish to modify the model to read different EXIF tags and use them as attributes you will need to modify the String Input 2 operator to define the names of the fields to be created in the CSV, and you will also need to modify the Cat 2 operator to concatenate all the values corresponding to those named fields. You may therefore need to add, remove or re-organise the ports on the Cat operator to provide the attribute values in the same order as the names.
It is also worth noting that I have set the Iterator's ExecutionMethod port to InProcessParallel, which is not the default. If this causes problems on your computer please set it back to the default of InProcessSerial.
Requires ERDAS IMAGINE 2020 Update 2 or later versions.
As provided the spatial model does require that specific EXIF tags are present in all the scanned JPEG files. If your JPEGs contain EXIF tags with different names or contents you may need modify the model accordingly.
The model is based on points being in Lat / Lon WGS 84
If you wish to input TIFF with EXIFs, or use other tag schemas such as XMP, you will need to modify the spatial model, especially the Dictionary Item within the Iterator to select the desired tag key/values.
JPEG Directory: The directory to scan for input *.jpg files.
Output Shapefile: The filename for the shapefile to produce which contains point geometries and other associated attribute fields.