Hexagon Geospatial
MENU

Spatial Modeler Tutorials

Learn more about our products, find answers, get the latest updates, and connect with other Hexagon Geospatial product users, or get support from our professional service team.
Showing results for 
Search instead for 
Do you mean 

Geodetic Reprojection of Raster Imagery

by Technical Evangelist on ‎03-22-2018 08:59 AM (2,423 Views)

 

Download model

 

Description:

 

geodeticreprojectraster_v16_5_0.gmdx
reproject_model.PNG

 

 

This Model takes an image with an existing map coordinate system (whether it's via a geometric calibration or an actual ortho-image) and resamples the image from the input Coordinate Reference System (CRS) to a user-selected CRS (and ortho-resamples at the same time if the input is a geometrically calibrated image).  This is a task which can easily be achieved in the regular ERDAS IMAGINE user interface, however use of a Spatial Model to perform this task makes Batch reprojecting large numbers of images as a service much easier.

 

The input image must either be an ortho-image, or a raw (file coordinate) image that already has a geometric model calibration associated with the data. Such association is automatically the case in ERDAS IMAGINE for data such as NITFs or TIFFs supplied by DigitalGlobe or other satellite data vendors. Or geometric models can be manually associated (or existing models fine-tuned) through other methods, such as the use of IMAGINE Photogrammetry block triangulation, manual GCP editing and rigorous sensor model solution, the Calibrate with Sensor Model and Terrain tool, etc. No matter what methodology is used, this Model expects the input image to be already associated with a geometric model - it simply uses that model to resample from one CRS to another CRS.

 

In the case of input imagery with a 3D geoemtric model calibration (e.g. RPCs), an optional raster DEM filename can be used for the elevation source for the 3D geometric model . If no DEM Filename is specified, the elevation source set on the model  saved with the image will be used. If the geometric model being used is not 3D (such as when the input image is already an ortho-image), any specified DEM will be ignored and has no effect. In the absence of other sources of DEM information ERDAS IMAGINE is delivered with a global DEM ($IMAGINE_HOME\etc\globalterrainsources\globaldem2.jp2) and a higher resolution version can be downloaded from the Hexagon Geospatial web site (http://download.hexagongeospatial.com/downloads/global-dem-data).

 

The pixel size (and units) of the output image can be manually specified if a specific size is required (e.g. 1m x 1m pixels). Or the fields can be left blank and a default value will be derived in a manner that maintains the size of the pixels in map space. Note that if a pixel size is specified it will be translated into the units of the output CRS. For example, if an output pixel size of 4m x 4m is specified, but the output CRS is Lat/Lon, the 4m values will be automatically translated to Decimal Degrees when the model runs.

 

Note that if you use this particular Model to reproject a DEM, it will only reproject the horizontal coordinate system, not the vertical. So it would not translate the vertical datum from, say, Mean Sea Level to WGS84. A slightly different Model would be required to do that. I may take a stab at producing a model of this variety in a future, separate Spatial Recipe post. 

 

Also note, if your input imagery contains wedges of "background" (e..g. DN values of 0) at the edges, but these locations have not been marked as NoData, you may wish to mark them as NoData prior to running this Model. Such an assignment could also be made inside the Model as well, through use of a Set to NoData operator after the Raster Input, if desired.

 

Input parameters: 

 

Raster Filename In: The name of the input raster dataset. The raster should provide a full set of PCS information (projection type, spheroid, datum, parameters, etc.) necessary to perform a geodetic reprojection from one PCS to another.

Optional DEM: DEM to be optionally used for orthorectification. Can be left blank if no DEM available or is already defined by the Input Image's 3D geometric model.

Raster Filename Out: The name of the output raster dataset.

Projected Coordinate System (PCS): Define the output 2D Projected Coordinate System to use for reprojecting the input image to. The default is Lat/Lon.

Resample Method: The interpolation type to be used when reprojecting the input image. Valid values are "Nearest Neighbor", "Bilinear Interpolation", "Cubic Convolution", "LaGrange", and "Bicubic Spline".

Cell Size Rule: Define if you will manually Specify the output Pixel Size (using the fields below), or derive it from the input raster size (Same As Input) or use the Minimum or Maximum pixel dimensions of the input raster.

Pixel Width Optional value for the output pixel x size. A value will be calculated if left blank and Cell Size Rule is set to Same As Input. Value and Units will be translated to the PCS selected.

Pixel Height: Optional value for the output pixel y size. A value will be calculated if left blank and Cell Size Rule is set to Same As Input. Value and Units will be translated to the PCS selected.

Pixel Units: Units to be used for Pixel Width and Height values. Value and Units will be translated to the PCS selected when the Model runs.

Force Square Pixels: If True, output pixels with have equal values for Pixel Width and Height (in the dimensions of the target PCS)

 

reproject_dialog.png

 

Batch Processing

 

If using the Model to batch reproject several images, go to the Spatial Modeler tab / Execute group / Run pull-down and select Run in Batch. This will launch the standard Batch Editor dialog with the reprojection model command loaded and already variabalised for use. Note that since there are 10 Port Input operators in the Model (the purple colored operators on the left of the Model) there are 10 corresponding input variable columns to be completed in the Batch Editor CellArray. Each row in the CellArray will effectively represent an individual execution of the orthorectify command on a specific input image. There are numerous ways to utilize the Batch Editor to use the loaded command, but a common approach would be as follows:

 

  • Select the RasterFilenameIn column (by clicking on its header) and click Add Files.
  • Use the File Chooser to select those input images you wish to batch reproject and add them to the CellArray list. Alternatively you can drag-n-drop files from Windows Explorer onto the CellArray to queue those files.
  • Depending on what you did with the Model prior to clicking Run in Batch you may wish to remove the first Row at this stage (by clicking on 1 in the Row column, right clicking and Delete Selection)
  • Note that the variable column for RasterFilenameOut name has been autopopulated based on a pre-defined pattern. If you wish to alter this naming pattern, or location of the output files, use the Variable Editor by clicking on the Edit button and then selecting RasterFilenameOut in the Variable list. The same applies to the other variables.
  • If you are going to provide OptionalDEM filename(s) turn on the Use Filechooser to Edit Name checkbox and then click in the Cell you want to define a OptionalDEM filename for. This will bring up a File Chooser for you to select the appropriate DEM filename to use with the corresponding InputImage. Repeat for each other row you wish to define an optional DEM for, Alternatively, If you want to use the same DEM (e.g. a Global DEM or Elevation Library) for multiple InputImages, you can turn on the Show Full Pathname checkbox, select an existing displayed path and filename for a DEM in the CellArray, copy that string and Paste it into other OptionalDEM cells.
  • To edit the PixelHeigth, PixelWidth, ResampleMethod and PixelUnits turn off the Use Filechooser to Edit Name checkbox. Click in the Cell to be altered and type the desired value. Again, if using the same value in multiple places you can Copy / Paste the string, or use the CellArray Formula function to populate the fields in selected rows / columns (or modify the appropriate Variable).
  • Once the commands are populated satisfactorily, click Submit to set up parallel processing of the jobs and/or to schedule processing times.

However, if using the Model to batch reproject several images it is often easiest to remove those Port Inputs for values which will not vary through the set of input images to be batched. For example, if all input images will be batch reprojected to 1m by 1m pixels, go ahead and delete the Pixel Width, Pixel Height and Pixel Units Port Inputs and set the required values on the Define Processing Area operator input ports themselves prior to going to the Spatial Modeler tab / Execute group / Run pull-down and selecting Run in Batch. Otherwise any values left with Port Input operators on them must be populated with values in the Batch Command Editor CellArray - they cannot be left blank with the intent of automatically using default values.

 

Another approach would be to wrap the majority of the existing model into an Iterator operator and use a Multi Filename Input operator to construct a list of images to be reprojected and use that to control the Iterator execution. This would bypass the Batch Editor entirely. Again, I may take a stab at producing a model of this variety in a future, separate Spatial Recipe post. 

 

 

 

   

 

Comments
by
on ‎03-23-2018 02:14 AM

Could this work out annoying small detail that if file has no units defined Imagine GUI based projection setting tends to fail. So could this be the tool that can set units and projection in one run?? Maybe that requires another Define Processing Area operator which confirms the unit setting first before projection is given.

 

I am not blaming software as it is hard to define lat/long projection if units are truly meters and vice versa. So unit thing is important to know and not all units and valid for all projections. I am just looking ways to avoid that old style which ended up to two separate runs pretty often.

by Technical Evangelist
on ‎03-23-2018 05:32 AM

Hi Timo,

 

Not entirely clear what you mean.

 

If your input data has no units defined then you cannot reproject it. As stated in the description (I think  - perhaps I missed that bit), you have to have full projection information defined on any input images you wish to reproject. This is just the nature of reprojection. If your data lacks full projection information you should really correct that before performing any analysis, not just when running this Model. You should use Image Command Tool to set the information before attempting to reproject. There's a nice new eTraining movie on that topic

 

http://community.hexagongeospatial.com/t5/ERDAS-IMAGINE/Setting-Projection-Parameters-Using-the-Batc...

 

On the other hand, if you mean it's difficult to know what the output dd pixel size should be when reprojecting to Lat/Lon - yes, that's taken care of by the Model. If you specify you want output pixels of (approximately) 1m x 1m when reprojecting a UTM image to Lat/Lon the Model figures out the conversion to dd for you when it executes. Same for other "mismatches" - when going from State Plane Feet to UTM Meters you could enter the desired pixel size in feet and it will translate to the correct number of meters for you.

 

Cheers

 

 

 

 

 

by
‎03-23-2018 05:41 AM - edited ‎03-23-2018 05:42 AM

I mean if you run a batch that defines both Map Model and Map Projection at once it pretty often fails and you need to typically define Map Model first and then projection in second run. What I mean is that does this new model allow control so that first Map Model (=units) is given then it gives projection but in user perspective it is just one run.

 

So you excactly knew what I ment - link you gave is correct but I think there is minor usability failure in this process and hoped this could solve it. The process described in video does not work always depending which projections happens to be in use.

 

......or then I am talking about ancient stuff and this was fixed many years ago :-)

 

My point is could spatial modeller give bit more flexibility in oder how different commands are run compared to Image Command tool and does your model actually represent that already or could it use another Define Processing Area operator to feed units first before giving the projection?

by Technical Evangelist
‎03-23-2018 05:50 AM - edited ‎03-23-2018 05:50 AM
by
on ‎03-23-2018 06:05 AM

Excactly and I though when seeing your model could it be done by queuing multiple Define Processing Area operators in one model?

Courses
Contributors