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, load precomputed data for fast loading with index into memory using s2.
idx, err := coord2country.OpenIndex()
if err != nil {
panic(err)
}
fmt.Printf("%v", idx.Query(48.8, 2.2))
Natural Earth Countries 10M is embedded in the library.
You can use your own data, use cmd/gendata
to create your data file.
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.
- geo-benthos a GIS plugin for Benthos, a stream processing tool, to enrich stream from coordinates.
- ovr the optional
-tags geo
build with thecountry
command returns the country of centroid.