I have a raster file and a WGS84 lat/lon point.
I would like to know what value in the raster corresponds with the point.
My feeling is that I should use GetSpatialRef()
on the raster object or one of its bands and then apply a ogr.osr.CoordinateTransformation()
to the point to map it to the raster's space.
My hope would then be that I could simply ask the rasters' bands what is at that point.
However, the raster object doesn't seem to have a GetSpatialRef()
or a way to access a geo-located point, so I'm somewhat at a loss for how to do this.
Any thoughts?
Yes, the API isn't consistent. The raster (the data source) has a
GetProjection()
method instead (which returns WKT).Here is a function that does what you want (drawn from here):
Its documentation is as follows (drawn from here):
Say i have a geotiff file test.tif. Then followin code should look up value somewhere near the pixel. I am not that confident for the part looking up cell, and will fix there is error. This page should help, "GDAL Data Model"
Also, you may go to gis.stackexchange.com to find experts, if you haven't.
done... with that, the vector file has adopted the projection from input raster file