4

I have PNG image exported from python script without any meta-data. I know coordinates of top-left corner and bottom-right corner and projection (I guess it's Mercator). How can I import this image to correct position?

To be sure, I know about Georeferencer in menu. However it seems like bad idea to resample original raster image. (I have to choose corner points manually, then enter target coordinates, and it's still not working.) Is there a way where I just enter 4 numbers and projection, and raster will appear on correct position in map? Or is it possible to somehow create metadata for this image so it will be imported automatically to correct position?

Edit: Ok, it is working when I manually set corners to correct pixel values and use Linear transformation. But it still seems like a bad solution. Adding some meta-data to image would be nicer.

4

No need to Georeference manually, if you create a World File. For .png it’ll have a .pngw extension and needs the name base name as the raster it refers to (and be in the same directory).

This is a text file and is fairly easy to set up programatically if you know the coordinates and extent of the raster. You might have to work out the cell size yourself. This should be straightforward if you have two corners.

Example (copied from GDAL docs)

pixel X size
rotation about the Y axis (usually 0.0)
rotation about the X axis (usually 0.0)
negative pixel Y size
X coordinate of upper left pixel center
Y coordinate of upper left pixel center

.

60.0000000000
0.0000000000
0.0000000000
-60.0000000000
440750.0000000000
3751290.0000000000

This doesn’t contain any projection info, you’ll need to assign a CRS to the raster when (or just after) you add it to QGIS.

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.