Sometime over the last year or so someone asked me if it would be possible to define the desired Projected Coordinate System (PCS) in Spatial Modeler simply by entering an EPSG code. This was, I think, in connection with a Spatial Model similar to the Geodetic Reproject model. For the output PCS the desire was to enter an EPSG code, such as 32617 to denote that the input imagery should be reprojected to WGS 84 / UTM zone 17N.
To enter a PCS usually entails popping up the ERDAS IMAGINE Projection Chooser in order to define the desired parameters (which is what the Geodetic Reproject spatial model does). It is possible to enter an EPSG code into this dialog. However the request was to be able to do this without popping up the Projection Chooser because this was a Spatial Model which was going to be published out to a Smart M.App and which would therefore not have access to the the GUI dialog.
At the time I did not think it was possible to just type in a EPSG code string like "32617" and have it used to define the desired projected coordinate system.
However I recently found out that this should be possible using the following basic approach:
EPSG_to_CRSID_snippet.gmdx |
The user running the Spatial Model is prompted to enter the EPSG code number (e.g. 32617) via a Port Input. That integer is then converted to a string. The String Input operator is pre-defined with the string "Authority: EPSG; Code: " which is then concatenated with the EPSG code string to form a string such as "Authority: EPSG; Code: 32617". The From String operator is then used to convert this string to a data type of IMAGINE.CoordinateReferenceSystemID, which is the input expected by Operators such as Define Processing Area and Create Affine Transform.
This code snippet could be embedded into the Geodetic Reproject spatial model to replace the pop-up Projection Chooser dialog as shown below:
GeodeticReprojectRaster_using_epsgcode_v16_6_0.gmdx |
This modified Spatial Model has also been provided in the download Zip file linked above.