Ticket #650 (closed defect: fixed)

Opened 16 months ago

Last modified 6 months ago

[raster] st_dumpaspolygon create int values

Reported by: etiennebr Owned by: jorgearevalo
Priority: blocker Milestone: PostGIS 2.0.0
Component: raster Version: trunk
Keywords: Cc:

Description

SELECT ST_AsBinary((ST_DumpAsPolygons(rast)).geom),

(ST_DumpAsPolygons(rast)).val

FROM smallr

Returns grouped values at the integer value. Is it possible to specify to return three digits values ?

Using let'say SELECT ST_Value(rast,10,15) FROM smallr

Returns 32B floats values

Attachments

smallr.sql Download (6.3 KB) - added by etiennebr 16 months ago.
small 32B rasters from an .asc file (three digits)

Change History

Changed 16 months ago by etiennebr

small 32B rasters from an .asc file (three digits)

Changed 16 months ago by pracine

  • summary changed from st_dumpaspolygon create int values to [raster] st_dumpaspolygon create int values

Changed 16 months ago by pracine

  • version changed from 1.5.X to trunk
  • milestone changed from PostGIS 1.5.3 to PostGIS 2.0.0

Changed 16 months ago by pracine

  • priority changed from medium to critical

Changed 14 months ago by pracine

  • owner changed from pracine to jorgearevalo

Changed 14 months ago by jorgearevalo

  • status changed from new to assigned

Changed 13 months ago by pracine

How do you plan to do that?

Changed 13 months ago by jorgearevalo

Working on it. Strange, because the values returned by the dump core function (rt_raster_dump_as_wktpolygons) are in floating point format, but they're truncated before being shown (just before calling PostgreSQL function BuildTupleFromCStrings).

Maybe the decimal part is omitted when is zero (like in the example with smallr table)...

Changed 13 months ago by pracine

If you read the doc of the GDALPolygonize function:

 http://www.gdal.org/gdal__alg_8h.html#3f522a9035d3512b5d414fb4752671b1

it says: "Note that currently the source pixel band values are read into a signed 32bit integer buffer (Int32), so floating point or complex bands will be implicitly truncated before processing."

I think this makes it impossible for us to get floats back from this function. We could add a parameter saying the number of digits we want and multiply every pixel by 10 exp(this number) but this would inply multiplying every pixel value: way too long.

I think the only way will be to have GDAL to work with float values...

Changed 11 months ago by pracine

Frank will have a look at this problem during the code sprint. Hopefully we'll have float support! :-)

Changed 11 months ago by jorgearevalo

Great news!

Changed 11 months ago by pracine

  • priority changed from critical to blocker

Changed 10 months ago by pracine

I filled a ticket in GDAL Trac:

 http://trac.osgeo.org/gdal/ticket/4005

Changed 9 months ago by jorgearevalo

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

Fixed in r7308. New GDAL polygonize function implemented in GDAL release 22476 ( http://trac.osgeo.org/gdal/changeset/22476). Please, update your GDAL copy to a release up to 22476 before compiling PostGIS with raster support to make it work.

Changed 9 months ago by pracine

No change in the API? No way to specify the number of digits?

Changed 9 months ago by dustymugs

From the looks of it, there is no way to specify a rounding factor.

Personally, I have a different question. By the looks of it, you need GDAL trunk revision 22476 to make use of the functionality and run some of the tests. So, is PostGIS Raster going to set the minimum required version of GDAL raster to whatever point release includes this specific revision?

Changed 9 months ago by jorgearevalo

No, no changes in the API. You simply get the raster value in a float variable, and this variable is copied in the 'val' field of the rt_geomval structure. Is not that enough?

Bborie: yes, I forgot to modify the configure script. We'll need the next GDAL stable version. We may call GDALPolygonize if GDAL version is lower than the required or the new GDALFPolygonize in case we have the right version of GDAL installed, and warn the user in the first case.

Changed 9 months ago by jorgearevalo

Now the existence of GDALFPolygonize is checked. r7316

Changed 6 months ago by dustymugs

  • status changed from closed to reopened
  • resolution fixed deleted

Reopened as testing of rt_raster_dump_as_wktpolygons() reveals that the output values are integers rather than floating point even though GDAL is trunk r22922 and postgis config detects GDALFPolygonize. It looks like the GDALFPOLYGONIZE macro isn't being set so that the compilation occurs correctly.

Changed 6 months ago by dustymugs

  • status changed from reopened to closed
  • resolution set to fixed

Fixed in r7785.

Note: See TracTickets for help on using tickets.