Method: H3::Indexing#to_boundary

Defined in:
lib/h3/indexing.rb

#to_boundary(h3_index) ⇒ Array<Array<Integer>>

Derive the geographical boundary as coordinates for a given H3 index.

This will be a set of 6 coordinate pairs matching the vertexes of the hexagon represented by the given H3 index.

If the H3 index is a pentagon, there will be only 5 coordinate pairs returned.

Examples:

Derive the geographical boundary for the given H3 index.

H3.to_boundary(617439284584775679)
[
  [52.247260929171055, -1.736809158397472], [52.24625850761068, -1.7389279144996015],
  [52.244516619273476, -1.7384324668792375], [52.243777169245725, -1.7358184256304658],
  [52.24477956752282, -1.7336997597088104], [52.246521439109415, -1.7341950448552204]
]

Parameters:

  • h3_index (Integer)

    A valid H3 index.

Returns:

  • (Array<Array<Integer>>)

    An array of six coordinate pairs.



73
74
75
76
77
78
79
# File 'lib/h3/indexing.rb', line 73

def to_boundary(h3_index)
  geo_boundary = GeoBoundary.new
  Bindings::Private.h3_to_geo_boundary(h3_index, geo_boundary)
  geo_boundary[:verts].take(geo_boundary[:num_verts]).map do |d|
    [rads_to_degs(d[:lat]), rads_to_degs(d[:lon])]
  end
end