@@ -26,17 +26,72 @@ WHERE ST_Within(location, ST_GeomFromGeoJSON('{
2626
2727## OGC Predicates
2828
29- | Function | Description |
30- | ----------------- | ----------------------------------- |
31- | `ST_Contains` | Geometry A contains geometry B |
32- | `ST_Intersects` | Geometries share any space |
33- | `ST_Within` | Geometry A is within geometry B |
34- | `ST_DWithin` | Within a given distance |
35- | `ST_Distance` | Distance between two geometries |
36- | `ST_Intersection` | Intersection geometry |
37- | `ST_Buffer` | Buffer around geometry |
38- | `ST_Envelope` | Bounding box |
39- | `ST_Union` | Union of geometries |
29+ | Function | Description |
30+ | ----------------- | ---------------------------------------------------- |
31+ | `ST_Contains` | Geometry A contains geometry B |
32+ | `ST_Within` | Geometry A is within geometry B |
33+ | `ST_Intersects` | Geometries share any space |
34+ | `ST_Disjoint` | Geometries share no space |
35+ | `ST_DWithin` | Within a given geodesic distance in meters |
36+ | `ST_IsValid` | Whether a geometry is well-formed |
37+
38+ ## Constructors
39+
40+ | Function | Result |
41+ | --------------------------------------------------- | ------------------------------------------------------------- |
42+ | `ST_Point(lng, lat)` | Point |
43+ | `ST_MakePoint(x, y [, z])` | Point |
44+ | `ST_GeomFromText(wkt [, srid])` | Geometry from WKT |
45+ | `ST_GeomFromGeoJSON(json)` | Geometry from GeoJSON |
46+ | `ST_GeomFromWKB(bytes [, srid])` | Geometry from WKB; accepts `X'...'` or its hex string |
47+ | `ST_MakeLine(point, point, ...)` | LineString |
48+ | `ST_MakePolygon(ring, ...)` | Polygon from arrays of `[lng, lat]` pairs |
49+ | `ST_MakeEnvelope(min_lng, min_lat, max_lng, max_lat)` | Rectangular Polygon |
50+
51+ ## Accessors and Measures
52+
53+ Measures are geodesic — meters, and square meters for area.
54+
55+ | Function | Result |
56+ | ----------------------- | ------------------------------------------------------------------- |
57+ | `ST_AsText(geom)` | WKT rendering |
58+ | `ST_AsGeoJSON(geom)` | GeoJSON rendering |
59+ | `ST_X(geom)` / `ST_Y(geom)` | Ordinate of a Point; NULL for any other geometry |
60+ | `ST_GeometryType(geom)` | Type name, e.g. `Point` |
61+ | `ST_NPoints(geom)` | Total vertex count |
62+ | `ST_SRID(geom)` | Always `4326` — geometry is stored as GeoJSON, i.e. WGS 84 |
63+ | `ST_Distance(a, b)` | Distance between two geometries |
64+ | `ST_Length(geom)` | Length of linear components |
65+ | `ST_Perimeter(geom)` | Boundary length of areal components |
66+ | `ST_Area(geom)` | Area of areal components, less holes |
67+
68+ ## Geometry Operations
69+
70+ | Function | Result |
71+ | ------------------------------------ | --------------------------------------------- |
72+ | `ST_Buffer(geom, meters [, segments])` | Geometry grown by a distance |
73+ | `ST_Envelope(geom)` | Bounding box |
74+ | `ST_Centroid(geom)` | Centroid, weighted by highest dimension |
75+ | `ST_Union(a, b)` | Union of geometries |
76+ | `ST_Intersection(a, b)` | Intersection geometry |
77+
78+ ## Reading Stored Geometry
79+
80+ Every function above works in every position a geometry expression may appear —
81+ an `INSERT` value, a `SELECT` projection, and a predicate's query-geometry
82+ argument. Constructors nest, so a buffered point is a valid search area, and a
83+ bare string literal is read as WKT or GeoJSON.
84+
85+ ```sql
86+ SELECT name, ST_AsText(location), ST_X(location), ST_Y(location)
87+ FROM restaurants;
88+
89+ SELECT name FROM restaurants
90+ WHERE ST_Within(location, ST_Buffer(ST_Point(-73.990, 40.750), 1000));
91+
92+ SELECT name FROM restaurants
93+ WHERE ST_DWithin(location, 'POINT(-73.990 40.750)', 1000);
94+ ```
4095
4196## Spatial Join
4297
@@ -48,7 +103,7 @@ WHERE ST_Contains(z.boundary, r.location);
48103## H3 Hexagonal Indexing
49104
50105```sql
51- SELECT h3_to_string(h3_encode( 40.748, -73.985, 9) ) AS hex;
106+ SELECT h3_latlngtocell( 40.748, -73.985, 9) AS hex;
52107```
53108
54109## Hybrid Spatial-Vector
0 commit comments