2

I have two SRTM rasters https://dds.cr.usgs.gov/srtm/version2_1/SRTM1/Region_06/ (N40W074 and N40W075) with Datum "WGS_1984"

I've united them to be able to work with one raster:

CREATE TABLE rasters.srtm AS
SELECT ST_Union(rast, 1) as rast
FROM (SELECT rast FROM rasters.srtm1
    UNION ALL
    SELECT rast FROM rasters.srtm2) foo

And then used this function to create a slope for New York (this shapefile: https://data.cityofnewyork.us/City-Government/Borough-Boundaries/tqmj-j8zm)

WITH r AS ( -- union of filtered tiles
     SELECT
             ST_Transform(ST_Union(srtm.rast), 26918) AS rast
     FROM rasters.srtm as srtm
     JOIN borough_boundaries ny
             ON ST_DWithin(ST_Transform(srtm.rast::geometry, 26918), ST_Transform(ny.geom, 26918), 1000)
   ), cx AS ( -- custom extent
           SELECT
                   ST_AsRaster(ST_Transform(ny.geom, 26918), r.rast) AS rast
           FROM borough_boundaries ny
           CROSS JOIN r
   )
   SELECT
           ST_Clip(ST_Slope(r.rast, 1, cx.rast), ST_Transform(ny.geom, 26918)) AS rast
   FROM r
   CROSS JOIN cx
   CROSS JOIN borough_boundaries ny;

The query runs for a few minutes and produces some raster tiles, but when I try to visualize in QGIS I get the error that the raster contains different SRIDs and therefore it cannot load it. Is there a mistake in the query or a way to output raster tiles with the same SRID?

I'm using PostgreSQL 11 with PostGIS 2.5

1
  • Is you second query supposed to be a create table query? It looks OK, but could you please post the complete query. Jan 19, 2020 at 11:21

1 Answer 1

2

The problem was that the shapefile for New York was split in different geometries, I use ST_Union to convert them into one and the query run with an output of the same SRID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.