Sunday, 23 July 2017

Convert a raster to GeoJSON polygons in PostGIS


I'm trying to convert a raster to a polygon and export it from PostGIS as GeoJSON. Specifically I want each pixel to be a polygon with associated the raster value.


PostGIS seems to have a few different functions for converting rasters to polygons, I'm using the ST_PixelAsPolygons function because I want each pixel to be represented as its own polygon.


Example:


SELECT ST_PixelAsPolygon(rast) FROM tbl;

However this returns a set of records for each raster and I can't easily convert this to GeoJSON.


Does anyone know of a simple way to do this?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...