NAME
Geo::H3::Index - H3 Geospatial Hexagon Indexing System Index Object
SYNOPSIS
use Geo::H3::Index;
my $h3 = Geo::H3::Index->new(string => $string); #isa Geo::H3::Index
my $center = $h3->geo; #isa Geo::H3::Geo
my $lat = $center->lat; #isa double WGS-84 Decimal Degrees
my $lon = $center->lon; #isa double WGS-84 Decimal Degrees
my $boundary = $h3->geoBoundary; #isa Geo::H3::GeoBoundary
DESCRIPTION
H3 Geospatial Hexagon Indexing System Index Object provides the primary interface for working with H3 Indexes.
CONSTRUCTORS
new
my $h3 = Geo::H3::Index->new(string=>$string);
my $h3 = Geo::H3::Index->new(uint64=>$uint64);
PROPERTIES
string
Returns the H3 string representation.
uint64
Returns the H3 uint64 representation.
index (DEPRECATED)
Returns the H3 uint64 representation.
Please note that `index()` was difficult to remember consistently. Therefore, I plan to move to the `uint64()` property moving forward while maintaining backwards compatibility.
resolution
Returns the resolution of the hex.
baseCell
Returns the base cell number of the hex.
isValid
Returns non-zero if this is a valid H3 hex.
isResClassIII
Returns non-zero if this hex has a resolution with Class III orientation.
isPentagon
Returns non-zero if this hex represents a pentagonal cell.
maxFaceCount
Returns the maximum number of icosahedron faces the given H3 hex may intersect.
area
Returns the area in square meters of this hex.
areaApprox
Returns the average area in square meters of hexes at this resolution.
edgeLength
Returns the exact edge length in meters that this hex shares with the passed in neighbor.
my $edgeLength_meters = $hex->edgeLength(); #default hex is first kring neighbor
my $edgeLength_meters = $hex->edgeLength($neighbor_hex_obj);
edgeLengthAverage
Returns the average of the exact edge lengths in meters of this hex.
edgeLengthApprox
Returns the average edge length in meters of hexes at this resolution.
METHODS
geo
Returns the centroid of the hex as a Geo::H3::Geo object.
geoBoundary
Returns the boundary of the hex as a Geo::H3::GeoBoundary object
parent
Returns a parent hex of this hex as a Geo::H3::Index object.
my $parent = $h3->parent; #next larger resolution
my $parent = $h3->parent(1); #isa Geo::H3::Index
children
Returns the children of the hex as an array reference of Geo::H3::Index objects.
my $children = $h3->children(12); #isa ARRAY
my $children = $h3->children; #next smaller resolution
centerChild
Returns the center child (finer) hex contained by this hex at given resolution.
my $centerChild = $hex->centerChild; #isa Geo::H3::Index
my $centerChild = $hex->centerChild(12); #isa Geo::H3::Index
kRing
Returns k-rings hexes within k distance of the origin hex.
my $hexes_aref = $hex->kRing($k); #isa ARRAY of L<Geo::H3::Index> objects
kRingDistances
Returns a hash reference where the keys are the H3 hex and values are the k distance for the given hex and k value.
my $distances_aref = $hex->kRingDistances($k); #isa ARRAY-ARRAY [ [$hex1, $dist1], [$hex2, $dist2], ... [$hexN, $distN] ]
hexRange
Returns an array reference of hexes within k distance of the hex object. k-ring 0 is defined as the origin index, k-ring 1 is defined as k-ring 0 and all neighboring indexes, and so on.
my $hexes_aref = $hex->hexRange($k);
hexRangeDistances
Returns a hash reference where the keys are the H3 uint64 and values are the k distance for the given hex and k value.
my $hash = $hex->hexRangeDistances($k); #isa ARRAY-ARRAY [ [$hex1, $dist1], [$hex2, $dist2], ... [$hexN, $distN] ]
hexRing
Returns the hex ring of this hex as an array reference of Geo::H3::Index objects
my $hexes = $h3->hexRing; #default k = 1
my $hexes = $h3->hexRing(5); #isa ARRAY
areNeighbors
Returns a 1 or 0 based on whether or not the provided hex object is a neighbor.
my $areNeighbors = $start_hex->areNeighbors($end_hex);
line
Returns the hexes starting at this hex to the given end hex as array reference of Geo::H3::Index objects.
my $list_aref = $start_hex_obj->line($end_hex_obj);
distance
Returns the distance in grid cells between this hex to the given end hex.
my $distance = $start_hex_obj->distance($end_hex_obj);
SEE ALSO
AUTHOR
Michael R. Davis
COPYRIGHT AND LICENSE
MIT License
Copyright (c) 2021 Michael R. Davis