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

**URL:** <https://discourse.julialang.org/t/how-do-i-get-the-bounds-or-center-of-a-named-region-in-gmt-jl/101506>\
**Category:** Geo\
**Tags:** gmt\
**Created:** [July 12, 2023, 2:52am UTC](https://discourse.julialang.org/t/how-do-i-get-the-bounds-or-center-of-a-named-region-in-gmt-jl/101506 "2023-07-12T02:52:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philip\_Stuckey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/philip_stuckey/32/4000_2.png) [@Philip\_Stuckey](https://discourse.julialang.org/u/Philip_Stuckey)\
**Post date:** [July 12, 2023, 2:52am UTC](https://discourse.julialang.org/t/how-do-i-get-the-bounds-or-center-of-a-named-region-in-gmt-jl/101506/1 "2023-07-12T02:52:49Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [July 12, 2023, 9:58am UTC](https://discourse.julialang.org/t/how-do-i-get-the-bounds-or-center-of-a-named-region-in-gmt-jl/101506/2 "2023-07-12T09:58:58Z")

</div>

Hi,  
Use the `getregion` option

```julia
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

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

---

<div class="post-metadata">

**Author:** ![Philip\_Stuckey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/philip_stuckey/32/4000_2.png) [@Philip\_Stuckey](https://discourse.julialang.org/u/Philip_Stuckey)\
**Post date:** [July 13, 2023, 12:28am UTC](https://discourse.julialang.org/t/how-do-i-get-the-bounds-or-center-of-a-named-region-in-gmt-jl/101506/3 "2023-07-13T00:28:41Z")

</div>

> [@joa-quim](#):
>
> `GMT.opt_R2num`

That seems to work, thanks

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [July 13, 2023, 1:06am UTC](https://discourse.julialang.org/t/how-do-i-get-the-bounds-or-center-of-a-named-region-in-gmt-jl/101506/4 "2023-07-13T01:06:16Z")

</div>

Note that you can also compute the centroid with

```julia
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

```
