1

I am currently in the process of creating a Python script, that automates certain parts of my QGIS processes. Currently I am trying to translate a PNG file to a GeoTIFF with the gdal_translate tool. However, I do not know how to get the values for the '-gcp' option. The tool I am using automatically creates a KML file with these values:

<north> 65.28265</north>
<south> 63.48401</south>
<east> 53.18008</east>
<west> 49.01991</west>
</LatLonBox></GroundOverlay>
<Placemark><name>Overlay</name>
<Point><coordinates> 51.1, 64.383333,0
</coordinates></Point></Placemark></Folder></kml>

I also know that the PNG file, that I am trying to process, fits the polygon that gets created. So what I am trying to get are the coordinates of the corners of the polygon and afterwards map the corners of the PNG.

Does anyone have an idea on how to do this?

3
  • 3
    What have you tried? What happens when you try? Please provide coding attempts and error messages.
    – Erik
    Sep 16 at 14:01
  • 1
    Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works
    – Ian Turton
    Sep 16 at 14:10
  • Hi Erik and Ian - thank you for you anserws. Unfortunately I cannot show you any coding attemtps, as I do not know how to calulcate the values and therfor do not have any coding attempts. I know, that these values define the polygon, but I do not know how I can get the values that I need for the gdal_translate tool. Sep 16 at 14:39
2

Looks like you really want to use the -a_ullr argument to set the four corners of the image. I have a png with no coordinate info, and if I do this:

$ gdal_translate -a_srs epsg:4326 -a_ullr 49.01991 65.28265 53.18008 63.48401 exceed4.png exceed4.tiff

I get a tiff with these coordinates:

Corner Coordinates:
Upper Left  (  49.0199100,  65.2826500) 
Lower Left  (  49.0199100,  63.4840100) 
Upper Right (  53.1800800,  65.2826500) 
Lower Right (  53.1800800,  63.4840100) 
Center      (  51.0999950,  64.3833300) 

and the correct coordinate system.

3
  • Thank you so much - I will try it out immediately! Sep 16 at 14:41
  • It worked :) Thank you so much! Sep 16 at 15:00
  • What happens if the image (png) is not exact, is not properly proportioned. Is just enough to know UpperLeft and LowerRight coords for this ?
    – neavilag
    Sep 25 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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