songololo commented on issue #11625:
URL: 
https://github.com/apache/incubator-superset/issues/11625#issuecomment-725305364


   I managed to make some headway, posting here for others:
   
   The JSON strings returned from `postGIS` using the `ST_AsGeoJSON` function 
contain only the geometry component of the geoJSON spec. This means that it is 
necessary to wrap these geometries in a full-fledged geoJSON object before 
`deck.gl` can recognise it.
   
   For example:
   ```postgresql
   SELECT *, json_build_object(
     'type',       'Polygon',
     'geometry',   ST_AsGeoJSON(ST_Transform(geom, 4326))::json)::text as 
geoJSON
   FROM <my-schema>.<my-table>;
   ```
   
   If you are working with MultiPolygons then you need to extract a Polygon 
first:
   ```postgresql
   SELECT *, json_build_object(
     'type',       'Polygon',
     'geometry',   
ST_AsGeoJSON(ST_Transform((ST_DUMP(geom)).geom::geometry(Polygon, 27700), 
4326))::json)::text as geoJSON
   FROM <my-schema>.<my-table>;
   ```
   
   Note that in both cases, the geoJSON result has to be cast to a text type 
otherwise superset will have issues when it runs internal queries, which are 
otherwise unable to sort the results (duplicate checking?) if using JSON.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to