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

Jorge Arevalo jorgearevalo at gis4free.org
Mon Mar 8 13:43:59 EST 2010


On Mon, Mar 8, 2010 at 5:42 PM, Pierre Racine
<Pierre.Racine at sbf.ulaval.ca> wrote:
>
> >4.- Add default geotransform to GDAL empty dataset: {0.0, 1.0, 0.0, 0.0, 0.0,1.0 }; (I can't get
> >geotransform from WKT Raster Band)
>
> Why? You can get all the parameters with (in order): rt_raster_get_x_offset(), rt_raster_get_pixel_width(), rt_raster_get_x_rotation(), rt_raster_get_y_offset(), rt_raster_get_y_rotation(), rt_raster_get_pixel_height()...

Yes, I can. It was testing code. But you're right.

>
> >1.- I'm testing this code with really simple raster, and I'm confused. For example:
> >* 2x2 32 bits signed int raster, with "1" in all cells. The result: POLYGON((0 0, 0 2, 2 2, 2 0, 0
> >0)). I was expecting POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))
>
> The result is correct since the pixel size is 1, the raster dimension is 2x2 and there is only one group of pixel sharing the same value.

Ok, Thanks for confirmation.

>
> >* the raster
> >from http://trac.osgeo.org/postgis/attachment/wiki/WKTRaster/SpecificationWorking01/WKTRasterEnvelopeC
> >onvexHullAndShape.gif. The result:
> >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?
>
> It look good to me. What is wrong?

Mmm... ok, it may be only my impression.

>
> >2.- I'd like to store the pixel value in each polygon. Is a good idea to create a field in the layer
> >to store pixel value?
>
> 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?

>
> >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)

>
> Pierre

Thanks Pierre!
Jorge


More information about the gdal-dev mailing list