The ST_AsGeoJSON function with the following query:
SELECT ST_AsGeoJSON(t.*) FROM vw_ph t (ph, capture_datetime) LIMIT 1;
Returns the following:
{
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[
-88.987035,
30.161476
]
},
"properties":{
"id":1,
"capture_datetime":"2020-08-26T19:51:05.575-05:00",
"ph":16,
"boat_datetime":"2020-08-26T19:51:05.538-05:00",
"latitude":30.161476,
"longitude":-88.987035,
"an_point_geom":{
"type":"Point",
"coordinates":[
-88.987035,
30.161476
]
}
}
}
I am trying to get a geojson output without having the geometry column an_point_geom
repeated in the properties
field as below as it will add unnecessary size in a large query and polygon geometry.
The closest I have been to this is with the query below.
SELECT ST_AsGeoJSON((t.ph , t.capture_datetime, t.an_point_geom, t.boat_datetime)) FROM vw_ph t LIMIT 1;
However, this returns the result without the geometry column in properties but the columns are named f1, f2...
which is not desirable.
{
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[
-88.987035,
30.161476
]
},
"properties":{
"f1":16,
"f2":"2020-08-26T19:51:05.575-05:00",
"f4":"2020-08-26T19:51:05.538-05:00"
}
}
Is there any way to exclude the geometry column from properties without another query?
I am using PostGIS 3.0.2 in PostgreSQL 9.6.