[postgis-users] [EXTERNAL] Re: ST_Resample function question.
Bborie Park
dustymugs at gmail.com
Tue Jun 12 09:14:32 PDT 2018
I think the problem here is that the code treats a raster with no SRS
differently than a raster with SRS where reprojection will NOT take place
(essentially, same Cartesian plane for source raster and destination
raster).
The key offending(?) line is
https://github.com/postgis/postgis/blob/svn-trunk/raster/rt_core/rt_warp.c#L273
I'll see if removing that line breaks any existing behavior per unit tests.
If no issues, your use case should just-work. I'll probably be able to
back-patch this into prior releases (2.1+) as not much has happened in the
GDAL Warp wrapper for a few years.
-bborie
On Tue, Jun 12, 2018 at 7:47 AM Birkett, Scott <scott.birkett at pioneer.com>
wrote:
> The comment that an unset SRID forcing a transformation to happen makes
> sense.
>
> You stated that the following would fail because GDALCreateGenImgProjTransformer2
> would just return null, and null can’t be transformed into a raster.
>
>
>
> So the following fails, we have seen that.
>
> *SELECT *
>
> * ST_Resample(*
>
> * ST_SetSRID(*
>
>
> *'0100000200000000000000F03F000000000000F0BF00000000000000000000000000000000000000000000000000000000000000000000000002000200080000000000000000000000000000000000000000080000000001000000010000000100000001000000'::raster,*
>
> * 4326),*
>
> * 2, 2)*
>
>
>
> But the following still returns the same *error*, when a height and width
> change is requested.
>
> *SELECT *
>
> * ST_Resample(*
>
> * ST_SetSRID(*
>
>
> *'0100000200000000000000F03F000000000000F0BF00000000000000000000000000000000000000000000000000000000000000000000000002000200080000000000000000000000000000000000000000080000000001000000010000000100000001000000'::raster,*
>
> * 4326),*
>
> * 4, 4)*
>
>
>
> While this works
>
> *SELECT *
>
> * ST_Resample(*
>
>
> *'0100000200000000000000F03F000000000000F0BF00000000000000000000000000000000000000000000000000000000000000000000000002000200080000000000000000000000000000000000000000080000000001000000010000000100000001000000'::raster,*
>
> * 4, 4)*
>
>
>
> Should a resample that changes the height and width still create an error?
>
>
>
> Thanks for your help so far.
>
>
>
> *From: *postgis-users <postgis-users-bounces at lists.osgeo.org> on behalf
> of Regina Obe <lr at pcorp.us>
> *Reply-To: *PostGIS Users Discussion <postgis-users at lists.osgeo.org>
> *Date: *Monday, June 11, 2018 at 4:33 PM
> *To: *'PostGIS Users Discussion' <postgis-users at lists.osgeo.org>
> *Cc: *"Gruca, Justin" <justin.gruca at pioneer.com>, "Conrad, Gabe" <
> gabe.conrad at pioneer.com>
> *Subject: *[EXTERNAL] Re: [postgis-users] ST_Resample function question.
>
>
>
> That error happens when gdal GDALCreateGenImgProjTransformer2 returns a
> NULL transform which I'm guessing happens if that data is already at that
> sampling.
>
> I know other conditions for that are if GDAL can't load the proj library
> or GDAL_DATA path is not set.
>
>
>
> Your data already has a width of 2,2 so I assume that if its already at
> the desired sampling it may return NULL.
>
>
>
> For example:
>
> SELECT ST_Resample(ST_ASRaster(
>
> 'SRID=4326;POLYGON((0 0,2 0,2 -2,0 -2,0 0))'::geometry, 2,
> 2),2,2);
>
>
>
> Yields the error you describe:
>
> ERROR: rt_raster_gdal_warp: Could not create GDAL transformation object
> for output dataset creation
>
>
>
> But if my original dimensions were width / height 4/4 and I request 2/2,
> then this works
>
>
>
> SELECT ST_Resample(ST_ASRaster(
>
> 'SRID=4326;POLYGON((0 0,2 0,2 -2,0 -2,0 0))'::geometry, 4,
> 4),2,2);
>
>
>
> But that doesn't explain why this doesn't work:
>
>
>
> SELECT ST_Resample(ST_ASRaster(
>
> 'SRID=4326;POLYGON((0 0,2 0,2 -2,0 -2,0 0))'::geometry, 4,
> 4),2,2);
>
>
>
>
>
> As far as why it works when you have no SRID, the raster code uses a
> hard-coded geotransform matrix when it's an unknown raster so it always
> gets a geotransform back it can use to apply.
>
>
>
> Hope that helps,
>
> Regina
>
>
>
>
>
>
>
> *From:* postgis-users [mailto:postgis-users-bounces at lists.osgeo.org] *On
> Behalf Of *Birkett, Scott
> *Sent:* Monday, June 11, 2018 4:27 PM
> *To:* postgis-users at lists.osgeo.org
> *Cc:* Gruca, Justin <justin.gruca at pioneer.com>; Conrad, Gabe <
> gabe.conrad at pioneer.com>
> *Subject:* [postgis-users] ST_Resample function question.
>
>
>
> "PostgreSQL 9.5.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.3
> 20140911 (Red Hat 4.8.3-9), 64-bit POSTGIS="2.2.5 r15298"
> GEOS="3.5.1-CAPI-1.9.1 r4246" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL
> 2.0.3, released 2016/07/01" LIBXML="2.9.1" LIBJSON="0 (...)"
>
>
>
> The raster created by …
>
> SELECT
> '0100000200000000000000F03F000000000000F0BF00000000000000000000000000000000000000000000000000000000000000000000000002000200080000000000000000000000000000000000000000080000000001000000010000000100000001000000'::raster,
> is a two band raster with zeros in the first band and ones in the second
> band.
>
>
>
> The following Resample works.
>
> //////////////////////////////////////////
>
>
>
> *SELECT
> ST_Resample('0100000200000000000000F03F000000000000F0BF00000000000000000000000000000000000000000000000000000000000000000000000002000200080000000000000000000000000000000000000000080000000001000000010000000100000001000000'::raster,
> 2, 2)*
>
>
>
> //////////////////////////////////////////////
>
>
>
> The following ST_SetSRID works
>
>
>
> //////////////////////////////////////////////
>
>
>
> *SELECT
> ST_SetSRID('0100000200000000000000F03F000000000000F0BF00000000000000000000000000000000000000000000000000000000000000000000000002000200080000000000000000000000000000000000000000080000000001000000010000000100000001000000'::raster::geometry
> ,4326);*
>
>
>
> //////////////////////////////////////////////
>
>
>
> The following Resample does not work.
>
> //////////////////////////////////////////
>
>
>
> *SELECT
> ST_Resample(ST_SetSRID('0100000200000000000000F03F000000000000F0BF00000000000000000000000000000000000000000000000000000000000000000000000002000200080000000000000000000000000000000000000000080000000001000000010000000100000001000000'::raster,
> 4326), 2, 2)*
>
>
>
> //////////////////////////////////////////////
>
> Error Follows
>
>
>
> ERROR: rt_raster_gdal_warp: Could not create GDAL transformation object
> for output dataset creation
>
>
>
> ********** Error **********
>
>
>
> ERROR: rt_raster_gdal_warp: Could not create GDAL transformation object
> for output dataset creation
>
> SQL state: XX000
>
>
>
> Raster in the first band follows…
>
> SELECT ST_AsText(geom), * FROM
> ST_PixelAsCentroids(ST_SetSRID('0100000200000000000000F03F000000000000F0BF00000000000000000000000000000000000000000000000000000000000000000000000002000200080000000000000000000000000000000000000000080000000001000000010000000100000001000000'::raster,
> 4326), 1);
>
>
>
> "POINT(0.5
> -0.5)";"0101000020E6100000000000000000E03F000000000000E0BF";0;1;1
>
> "POINT(1.5
> -0.5)";"0101000020E6100000000000000000F83F000000000000E0BF";0;2;1
>
> "POINT(0.5
> -1.5)";"0101000020E6100000000000000000E03F000000000000F8BF";0;1;2
>
> "POINT(1.5
> -1.5)";"0101000020E6100000000000000000F83F000000000000F8BF";0;2;2
>
>
>
>
>
> Is there something with the ST_Resample function that I am missing? I
> don’t understand why setting the SRID to 4326 breaks ST_Resample in this
> instance. ST_SetSRID for the above raster works fine, the raster is
> returned and the coordinates are valid for 4326.
>
>
>
> Any help is appreciated.
>
>
>
>
>
>
>
> This communication is for use by the intended recipient and contains
> information that may be Privileged, confidential or copyrighted under
> applicable law. If you are not the intended recipient, you are hereby
> formally notified that any use, copying or distribution of this e-mail,in
> whole or in part, is strictly prohibited. Please notify the sender by
> return e-mail and delete this e-mail from your system. Unless explicitly
> and conspicuously designated as "E-Contract Intended", this e-mail does not
> constitute a contract offer, a contract amendment, or an acceptance of a
> contract offer. This e-mail does not constitute a consent to the use of
> sender's contact information for direct marketing purposes or for transfers
> of data to third parties. Francais Deutsch Italiano Espanol Portugues
> Japanese Chinese Korean http://www.DuPont.com/corp/email_disclaimer.html
>
>
> This communication is for use by the intended recipient and contains
> information that may be Privileged, confidential or copyrighted under
> applicable law. If you are not the intended recipient, you are hereby
> formally notified that any use, copying or distribution of this e-mail,in
> whole or in part, is strictly prohibited. Please notify the sender by
> return e-mail and delete this e-mail from your system. Unless explicitly
> and conspicuously designated as "E-Contract Intended", this e-mail does not
> constitute a contract offer, a contract amendment, or an acceptance of a
> contract offer. This e-mail does not constitute a consent to the use of
> sender's contact information for direct marketing purposes or for transfers
> of data to third parties. Francais Deutsch Italiano Espanol Portugues
> Japanese Chinese Korean http://www.DuPont.com/corp/email_disclaimer.html
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20180612/ca8b569d/attachment.html>
More information about the postgis-users
mailing list