The Polygon datatype represents a shape on the Earth as a ring of WGS84 Latitude and Longitude pairs. The location is encoded as a GeoJSON “polygon”. Example:
{
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
}coordinates property, GeoJSON orders the coordinates as "longitude, latitude" (X coordinate, Y coordinate), as other GIS coordinate systems are encoded. Note that the SoQL within_box and within_circle functions use the more conventional ordering, however.
The following operators can be used on polygon fields:
| Operator | Description |
|---|---|
IS NULL |
TRUE for values that are NULL. |
IS NOT NULL |
TRUE for values that are not NULL. |
And the following functions can be used with them:
| Keyword Name | Description | Availability |
|---|---|---|
distinct |
Returns distinct set of records | 2.1 and 3.0 |
| Function Name | Description | Availability |
|---|---|---|
case(...) |
Returns different values based on the evaluation of boolean comparisons | 2.1 and 3.0 |
convex_hull(...) |
Returns the minimum convex geometry that encloses all of another geometry | 2.1 and 3.0 |
count(...) |
Returns a count of a given set of records | 2.0, 2.1, and 3.0 |
extent(...) |
Returns a bounding box that encloses a set of geometries | 2.1 and 3.0 |
intersects(...) |
Allows you to compare two geospatial types to see if they intersect or overlap each other | 2.1 and 3.0 |
num_points(...) |
Returns the number of vertices in a geospatial data record | 2.1 and 3.0 |
simplify(...) |
Reduces the number of vertices in a line or polygon | 2.1 and 3.0 |
simplify_preserve_topology(...) |
Reduces the number of vertices in a line or polygon, preserving topology | 2.1 and 3.0 |
within_box(...) |
Returns the rows that have geodata within the specified box, defined by latitude, longitude corners | 2.0, 2.1, and 3.0 |
within_circle(...) |
Returns the rows that have locations within a specified circle, measured in meters | 2.0, 2.1, and 3.0 |
within_polygon(...) |
Returns the rows that have locations within the specified box, defined by latitude, longitude corners | 2.1 and 3.0 |
Closely related to the Polygon datatype is the MultiPolygon
.