# How can I add all the 4 corners as GCP in an image that I want to reproject?

I am working on a Modis - oceancolor image and I want to reproject it to wgs84. I have the upper left/right and lower left/right values from the metadata of the image and I want to add them all in the command line of `gdal_translate` or `gdal_warp`. But in these two commands I can only add the upper left and lower right lat/long (x,y).

Do you have any idea how I can add all the corners of the image in the script?

• I am not sure I understand your question. If you enter the values, the algorithm will do the math to find all corners. If you are looking to find each corner value I find drawing a square on paper and writing out the values work. For example, if you start in the lower left and work clockwise you would have the following: 0,0; 0,1; 1,1; 1,0. If you enter the lower left X/Y (llxy) and the upper right x/y (urxy), it will be the same as the upper left x/y (ulxy) and the lower right x/y (lrxy). Using this schema gives you all the values you need to do the transformation (not needing 4 corners) – Ryan Garnett Nov 1 '12 at 3:02
• Yes of course! The problem in the image I am now working on is that the corners from lower left and clockwise are the following: 1,1; 0.5,4; 3,6; 4,3. That's why I need to add all the 4 corners... Ul(x,y) and Lr(x,y) are not enough. – Vilen Nov 1 '12 at 8:23
• Would gdal_translate work, with the -a_srs and -a_ullr? I have used this successfully for similar problems. If that is not what you need, you may consider georectifying it. I know you posted that you would like to do this in a commandline application. – Ryan Garnett Nov 1 '12 at 13:34
• This is exactly what I did but I still need to use as gcp points the other two corners. The story is that I am trying to apply an automatic command line application for this action. Still searching... – Vilen Nov 1 '12 at 14:46

GDAL works with GCP, but that requires a further step:

1. Apply the GCP
2. Transform the picture using the GCP to the source CRS
3. Reproject from the source CRS to your desired CRS

To apply the GCP correctly, you have to know the local coordinate systems used for native tif and your source CRS. The tif has the origin in the upper left corner, X to the right, and Y to the bottom. WGS84 has the origin at 0°E/0°N, X to the East, and Y to the North.

So the command lines are:

``````gdal_translate -gcp pixel1 line1 X1 Y1 -gcp pixel2 line2 X2 Y2 ... source.tif sourceGCP.tif
gdalwarp -r bilinear -t_srs EPSG:xyz sourceGCP.tif sourceCRS.tif
gdalwarp -t_srs EPSG:4326 sourceCRS.tif destCRS.tif
``````

You have to select the source CRS according to the CRS coordinates you have chosen for your GCP.

• what is sourceCRS.tif file or can you also please explain what is CRS? – Gurminder Bharani Aug 10 '16 at 13:20
• The source Coordinate Reference System (CRS) is defined by EPSG:xyz (e.g. EPSG:4326 for WGS84 lonlat degrees) in the second line. The values X1 Y1 X2 Y2 etc in the first line are given in that coordinate system. – AndreJ Aug 10 '16 at 13:35
• thank you for the prompt reply, can I add Z1 values adjacent to Y1 – Gurminder Bharani Aug 10 '16 at 14:07
• Thank you for taking out your time and replying to my queries. – Gurminder Bharani Aug 10 '16 at 14:32
• UPDATE: gdal.org/gdal_translate.html allows for elevation as a third coordinate Z1, but I don't know how that can be used. – AndreJ Aug 10 '16 at 15:28