[postgis-users] Help with ST_CLIP

Stephen Woodbridge stephenwoodbridge37 at gmail.com
Fri Mar 12 14:46:41 PST 2021


On 3/12/2021 4:55 PM, Simon G Greener wrote:
> Stephen,
>
> A type 4326 not 4236.

Opps, yeah, I mis-read that.
So I don't work with rasters and will defer to others on any specifics.

I think I would try to make a simplistic test case with a little raster 
and a little polygon, that you can play with to figure out the write set 
of commands and data types that work.

The only reasons I can think of that you results are all null are:
1) the polygon does not intersect the raster, because of types, 
projections whatever
2) maybe a code bug
3) some obscure usage error that is not well documented

I know you know this stuff pretty well, so if you can not sort it out 
with a test case, at least you'll have that to submit with a bug report 
or have something that other experts can try out and maybe correct.

Best,
-Steve

>
> > select st_astext(geog::geometry) from gbr_marine_park_boundary;
>
> The numbers look correct after the cast.
>
> Even though the data is extensive should I consider transforming to a 
> projected SRID?
>
> Geographic rasters are not supported right? This is the reason for the 
> cast to call the ST_Clip function.
>
> regards
>
> Simon
>
> On 13/03/2021 5:42 am, Stephen Woodbridge wrote:
>> Hi Simon,
>>
>> A geography column in 4236 sounds strange. Check the coordinate 
>> values of the cast polygon.
>>
>> select st_astext(geog::geometry) from gbr_marine_park_boundary;
>>
>> and see if they look like what you expect.
>>
>> -Steve W
>>
>> On 3/12/2021 1:37 AM, Simon SPDBA Greener wrote:
>>> "POSTGIS=""2.4.3 r16312"" PGSQL=""100"" GEOS=""3.6.2-CAPI-1.10.2 
>>> 4d2925d6"" PROJ=""Rel. 4.9.3, 15 August 2016"" GDAL=""GDAL 2.2.3, 
>>> released 2017/11/20"" LIBXML=""2.9.4"" LIBJSON=""0.12.1"" 
>>> LIBPROTOBUF=""1.2.1"" RASTER"
>>>
>>> I have a polygon that defines the boundary of the Great Barrier Reef.
>>>
>>> A) That boundary is stored as a vector geography column (4326) in a 
>>> table.
>>> B) I have loaded a raster dataset of depths (4326) and checked its 
>>> statistics.
>>>     The data loaded correctly and I can see valid depth values.
>>>
>>> Now I want to clip the data in B with the polygon in A.
>>>
>>> (I can't use a raster function with a geography object so I cast it 
>>> to geometry.)
>>>
>>> create table gbr100x100clip
>>> as
>>> select ST_Clip(g.rast, 1, m.geog::geometry, false) as rast
>>>   from gbr_marine_park_boundary as m,
>>>        gbr100x100 as g;
>>>
>>> This works but the value (depth) of the whole (slipped) rasters is 
>>> NULL.
>>>
>>> I expected to see depth values but this returns null values.
>>>
>>> SELECT (stats).*
>>>   FROM (SELECT ST_SummaryStats(rast, 1) As stats FROM 
>>> gbr100x100clip) As foo
>>>  order by max desc;
>>>
>>> Can anyone give me an idea of what I am doing wrong?
>>>
>>> regards
>>> Simon
>>>
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>
>>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users


-- 
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



More information about the postgis-users mailing list