Ticket #1648 (reopened defect)

Opened 15 months ago

Last modified 11 months ago

[raster] ST_AsRaster unexpected result

Reported by: jomarlla Owned by: dustymugs
Priority: medium Milestone: PostGIS GDAL
Component: raster Version: trunk
Keywords: Cc:

Description

Hi,

create table rast2 as

select ((pol).geom)::geometry (polygon, 0) as geom,

(pol).val::integer as value

from (select st_pixelaspolygons (rast) as pol from

(select st_asraster ('POLYGON ((11 11, 21 11, 26 21, 16 21, 11 11))'::geometry,

1.5::double precision, 2::double precision, 11, 11, '8BUI', 100, -1, 0, 0, true

) as rast

) as tabla) as tabla1;

Im getting a cell which is not burned.

Attachments

Imagen11.png Download (3.0 KB) - added by jomarlla 15 months ago.
A pixel is not burned
gdal-r24047.png Download (38.3 KB) - added by dustymugs 15 months ago.

Change History

Changed 15 months ago by jomarlla

A pixel is not burned

Changed 15 months ago by jomarlla

  • owner changed from pramsey to pracine
  • component changed from postgis to raster

The attached file shows the example.

Changed 15 months ago by pracine

  • summary changed from ST_AsRaster unexpected result to [raster] ST_AsRaster unexpected result

Changed 15 months ago by dustymugs

What version of GDAL are you using? Testing your example on GDAL trunk (r24047) works fine. If you're using a version prior to 1.9, please try 1.9.

I've attached an image of what I'm getting.

Changed 15 months ago by dustymugs

Changed 15 months ago by jomarlla

Im using GDAL 1.9 release packaged from grass project repository  http://download.opensuse.org/repositories/Application:/Geo/openSUSE_12.1/i586/

POSTGIS="2.0.0beta2SVN" GEOS="3.3.2-CAPI-1.7.2" PROJ="Rel. 4.7.1, 23 September 2009" GDAL="GDAL 1.9.0, released 2011/12/29" LIBXML="2.7.8"

Didnt try GDAL trunk. If the trunk version is already working maybe this ticket should be closed. Right now I can not build GDAL trunk to check it out by myself.

An easier way to check it:

select st_count(st_asraster ('POLYGON ((11 11, 21 11, 26 21, 16 21, 11 11))'::geometry, 1.5::double precision, 2::double precision, 11, 11, '8BUI', 100, -1, 0, 0, true));

st_count


40

You are getting 42 while Im getting 40.

Maybe some more people can try it with other gdal versions?

regards,

Changed 15 months ago by dustymugs

Part of the problem here is there is nothing the PostGIS Raster devs (me included) can do to remedy the result you're getting as the PostGIS function is passing the geometry to GDAL to do the actual burning. If you can, you may want to see what you get using the geometry through the gdal_rasterize utility.

Changed 15 months ago by pracine

I get 40.

SELECT PostGIS_Full_Version ();

"POSTGIS="2.0.0alpha7SVN" GEOS="3.3.2-CAPI-1.7.2" PROJ="Rel. 4.6.1, 21 August 2008" GDAL="GDAL 1.9.0, released 2011/12/29" LIBXML="2.7.8" USE_STATS (core procs from "2.0.0alpha7SVN" need upgrade) (raster procs from "2.0.0alpha7SVN" need upgrade)"

Changed 15 months ago by dustymugs

  • milestone changed from PostGIS 2.0.0 to PostGIS 2.0.1

Using gdal trunk r24093, I get 42. I'm going to change the milestone for the future as though this ticket is worth watching, there isn't anything that the PostGIS devs can do about a GDAL behavior.

Changed 15 months ago by dustymugs

Just tested GDAL 1.9.0 on Linux 64-bit and I get 42. On Linux 32-bit w/ GDAL 1.9.0, I get 40. On Linux 32-bit w/ GDAL trunk r24093, I get 40 again.

Strange that the behavior differs depending on the architecture.

Changed 11 months ago by dustymugs

I'll test a different method using the gdal_rasterize utility on 32 vs 64 bit.

Changed 11 months ago by dustymugs

  • owner changed from pracine to dustymugs
  • status changed from new to assigned

Changed 11 months ago by dustymugs

  • status changed from assigned to closed
  • resolution set to wontfix

After doing some additional digging, the difference in burned pixels boiled down to the use of the "touched" parameter.

Having "touched" be true causes the difference of burned pixels (42 vs 40 on 64 vs 32-bit)...

SELECT
	ST_Count(
		ST_AsRaster(
			'POLYGON ((11 11, 21 11, 26 21, 16 21, 11 11))'::geometry,
			1.5::double precision, 2::double precision,
			11, 11,
			'8BUI',
			100, 0,
			0, 0,
			true
		)
	);

With "touched" being false, 32 and 64-bit Linux return the same number of burned pixels: 34.

SELECT
	ST_Count(
		ST_AsRaster(
			'POLYGON ((11 11, 21 11, 26 21, 16 21, 11 11))'::geometry,
			1.5::double precision, 2::double precision,
			11, 11,
			'8BUI',
			100, 0,
			0, 0,
			false
		)
	);

Since everything is the same except the "touched" parameter, which only sets the ALL_TOUCHED option flag when calling GDALRasterizeGeometries(), there is a behavior difference in GDAL's algorithm.

I'm closing this ticket as there is nothing that can be done on the PostGIS side. Might be worth submitting a new ticket to GDAL though highlighting the difference in behavior for ALL_TOUCHED in 32 vs 64-bit environments.

Changed 11 months ago by pracine

Why not keeping it open as a link to a GDAL ticket and until a solution is found to this ticket. Otherwise it will fall into the limbo.

Changed 11 months ago by dustymugs

I don't like keeping tickets open that we can't do anything about. The ticket would just be found in the closed tickets report so should exist forever.

If we want to keep these "GDAL" tickets open, I'd like a milestone similar to the "PostGIS GEOS" item for "PostGIS GDAL" so that it can be more appropriately categorized. But I thought there was discussion about keeping the milestone options limited to prevent clutter.

Changed 11 months ago by pracine

Who said we can't do anything about it? We can first fill a ticket in GDAL. We can even fix it ourself or put some pressure somewhere. If we close it without doing anything, it will just pop another time in the future. I don't like to close unfixed tickets. There are also plenty of tickets that stay here for years. The important is to have a way to "trac" them. Closed tickets are generally forgotten forever.

Changed 11 months ago by strk

  • status changed from closed to reopened
  • resolution wontfix deleted
  • milestone changed from PostGIS 2.0.1 to PostGIS GDAL

There, "PostGIS GDAL" milestone. Now it takes a ticket to  http://trac.osgeo.org/gdal dustymugs: will you do that and link back here ?

Changed 11 months ago by dustymugs

GDAL ticket is  4704

Note: See TracTickets for help on using tickets.