How do I get the bounds (or center) of a named region in GMT.jl

Hi, so I’m messing around with making a map of California with a Lambert Conic Projection (my eventual goal is to make maps of the maidenhead locator for various states), unfortunately it’s at an angle unless I manually adjust the “parallels” (I assume this designates the center of the projection somehow). I specify the region with the string “US,CA”, is there any way I can get the bounds or center of a named region without having to find it manually?

here’s my code so far

using GMT
coast(
	region="US.CA", 
	proj=(name=:lambertConic, parallels=[37 -36]),
	frame=:g, 
	area=100,
    land=:gray, 
	water=:white, 
	borders=(
		(type=1, pen=(0.5, :black)),
		(type=2, pen=(0.5, :black))
	),
	inc="10m",
	show=true
)

edit: so it does what I want if I don’t specify a projection, but I would still like to know the answer in case I do want to specify a projection.

Hi,
Use the getregion option

coast(getregion="US.CA")
"-R235.584442/245.870514/32.530884/42.00983"

Hmm, but that is not numeric. Have to resort to an unexported function

GMT.opt_R2num("-R235.584442/245.870514/32.530884/42.00983")
4-element Vector{Float64}:
 235.584442
 245.870514
  32.530884
  42.00983

BTW, inc="10m" is not a coast option. inc or increment is only for when we are dealing with grids and images.

1 Like

That seems to work, thanks

Note that you can also compute the centroid with

centroid(coast(DCW="US.CA", dump=true))
BoundingBox: [240.39195760563373, 240.39195760563373, 37.245067902690664, 37.245067902690664]
1×2 GMTdataset{Float64, 2}
 Row │   col.1    col.2
     │ Float64  Float64
─────┼──────────────────
   1 │ 240.392  37.2451
2 Likes