Outside -90/+90 degree range: pygmt.info()/gmt info output for geographic data and -I option in polar latitudes

Hi all

I am generating a set of maps using pygmt.info( data=myGeoDataFrame, spacing=4 ) to set the region. Now, one of the features I am plotting has vertices around -88.8˚S, resulting in a -R-48/128/-92/-76 region definition. As I parse this straight into pygmt.coast() and a Mercator projection, pygmt rightly complains about -92 being outside the -90/+90 degree range (this is for global features, so currently I am not worried too much about the projection).

As the geodataframe has an EPSG:4326 projection, I would have assumed that pygmt.info() is clever enough to just give -90 as southern boundary. The same happens also with OGR_GMT-formatted data ( @Je4326 in header) and gmt info.

Bug or feature request to limit the increment output of (py)gmt info for geographic data to -90/+90 degree range?

Cheers,
Christian

/edit: GMT 6.4.0_965fc97-dirty_2021.11.20, pygmt v0.5.0

You are probably not telling GMT that your data are geographic lon/lat. When I use -fg and get a region out of bounds, GMT will say this:

gmt info t.txt -I7 -fg
gmtinfo [WARNING]: Using -I caused wesn[YLO] to become < -90. Reset to -90.

-R0/35/-90/-84

[Note to self: wesn[YLO] really? You could not just write south?]. Of course, we cannot prevent you from using this with a Mercator projection and there is no “default” latitude for that anyway other than < 90. If you plan to do this then you would be better off getting the w e s n values numerically and impose your own limits.

Perhaps the Pygmt wrapper can check for this and pass the -fg flag to the API.

The same happens also with OGR_GMT -formatted data ( @Je4326 in header) and gmt info

That I may be able to fix in the core.

Thanks Paul, clear case of RTFM and being too late in the case of gmt info.

PyGMT.info() however doesn’t seem to have a flag for geographic data indeed.

For now, I’ll probably post-process the string from pygmt.info() to make sure that it is -90 < s < 90 like you suggest.

Cheers,
Christian

For completeness, I am using for now:

    region = pygmt.info( data=gdf,spacing=4)
    if region[2] < -90:
        region[2] = 89.9.
    if region[3] > 90:
        region[3] = 89.9.

[edited to include @EJFielding’s suggestion]

If you are using the Mercator projection, you will get better results if you make the maximum latitude less than 90 degrees, like 89.9 degrees.

CLI GMT master now understands the EPGS4326 in an OGR/GMT file (and hence shape files) at least, but doing this for the dataframe will need to take place in PyGMT.

Thanks @pwessel - Will test with the CLI version!

@EJFielding - much appreciated, have adopted my script & post accordingly.