[gdal-dev] How to get the size of a OGRGeometry

Jorge Arévalo jorge.arevalo at gmail.com
Tue Jul 7 19:08:19 EDT 2009


2009/7/8 Frank Warmerdam <warmerdam at pobox.com>:
> Jorge Arévalo wrote:
>>
>> Hello,
>>
>> If I have an OGRGeometry object (said poGeom), I can get its coords by:
>>
>> OGREnvelope * poE = new OGREnvelope();
>> poGeom->getEnvelope(poE);
>>
>> // poE->MinX, poE->MinY, poE->MaxX, poE->MaxY are the limit coords
>>
>> If I want the size of the Geometry:
>>
>> double dSizeX = poE->MaxX - poE->MinX;
>> double dSizeY = poE->MaxY - poE->MinY;
>>
>> Is it the correct way?
>
> Jorge,
>
> This is appropriate for finding the width and height of the
> bounding box.  Is that what you mean when you say "size"?   Size
> is not a well defined term all on it's own.

Hello Frank,

I'm talking about the nRasterXSize, nRasterYSize of a GDALDataset
(this is what I mean with "size"). In the context of the GDAL WKT
Raster driver, I can get the extent covered by a raster getting the
"extent" column from RASTER_COLUMNS table. If I read this column like
an OGRGeometry object, with an OGREnvelope, I can get the upper left
coords (poE->MinX, poE->MinY?) and the extent of the raster. But I'm
not sure if my operations are correct or there is a better way to do
this

Many thanks

>
> Best regards,
> --
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | Geospatial Programmer for Rent
>
>


More information about the gdal-dev mailing list