[gdal-dev] XY Point extraction from raster

Ari Jolma ari.jolma at tkk.fi
Sun Jun 29 07:05:01 EDT 2008


Hyer, Dr. Edward (Post Doc) kirjoitti:
> I have been very pleased with the way I can use 'gdaltransform' to wrap
> a long set of operations into a single-line command. I am trying to
> extract point data from an HDF file, and with:
>
> gdaltransform -i -t_srs EPSG:4326 HDF_FILE.hdf < points_dd.txt >
> points_xy.txt
>
> I can feed it a set of XY geographic locations, and it will spit out
> corresponding image coordinates.
>
> Now, how can I actually pull the data, just for those specific
> coordinates?
>
> I use PDL in Perl for numerics, but this seems like something I should
> be able to do with the command-line utilities.
>   

If you have working Perl wrappers, it should be easy once you have the 
band object:

$data = $band->ReadTile($x, $y, 1, 1);
$pixel = $data->[0][0];

If the HDF file is not too big and you have lots of pixels, then perhaps

$data = $band->ReadTile;
$pixel = $data->[$x][$y];

is faster. ReadTile appeared in GDAL 1.5.

I also use PDL sometimes (mostly because of PDL::NetCDF), but did not 
have the need to pull in data from rasters directly to PDL. If there's 
interest, we could perhaps write a PDL::GDAL module.

Ari

> Thanks for any tips/tricks,
>
> --Edward H.
>
> Dr. Edward J. Hyer
> Post-Doctoral Researcher
> Naval Research Laboratory
> Marine Meteorology Division
> 7 Grace Hopper Avenue, Stop 2
> Monterey, California 93940
> 831-656-4023
> FAX 831-656-4769
> edward.hyer at nrlmry.navy.mil
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>   


-- 
Prof. Ari Jolma
Geoinformatiikka / Geoinformatics
Teknillinen Korkeakoulu / Helsinki University of Technology
tel: +358 9 451 3886 address: POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma



More information about the gdal-dev mailing list