mapsize2region

region_opt, proj_opt = mapsize2region(proj=?, scale=?, clon=?, clat=?, width=?, height=0, bnds="", plot=false)

Compute the region for a map of user specified projection, scale, width and height.

Kwargs

  • proj: Projection. Either a string (e.g. “m” for Mercator, “lambert”, “stere”, etc.), or a tuple for projections that demand more parameters. Same syntax as coast, etc.
  • scale: Scale of the map in the form of “1:xxxx” (e.g. “1:1000000”).
  • clon: Center longitude of the map in degrees.
  • clat: Center latitude of the map in degrees.
  • width: Width of the map in centimeters.
  • height: Height of the map in centimeters. If not specified, it defaults to width.
  • bnds: We need a default limits as first approximation to obtain the seeked region. That normally is the global [-180 180 -90 90]. But that might not work for certain cases as for example the Mercator projection Where no poles are allowed). Thoug the Mercator case is dealt in internally, there are other projections that don’t allow global limits. In those cases, you will need to specify bnds using the same syntax as for the region option of all GMT functions.
  • plot: If true, we generate an example map representative of the requested region using coast function. Use this only to get an idea of the obtained region. No fine tunings are done here. Default is false.

Returns

A tuple with the region in the form of “xmin/xmax/ymin/ymax” and the projection string used. Use this ooutput as input on all odules that require a region and projection.

Credits

Stolen fom Tim Hume’s idea posted in the GMT forum: https://forum.generic-mapping-tools.org/t/script-to-create-a-map-with-defined-width-and-height/5909/17?u=joaquim

Example

opt_R, opt_J = mapsize2region(proj=(name=:tmerc, center=-177), scale="1:10000000", clon=-177, clat=-21, width=15, height=10)

# And now do a simple coastline map showing the region.
# Note that the same could be achieved by setting the `plot=true` but this shows more explicitly
# how to use the mapsize2region() output.
coast(region=opt_R, proj=opt_J, shore=true, show=true)

Methods

# 2 methods for generic function "mapsize2region" from GMT:
 [1] mapsize2region(; proj, scale, clon, clat, width, height, bnds, plot)
 [2] mapsize2region(proj::String, scale::String, clon::Float64, clat::Float64, width::Float64, height::Float64, bnds)

See Also