How can I georeference an unrotated image by knowing two Lat/Lng coordinates?

I tried to transform the coordinates to UTM, but this didn't work (for me), because I also need to rotate it and calculate with the angles, which seems to be complicated.

My aim is to calculate every other coordinate of the image by clicking on it.

  • 2
    Which software are you using?
    – ahmadhanb
    Apr 5, 2019 at 9:51
  • 3
    Two points determine a line. Three points determine a plane. And five to ten links determine an image transformation with a decent enough RMS error to trust the result. Two points aren't nearly enough.
    – Vince
    Apr 5, 2019 at 10:09
  • @ahmadhanb I try to program this in JavaScript. Maybe I'm wrong here, but I thought, here I will get the math I need for it.
    – hideous
    Apr 5, 2019 at 10:23
  • If image is not rotated and already rectified (scanned map etc.) then two points is enough. Use for example gdal.org/gdal_translate.html with the option -a_ullr ulx uly lrx lry: Assign/override the georeferenced bounds of the output file. This assigns georeferenced bounds to the output file, ignoring what would have been derived from the source file. So this does not cause reprojection to the specified SRS.
    – user30184
    Apr 5, 2019 at 10:30
  • 1
    If you know the coordinates of the top-left pixel and pixel size you can write an ESRI worldfile en.wikipedia.org/wiki/World_file.
    – user30184
    Apr 5, 2019 at 10:44

1 Answer 1


Suppose you know that pixel (50, 75) is at (8.3, 2.3) degrees and pixel (250, 900) is at (12.3, 6.3) degrees.

Then your pixel width W is (12.3-8.3)/(250-50) and your pixel height H is (6.3 - 2.3)/(900-75)

Then your top left corner (centre of pixel (0,0)) is at (8.3 - 50*W, 2.3 - 75*H) - i.e. its 50 pixel widths left of the first reference pixel, and 75 pixel heights above it).

Your bottom right corner pixel centre is at top-left + (W * Number of columns), (H * Number of rows) - i.e. its that number of pixel widths across and down.

Those calculations give you pixel centres. Divide the width and height of the image in ground units by the number of height and width columns to get a pixel width and height, and then add or subtract half of one of those from your corner pixel centres to get pixel edges. Now you have the bounding box.

Now you can write a standard "World file" or other simple georeferencer.

Note this depends on your image being properly rectified and in the correct coordinate system, and north-up, and not subject to any distortions due to camera angle or field of view. But with two reference points you can't do any better.

  • Thanks, for your answer so far. Will try this. My image is a construction plan, so it is not north up, but I can calculate the correct angle and transform the coordinate system, to get the correct pixel.
    – hideous
    Apr 5, 2019 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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