[Gdal-dev] GDAL in delphi .. reading pixel values (Esri grids)
jk nz
jk_nzd at hotmail.com
Mon Apr 26 19:32:10 EDT 2004
Hi,
This line:
input >> L_COORDFILE >> coordFile >> L_OUTFILE >> outFile >> L_ROWS >>
fileRows >>
L_COLS >> fileCols >> L_XCOORDCOL >> xCoordCol >> L_YCOORDCOL >>
yCoordCol >> L_IMAGEFILE >> imageFile;
... doesnt make the slightest bit of sense to me (I dont know C++), but I'm
guessing it is some smart way of getting values for all these variables in
one line? Later on there is for loops which use fileRows and fileCols - are
these values the same as GetRasterBandXSize and GetRasterBandYSize?
I have GetGeoTransform working correctly, so very close now to getting pixel
reading to work (I hope!)
Regards
JK.
>From: Andrew Finley <afinley at gis.umn.edu>
>Reply-To: gdal-dev at remotesensing.org
>To: gdal-dev at remotesensing.org
>Subject: Re: [Gdal-dev] GDAL in delphi .. reading pixel values (Esri grids)
>Date: 26 Apr 2004 08:42:50 -0500
>
>Hi JK,
>I think there is a similar chunk of code in the list archives, but here
>it is again. Attached are two files, getPixelValueGdal.cpp and
>parameterfile. The parameterfile describes the image location and the
>coordinate file (i.e., point xy locations). This is set up for ERDAS
>images, I think you will only have to change the driver for it to read
>grids. Hope this helps. Let me know if you have any questions.
>-Andy
>
>
>On Mon, 2004-04-26 at 00:48, jk nz wrote:
> > Has anyone tried using GDAL from the Borland Delphi language?
> >
> > I have been mostly sucessful in doing so, but having problems reading
>pixel
> > values from an esri grid..
> >
> > Does anyone have sample code of reading pixels? C is ok .. I have seen
> > sample of reading blocks but that wasnt quite what I wanted ...
> >
> > I do not know how to extract the pixel values as I dont know how they
>are
> > laid out in memory .. is it a 2d grid, or a 1d grid?
> >
> > eg is it laid out in memory as
> >
> > row1 [px1][px2][px3][...]
> > row2 (possible some memory gap in between rows) [px10][px11][...]
> >
> > or as row1 [px1][px2][...] (row2, no gap in memory, next pixel is at
>address
> > pxN+ sizeof(px)) [px10][...]
> >
> > It appears I have to use pointer arithmetic to index the block, ie
>pixelN :=
> > block[index] works fine if it is a 1d grid in memory, but its not so
>easy if
> > its a 2d grid, as the operator block[x,y] is not valid in delphi
> >
> > So I'm trying to figure out what happens at the end of a row? is the
>first
> > element of the next row located in the next memory address or ...?
> >
> > Any help appreciated
> >
> > Regards
> >
> > JK.
> >
> >
> > Here is my code: - everything appears to work, apart from reading
>individual
> > pixel values.
> >
> > for i := 0 to nYBlocks - 1 do // i = Y block index
> > for j := 0 to nYBlocks - 1 do // j = X block index
> > begin
> > GDALReadBlock(RasterBand, j, i, pafScanline);
> >
> > // compute which part of the block is valid for partial
> > blocks
> > if(i * nBlockYSize > nY) then
> > nYValid := nY - i * nBlockYSize
> > else
> > nYValid := nBlockYSize;
> >
> > if(j * nBlockXSize > nX) then
> > nXValid := nX - j * nBlockXSize
> > else
> > nXValid := nBlockXSize;
> >
> > doubleptr := @pafScanline;
> >
> > for k := 0 to nYValid - 1 do // k = Y cell index
> > for l := 0 to nXValid - 1 do // l = X cell index
> > begin
> > inc(doubleptr);
> > cell := doubleptr^;
> > // debugging stuff, did we get an ok value or not?
> > if cell > 0 then
> > ShowMessage(FloatToStr(cell));
> > end; // for l, for k
> > end; // for j, for i
> >
> > _________________________________________________________________
> > Need more speed? Get Xtra JetStream @ http://xtra.co.nz/jetstream
> >
> > _______________________________________________
> > Gdal-dev mailing list
> > Gdal-dev at remotesensing.org
> > http://remotesensing.org/mailman/listinfo/gdal-dev
>--
>Andrew Finley, Research Fellow
>Department of Forest Resources
>College of Natural Resources
>University of Minnesota
>305 Green Hall
>1530 Cleveland Avenue N.
>St. Paul, MN 55108
>
>Ph 612-624-1714 office
>www.cnr.umn.edu/FR/people/facstaff/finley/index.html
><< getPixelValueGdal.cpp >>
><< parameterfile >>
_________________________________________________________________
Surf the net and talk on the phone with Xtra JetStream @
http://xtra.co.nz/jetstream
More information about the Gdal-dev
mailing list