Starting with an .img
file how to I convert a specific (x,y) coordinate into (lon,lat) with gdal
. I don't know what my input format is, but if I type gdalinfo topo.img
it tells me the corner coordinates of the map, so it ought to be possible to get the coordinates for any of the grid points without further input. gdallocationinfo topo.img [x] [y]
gives the elevation only.
The beginning of the gdalinfo
output for the input file looks like this:
Driver: HFA/Erdas Imagine Images (.img)
Files: bigislandDTM.img
bigislandDTM.ige
bigislandDTM.rrd
Size is 32609, 35573
Coordinate System is:
PROJCS["NAD_1983_UTM_Zone_5N",
GEOGCS["NAD83",
DATUM["North_American_Datum_1983",
SPHEROID["GRS 1980",6378137,298.257222101,
AUTHORITY["EPSG","7019"]],
TOWGS84[0,0,0,0,0,0,0],
AUTHORITY["EPSG","6269"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9108"]],
AUTHORITY["EPSG","4269"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",-153],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["Meter",1],
AUTHORITY["EPSG","26905"]]
Origin = (170717.059624216170050,2247879.339183096773922)
Pixel Size = (4.497066284309543,-4.497066284309542)
Corner Coordinates:
Upper Left ( 170717.060, 2247879.339) (156d 9' 9.63"W, 20d18' 1.76"N)
Lower Left ( 170717.060, 2087905.200) (156d 7'28.87"W, 18d51'25.08"N)
Upper Right ( 317361.894, 2247879.339) (154d44'57.59"W, 20d19'12.58"N)
Lower Right ( 317361.894, 2087905.200) (154d44' 1.61"W, 18d52'30.47"N)
Center ( 244039.477, 2167892.270) (155d26'24.29"W, 19d35'22.45"N)
img
file withgdal_translate -of xyz -srcwin 12000 11000 7000 2000 -outsize 22.49% 22.49% topo.img tmp.txt
. If I can get the corner coordinates of what I have cropped out, then I know how to make a topo map with GMT. In the example you link, it is assumed that x and longitude are related linearly, which is not exactly true if I look at the corner coordinates of my rectangular grid. – Norbert Oct 19 '15 at 23:32img2grd
, but can't get it to produce any output. Thanks! – Norbert Oct 20 '15 at 0:02gdalinfo output_file.tif
– BradHards Oct 20 '15 at 2:29