[Gdal-dev] Find elevation data at specific point
Gerald Brandt
gbr at MICROPILOT.com
Fri Jun 4 13:37:11 EDT 2004
Thanks! What would the pixelx, liney formula be if the image is not
north up?
I'm working with DEM and DTED and have not yet seen anything that isn't
north up, but that doesn't mean there aren't any!
Thanks,
Gerald
> -----Original Message-----
> From: gdal-dev-admin at remotesensing.org
> [mailto:gdal-dev-admin at remotesensing.org] On Behalf Of Frank Warmerdam
> Sent: Friday, June 04, 2004 12:07 PM
> To: gdal-dev at remotesensing.org
> Subject: Re: [Gdal-dev] Find elevation data at specific point
>
>
> Gerald Brandt wrote:
> > Hi,
> >
> > I would like to know how to get the elevation from a specific
> > coordinate (in latitude/longitude or UTM). I can convert between
> > lat/long and UTM as needed for the specific map data loaded, but I
> > don't know how to get the elevation of that coordinate.
> >
> > I'm assuming that I need to get the xpixel and yline values, and
> > reference off of that somehow. But, being new to GDAL, I'm
> not quite
> > sure.
>
>
> Gerald,
>
> I haven't got time to prepare a proper demonstration. But
> the brief answer is you need to:
>
> o Transform your coordinate into the coordinate system of the image.
> For instance if you start with lat/long but the image is
> in UTM, convert
> it to UTM.
> o Convert that coordinate to image pixel/line coordinates.
> Assuming the
> image is north-up (no rotational coefficients) then this would be:
>
> pixel_x = (geo_x - gt[0]) / gt[1]
> pixel_y = (geo_y - gt[3]) / gt[5]
>
> Where gt[] is the Geotransform array fetched with the
> GetGeotransform()
> method on the GDALDataset.
>
> o Read just that pixel with RasterIO().
>
> eg.
>
> double dfElev;
>
> poDS->GetRasterBand(1)->RasterIO( GF_Read, pixel_x, pixel_y, 1, 1,
> &dfElev, 1, 1, GDT_Float64 );
>
> or something like that.
>
> Good luck,
>
> --
> ---------------------------------------+----------------------
> ----------
> ---------------------------------------+------
> 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
>
> _______________________________________________
> Gdal-dev mailing list
> Gdal-dev at remotesensing.org
> http://remotesensing.org/mailman/listinfo/gdal> -dev
>
More information about the Gdal-dev
mailing list