You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/integrations/postgis.rst
+27-12Lines changed: 27 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
PostGIS
4
4
=======
5
5
6
-
You can use the string representation for `PostGIS <https://postgis.net/>`_ data types such as ``geometry`` or ``geography`` (you need to `install PostGIS <https://postgis.net/documentation/getting_started/>`_ first).
6
+
To work with `PostGIS <https://postgis.net/>`_ data types such as ``geometry`` or ``geography``, you'll need to `install PostGIS <https://postgis.net/documentation/getting_started/>`_ first.
7
7
8
8
.. code-block:: postgres
9
9
@@ -16,20 +16,16 @@ You can use the string representation for `PostGIS <https://postgis.net/>`_ data
16
16
area geometry
17
17
);
18
18
19
-
To add areas in polygon format, you can use string representation:
Now, when you request the information, PostgREST will automatically cast the ``area`` column into a ``Polygon`` geometry type. Although this is useful, you may need the whole output to be in `GeoJSON <https://geojson.org/>`_ format out of the box, which can be done by including the ``Accept: application/geo+json``in the request. This will work for PostGIS versions 3.0.0 and up and will return the output as a `FeatureCollection Object <https://www.rfc-editor.org/rfc/rfc7946#section-3.3>`_:
28
+
When you request the information, PostgREST will automatically cast the ``area`` column into a ``Polygon`` geometry type. Although this is useful, you may need the whole output to be in `GeoJSON <https://geojson.org/>`_ format out of the box, which can be done using the `standard <https://www.iana.org/assignments/media-types/application/geo+json>`_ ``application/geo+json`` media type. This will work for PostGIS versions 3.0.0 and up and will return the output as a `FeatureCollection Object <https://www.rfc-editor.org/rfc/rfc7946#section-3.3>`_:
33
29
34
30
.. code-block:: bash
35
31
@@ -70,6 +66,9 @@ Now, when you request the information, PostgREST will automatically cast the ``a
70
66
]
71
67
}
72
68
69
+
Using generated columns
70
+
-----------------------
71
+
73
72
If you need to add an extra property, like the area in square units by using ``st_area(area)``, you could add a generated column to the table and it will appear in the ``properties`` key of each ``Feature``.
74
73
75
74
.. code-block:: postgres
@@ -135,3 +134,19 @@ Now this query will return the same results:
135
134
}
136
135
]
137
136
}
137
+
138
+
Using string representation
139
+
---------------------------
140
+
141
+
To insert areas in polygon format, you can use string representation:
0 commit comments