[gdal-dev] How to access a part of an image

Tamas Szekeres szekerest at gmail.com
Mon Jun 16 16:00:15 EDT 2008


Andreas,

If you use RasterIO the nXSize,nYSiye should correspond to the
nBufXSize nBufYSize to avoid the image decimation / replication
according to
http://www.gdal.org/classGDALDataset.html#e077c53268d2272eebed10b891a05743

Best regards,

Tamas


2008/6/16 Andreas Theofilu <andreas at theosys.at>:
> Hi to all,
>
> I have here a PNG image of a map where I know the geo coordinates of the upper
> left corner and the lower right corner. Of course I know the pixels in X and
> Y dimensions.
>
> Now I want to display only a part of that image. I know the upper left corner
> in geo coordinates and also the lower right corner of the rectangular I want
> to show. I also know the pixel dimensions of the window on the screen, where
> I want to display the map. The size in pixels of the window on the screen
> does not correspond to the pixels of the image.
>
> I'm able to open the image with GDAL, but I don't know how I should tell GDAL
> about the geo dimensions of the image (tried it with SetGeoTransform())? And
> how can I tell GDAL about the rectangular I wand to load from the image?
>
> I tried to compute this myself and could successfull calculate the X and Y
> offset in pixels, where to start loading the image. I then give this to
> RasterIO() and was able to read only a part of the image, but with wrong
> dimensions of course, because GDAL didn't knew the wanted pixels in X and Y
> directions.
>
> Is there another way to do that?
>
> --
> Andreas Theofilu
> TheoSys - Software Systems and Solutions
> http://www.theosys.at
> Tel.: +43 676 / 786 53 89
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>


More information about the gdal-dev mailing list