Showing results for 
Search instead for 
Do you mean 

 

Download (original) model

 

Description:

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
EXIF_Results.png

 

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. 

 

plot_exif_locations_multifile_v16_6_2.gmdx
EXIF_Model.PNG

 

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.

 

Iterator sub-model
EXIF_Iterator.PNG

 

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.

 

Data Requirements & Assumptions

 

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. 

 

Input parameters:

 

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.

 

Comments
by Technical Evangelist
‎01-11-2021 01:01 PM - edited ‎01-11-2021 01:11 PM

Addendum 11th January, 2021:

 

Download newer model

 

Description:

 

I went back to this model to correct a problem and make a few improvements as follows:

 

  1. I noticed that the original v16_6_2 version of the model would not have worked with EXIF tags showing the data as being in the Eastern hemisphere. This was because of a simple failure to connect two ports within the Iterator. You should be able to spot the error in the screenshot shown above on the If Else 13 operator. I've corrected the issue in the v16_6_3 versions downloadable from this Comment.

  2. I found a better way to define the Projected Coordinate System (PCS) of the output data. Rather than using a Report operator to write out an appropriate .prj file after the shapefile has been created the newer model uses a Coordinate Transformation operator (more usually used for reprojecting features data). Since the point geometries derived from the EXIF tags have no internally defined PCS, application of the Coordinate Transformation instead has the effect of associating the TargetCRS with the features passing through it. The model is set up to apply Geographic Lat/Lon WGS 84 as the PCS - if the EXIF tags are using a different PCS you could modify the port directly using the Projection Chooser, or prompt for the appropriate EPSG code using this approach:

    Using an EPSG Code (snippet) - Hexagon Geospatial Community

    Note that this is not going to provide a way to reproject the points as part of the spatial model. For example, if the photograph locations are stored as Lat/Lon EXIF tags, but you wanted the output shapfile in UTM, you coudn't just specify UTM on the Coordinate Transformation operator. But you could specify Lat/Lon and then use a second Coordinate Transformation operator to transform the features from Lat/Lon to UTM. 

  3. The original model would fail if one or more of the input JPEG files lacked the requested EXIF tags. Rather than doing this the contents of the Iterator were further embedded into a Catch Error operator so that any failing iterations were captured without stopping execution of the overall model. The names of JPEG files which caused such errors are fed out of the Iterator on a new port and are sent to a Report. This is currently set up to be listed in the Session Log, but could be easily changed to write out a file. 

    Plot_EXIF_Locations_Multifile_v16_6_3.gmdx
    EXIF_Model_New.PNG
Courses
Contributors