I have an image (map) without geo data in TIFF format.
I need to get GeoTIFF file from my image. I have latitude and longitude for each corner of my map. How can I add my geo data to my image in Google spatial refence to get geotiff? I know that GDAL can help me with that. Can anyone help me build a command

- 5,589
- 7
- 33
- 50
-
Are you looking for a language library or a tool? – starbolin Jun 08 '12 at 23:24
-
perhaps you will find your answer here: http://www.gdal.org/. GDAL is a command line tool that allows you to convert images, projections, specify bounds etc. – Suvi Vignarajah Jun 09 '12 at 01:02
-
GDAL ))). I'm trying to use it but don't understand how to add my geo data to my image file. Could you help me with this. I understand that I need to use gdal_translate, my spacial reference as for Google maps (WGS84). my coordinates (lat/long) 55.7234, 37.555287 - left bottom 55.725406, 37.551623 - left top 55.726058, 37.553034 - right top 55.724892, 37.556912 - right bottom. – rowwingman Jun 09 '12 at 11:06
2 Answers
You have the right idea in your answer but allow me to expand. You are correct, you'll need to use the gdal_translate tool to set ground control points (gcps) to georeference the image. But the command line argument should go like so:
gdal_translate -of GTiff -a_srs EPSG:4326 -gcp [pixel line easting northing] -gcp [pixel line easting northing] -gcp [pixel line easting northing] sourcefile outpulfile
You don't necessarily have to output to a VRT, VRT's are useful if you want to perform other algorithms to your file, add more datasets to it, eventually output it as a KML - amongst others which you can read up on here ( http://www.gdal.org/gdal_vrttut.html ). But for this purpose setting -of
to GTiff is ideal.
-a_srs EPSG:4326
Next, in the spatial reference you are correct it should be referenced to WGS84 the coordinate system used by google earth, however we specify it using EPSG:4326
- this is just the coding scheme the Geomatics Committee has agreed on to identify coordinate systems worldwide ( http://www.epsg.org/ ).
-gcp [pixel line easting northing]
The ground control points, are probably the most trickiest part of the command line argument. The first 2 numbers represent the pixel and line coordinate of your actual image, for instance (0,0) for the top left most corner of your image. The second set of numbers that should follow is the corresponding lat/long coordinates that your image should be referenced to. Now, you'll only need 3 of these -gcps
because the 4th one will be determined if your image is a square/rectangle.
sourcefile outputfile
This part should be self-explanatory, just remember they are both *.tif files.
Now, there if one last thing you will need to do to complete your task. You will have to actually project the image to the coordinate system for it to be aligned. This is down using the gdalwarp
command ( http://www.gdal.org/gdalwarp.html ).
gdalwarp -t_srs EPSG:4326 sourcefile outputfile
You'll have to specify an -of
(output fileformat) if it was supposed to something other than a GeoTiff - but the default format is GTiff so you don't need to specify it.

- 4,788
- 4
- 34
- 46

- 5,758
- 27
- 38
-
1keep in mind, the `sourcefile` for your `gdalwarp` is the `outputfile` you get from the `gdal_translate` tool – Suvi Vignarajah Jun 10 '12 at 16:30
-
Thank's very much for explanation. But I don't understand about EPSG:4326 - is this the same as WGS84? – rowwingman Jun 10 '12 at 21:43
-
1yes, they are both the same..let me refer you to this question from the GIS StackExchange http://gis.stackexchange.com/questions/3334/what-is-the-difference-between-wgs84-and-epsg4326 – Suvi Vignarajah Jun 10 '12 at 22:35
-
-
-
-
my mistake, you're right that should be top left corner..like i said, gcp's are the trickiest part, i've messed up the orders enough and my images always come out distorted - you really have to make sure they match up (direction/position wise)...i updated my answer as well, thanks for the catch – Suvi Vignarajah Jun 15 '12 at 20:50
gdal_translate -of VRT -a_srs WGS84 -a_ullr 55.7254060 37.5516230 55.7248920 37.5569120 source image destination image
gdal_translate -of VRT -a_srs "spacial reference" -a_ullr "left top lat/long" "right bottom lat/long" source image destination image

- 57,590
- 26
- 140
- 166

- 5,589
- 7
- 33
- 50
-
This worked for me and correctly set the coordinate reference system. An explanation of what the -a_ullr parameter does how it works might be useful for others. – Mark Williams Mar 02 '15 at 12:30