[postgis-devel] [gdal-dev] [WKTRaster] WKT Raster band to GDAL band

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Mon Mar 8 13:55:20 PST 2010


>> >POLYGON ((3 1,3 2,2 2,2 3,1 3,1 6,2 6,2 7,3 7,3 8,5 8,5 6,3 6,3 3,4 3,5 3,5 1,3 1))
>> >POLYGON ((3 3,3 6,6 6,6 3,3 3))
>> >POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))
>> >POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8
>3,8
>> >6,7 6,7 7,6 7))
>> >
>> >Something strange here? Am I doing things right?

You know how to quickly display geometries? Do you? I use OpenJump.

>> You are supposed to return the value for each polygon in a "wktgeomval set" as stated in the specs.
>This way the SQL caller can decide what to do with the value. Isn't that what you did?
>
>Yes, I did this. The point is I was trying to label each polygon with
>its pixel value (GDALPolygonize allows this). Then, in a loop, I get
>all the features of the layer written by GDALPolygonize and store the
>exported WKT polygon and the px value in a wktgeomval structure.
>Sounds good?

Very good.

>> >3.- From a GDAL RasterBand, I can fetch the owning dataset handle (GDALGetBandDataset).I think it
>> >could be useful to get the WKT Raster handle from a WKT RasterBand too... Am I right?
>>
>> rt_band_get_data()?
>
>No, I mean getting the raster that contains this band, from the band
>struct itself, like
>
>GDALDatasetH GDALGetBandDataset(GDALRasterBandH hBand )
>
>from GDAL C API
>
>(or GDALRasterBand::GetDataset() from GDAL C++ API)

If it would be useful to you, then it would probably be useful to us...

By the way: I saw that your code does not handle the SRID. That means ST_AsPolygon(raster, integer) -> geomval set would have to get it itself from the raster. Maybe it would be more efficient to include it in the wktgeomval structure so ST_AsPolygon could use it directly in ST_GeometryFromText(text WKT, SRID) without having to query the raster again.

Pierre



More information about the postgis-devel mailing list