SQLite Forum

Country-coding from Lat/Long, using GeoPoly and/or R-Tree
Login
The "Geopoly" extension mentioned in the link of the original post
supports non-rectangular regions.  Each entry in Geopoly is a polygon.
The extension supports primitives to:

  *  Determine if polygons intersect
  *  Determine if one polygon is entirely contained inside another
  *  Determine if a point is inside or outside a polygon
  *  Find the area of a polygon
  *  Perform linear transformations (flipping, stretching, rotating)
     on polygons.
  *  Render polygons as SVG.

The inputs are GeoJSON descriptions of polygons.  You can search online to
find lots of maps in the GeoJSON format, which can be directly imported
into a Geopoly index.

An SQL script that demonstrates Geopoly's capabilities is in the source
tree in the [ext/rtree/visual01.txt][1] file.  Run this file as follows:

~~~~
     sqlite3 <visual01.txt >geopoly-demo.html
     open geopoly-demo.html
~~~~

For your viewing convenience, I have uploaded the output to
<https://sqlite.org/tmp/geopoly-demo.html>.

[1]: https://sqlite.org/src/file/ext/rtree/visual01.txt