Output proportions

Hi, I use GRASS GIS and its r.out.png module to prepare the data. Then I am trying to plot it with this script:

fig = pygmt.Figure()
fig.grdimage(
    grid = "./zm1960.png",
    frame = 'afg',
)
fig.show()

However the output has different proportions. Prepared data are 1800 x 1300 pix, whereas pygmt output is squareish.

What am I doing wrong?

If you already have an image why do you to plot it again?

To get nice cartographic output together with other maps.

From a png image that is not georeferenced you cannot do much.

It is georeferenced:

pygmt.grdinfo (grid = "./zm1960.png")
'./zm1960.png: Title: Grid imported via GDAL\n./zm1960.png: Command: \n./zm1960.png: Remark: \n./zm1960.png: Pixel node registration used [Cartesian grid]\n./zm1960.png: Grid file format: gd = Import/export through GDAL\n./zm1960.png: x_min: -628350 x_max: -627450 x_inc: 0.5 name: x n_columns: 1800\n./zm1960.png: y_min: -1000500 y_max: -999850 y_inc: 0.5 name: y n_rows: 1300\n./zm1960.png: v_min: 1.79769313486e+308 v_max: -1.79769313486e+308 name: z\n./zm1960.png: scale_factor: 1 add_offset: 0\n./zm1960.png: Default CPT: \n+proj=krovak +lat_0=49.5 +lon_0=24.8333333333333 +alpha=30.2881397527778 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +towgs84=589,76,480,0,0,0,0 +units=m +no_defs\n'

And GeoTIFF got through r.out.gdal is same way ‘squared’ as this PNG file, plus it has wrong colors.

What kind of png is this? Does it have a .pgw (or similar name) companion file? And where is this info

proj=krovak +lat_0=49.5 +lon_0=24.8333333333333 +alpha=30.2881397527778 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +towgs84=589,76,480,0,0,0,0 +units=m +no_defs

coming from?

That coordinate system is descibred in the link below. It is output of pygmt.grdinfo.

My question was more. Where does the png image stores that projection info? I know no way of doing that but apparently there is one. Can you make that image available?

This is not the png image, it is

https://forum.generic-mapping-tools.org/uploads/default/original/2X/1/1b9666ee761f967b505a185765d1b46e1327b9ba.jpeg

Hope this link works

Yes the link works but it points to a plain simple png file but a simple png cannot have coordinates nor a referencing system. So you must have more material that holds that info. Whilst for the coordinates I can imagine that you also have a companion world file (I asked about this already) for the projection I have no idea on what that might be. If you are not able to explain (and provide) these details no one can help you (or at least I can’t).

Sorry I missed that file here goes the content of .wld file:

                   0.500000000000000 
                   0.000000000000000 
                   0.000000000000000 
                  -0.500000000000000 
             -628349.750000000000000 
             -999850.250000000000000 

The thing is, that it doesn’t really matter if the file is georeferenced or not. When I run the above code for Geotiff or just plain image, the output is always disproportional like this (just with different coordinates):

I guess I found the solution.

  • By default pygmt plots data into the square window.
  • The fix for this image is projection = "X18/13"
  • In general it is projection = "Xwidth/height" to get to the original proportions

The correct way (if something automatic does not work well) should be "X18/0".

And that (the world file) still does not explain where the projection info is coming from.

Sorry, my mess. There was also an png.aux.xml generated by r.out.gdal.

Can you please attach that one too? I’m curious to see if it works.
Put it in a zip file to let the system attach that file.
Thanks.

The system argues it is bigger than 4Mb although it is 1,6… try this link.

Thanks. I learned that those aux xml files may be used to carry projection info. It is also a quite big one.
Anyway GMT can read (and plot) it fine.