Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akhenakh/coord2country
A simple solution to query for point in polygon in countries
https://github.com/akhenakh/coord2country
Last synced: 24 days ago
JSON representation
A simple solution to query for point in polygon in countries
- Host: GitHub
- URL: https://github.com/akhenakh/coord2country
- Owner: akhenakh
- License: mit
- Created: 2023-09-19T23:35:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-07T17:51:17.000Z (10 months ago)
- Last Synced: 2024-01-07T18:49:02.106Z (10 months ago)
- Language: Go
- Size: 15.8 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# coord2country
A simple solution to query for point in polygon, very fast, mainly for countries polygons but could serve any enclosed regions.
Embedding data from [Natural Earth](https://www.naturalearthdata.com/downloads/10m-cultural-vectors/), load precomputed data for fast loading with index into memory using [s2](https://s2geometry.io/).
## Usage
```go
idx, err := coord2country.OpenIndex()
if err != nil {
panic(err)
}fmt.Printf("%v", idx.Query(48.8, 2.2))
```## Data
Natural Earth Countries 10M is embedded in the library.
You can use your own data, use `cmd/gendata` to create your data file.
## Speed
Around 320 ns per query, when contained in a Polygon, around 190 ns in a dead zone.
RSS Memory is around 230MB for the 10M world countries.
## Projects Using coord2country
- [geo-benthos](https://github.com/akhenakh/geo-benthos) a GIS plugin for [Benthos](https://www.benthos.dev/), a stream processing tool, to enrich stream from coordinates.
- [ovr](https://github.com/akhenakh/ovr) the optional `-tags geo` build with the `country` command returns the country of centroid.