Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am working on a Modis - oceancolor image and I want to reproject it to wgs84. I have the Upper left/right and Low 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 Low Right lan/long (x,y).

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

Thank you!

share|improve this question
    
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
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.