ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - mmadfox/go-geojson2h3: Conversion utilities between H3 indexes and GeoJSON
Conversion utilities between H3 indexes and GeoJSON - mmadfox/go-geojson2h3
Visit Site

GitHub - mmadfox/go-geojson2h3: Conversion utilities between H3 indexes and GeoJSON

GitHub - mmadfox/go-geojson2h3: Conversion utilities between H3 indexes and GeoJSON

go-geojson2h3

Coverage Status Documentation Go Report Card

The geojson2h3 library includes a set of utilities for conversion between GeoJSON Objects:

  • Point, MultiPoint,
  • LineString, MultiLineString
  • Polygon,MultiPolygon
  • GeometryCollection
  • Feature,FeatureCollection
  • Circle

and H3 hexagon indexes, using: H3-GO and GeoJSON

Installation

$ go get github.com/mmadfox/go-geojson2h3

API

// ToH3 converts a GeoJSON objects to a list of hexagons with specified resolution.
ToH3(resolution int, o geojson.Object) (indexes []h3.H3Index, err error)

// ToFeatureCollection converts a set of hexagons to a GeoJSON `FeatureCollection`
// with the set outline(s). The feature's geometry type will be `Polygon`.
ToFeatureCollection(indexes []h3.H3Index) (*geojson.FeatureCollection, error)

Examples

package main

import (
	"fmt"

	"github.com/mmadfox/go-geojson2h3"
	"github.com/tidwall/geojson"
	"github.com/uber/h3-go/v3"
)

func main() {
	resolution := 9
	object, err := geojson.Parse(`{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"shape":"Polygon","name":"Unnamed Layer","category":"default"},"geometry":{"type":"Polygon","coordinates":[[[-73.901303,40.756892],[-73.893924,40.743755],[-73.871476,40.756278],[-73.863378,40.764175],[-73.871444,40.768467],[-73.879852,40.760014],[-73.885515,40.764045],[-73.891522,40.761054],[-73.901303,40.756892]]]},"id":"a6ca1b7e-9ddf-4425-ad07-8a895f7d6ccf"}]}`, nil)
	if err != nil {
		panic(err)
	}

	indexes, err := geojson2h3.ToH3(resolution, object)
	if err != nil {
		panic(err)
	}
	for _, index := range indexes {
		fmt.Printf("h3index: %s\n", h3.ToString(index))
	}

	featureCollection, err := geojson2h3.ToFeatureCollection(indexes)
	if err != nil {
		panic(err)
	}
	fmt.Println("Polyfill:")
	fmt.Println(featureCollection.JSON())
}

Contributing

Pull requests and Github issues are welcome. Please include tests for new work, and keep the library test coverage at 90-100%.

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory