# Output proportions

**URL:** <https://forum.generic-mapping-tools.org/t/output-proportions/4948>\
**Category:** PyGMT Q&A\
**Created:** [June 3, 2024, 3:04pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948 "2024-06-03T15:04:37Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![pawleeq](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pawleeq/32/4125_2.png) [@pawleeq](https://forum.generic-mapping-tools.org/u/pawleeq)\
**Post date:** [June 3, 2024, 3:04pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/1 "2024-06-03T15:04:37Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [June 3, 2024, 3:17pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/2 "2024-06-03T15:17:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pawleeq](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pawleeq/32/4125_2.png) [@pawleeq](https://forum.generic-mapping-tools.org/u/pawleeq)\
**Post date:** [June 3, 2024, 3:22pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/3 "2024-06-03T15:22:50Z")

</div>

To get nice cartographic output together with other maps.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [June 3, 2024, 3:27pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/4 "2024-06-03T15:27:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pawleeq](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pawleeq/32/4125_2.png) [@pawleeq](https://forum.generic-mapping-tools.org/u/pawleeq)\
**Post date:** [June 3, 2024, 3:32pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/5 "2024-06-03T15:32:32Z")

</div>

It is georeferenced:

```auto
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.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [June 3, 2024, 3:55pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/6 "2024-06-03T15:55:05Z")

</div>

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

```auto
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?

---

<div class="post-metadata">

**Author:** ![pawleeq](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pawleeq/32/4125_2.png) [@pawleeq](https://forum.generic-mapping-tools.org/u/pawleeq)\
**Post date:** [June 3, 2024, 4:02pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/7 "2024-06-03T16:02:56Z")

</div>

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

> **[S-JTSK / Krovak East North - SJTSK - EPSG:5514](https://epsg.io/5514)**
>
> EPSG:5514 Projected coordinate system for Czechia; Slovakia. North-orientated alternative for GIS purposes to south-orientated S-JTSK / Krovak (CRS code 5513) which remains the legal system. Coordinates are negative. GIS.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [June 3, 2024, 4:26pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/8 "2024-06-03T16:26:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pawleeq](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pawleeq/32/4125_2.png) [@pawleeq](https://forum.generic-mapping-tools.org/u/pawleeq)\
**Post date:** [June 3, 2024, 5:17pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/9 "2024-06-03T17:17:54Z")

</div>

![](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/1/1b9666ee761f967b505a185765d1b46e1327b9ba.jpeg)

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [June 3, 2024, 5:53pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/10 "2024-06-03T17:53:49Z")

</div>

This is not **the** png image, it is

[![](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/1/1b9666ee761f967b505a185765d1b46e1327b9ba.jpeg) ](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/1/1b9666ee761f967b505a185765d1b46e1327b9ba.jpeg)

---

<div class="post-metadata">

**Author:** ![pawleeq](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pawleeq/32/4125_2.png) [@pawleeq](https://forum.generic-mapping-tools.org/u/pawleeq)\
**Post date:** [June 3, 2024, 10:26pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/11 "2024-06-03T22:26:56Z")

</div>

Hope this [link](https://www.pawleeq.com/pub/zm1960.png) works

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [June 3, 2024, 10:57pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/12 "2024-06-03T22:57:31Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![pawleeq](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pawleeq/32/4125_2.png) [@pawleeq](https://forum.generic-mapping-tools.org/u/pawleeq)\
**Post date:** [June 4, 2024, 7:11am UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/13 "2024-06-04T07:11:00Z")

</div>

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

```auto
                   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):

 ![](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/c/c3fe0b48e7d9e2f48cb1607fc668f1aea59f278d.jpeg)

---

<div class="post-metadata">

**Author:** ![pawleeq](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pawleeq/32/4125_2.png) [@pawleeq](https://forum.generic-mapping-tools.org/u/pawleeq)\
**Post date:** [June 4, 2024, 9:09am UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/14 "2024-06-04T09:09:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [June 4, 2024, 11:14am UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/15 "2024-06-04T11:14:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pawleeq](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pawleeq/32/4125_2.png) [@pawleeq](https://forum.generic-mapping-tools.org/u/pawleeq)\
**Post date:** [June 4, 2024, 3:15pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/16 "2024-06-04T15:15:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [June 4, 2024, 3:29pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/17 "2024-06-04T15:29:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pawleeq](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pawleeq/32/4125_2.png) [@pawleeq](https://forum.generic-mapping-tools.org/u/pawleeq)\
**Post date:** [June 4, 2024, 3:37pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/18 "2024-06-04T15:37:42Z")

</div>

The system argues it is bigger than 4Mb although it is 1,6… try this [link](https://www.pawleeq.com/pub/zm1960.zip).

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [June 4, 2024, 6:27pm UTC](https://forum.generic-mapping-tools.org/t/output-proportions/4948/19 "2024-06-04T18:27:06Z")

</div>

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.
