Is there any way to automatically georeference hundreds of jpeg images with known corner coordinates in a text file?
1 Answers
You can write a small script to generate jgw (georeference) file. I suppose your jpegs are rectified (pixel rows and columns are parallel to the axises of the coordinate system). You have to know the pixel size on the field and the coordinates of the upper left corner. You have to create a simple text file (one data in a row):
x_pixel_size_on_the_field
0
0
-y_pixel_size_on_the_field
x_coordinate_of_upper_left_pixel_center
y_coordinate_of_upper_left_pixel_center
Please note the negative sign before y_pixel_size_on_field. For example pixel size in map units is 20 cm and the upper left corner coordinates are 234100 65400, then the world (jgw) file is:
0.20
0
0
-0.2
234100.1
65400.1
I don't know how can you find the coordinates of the upper left corner from the file name.
- 7,325
- 17
- 27
-
gdal_translate could be a chance to avoid writing your own script, as user30184 wrote. – Zoltan May 26 '18 at 08:05
-
Yes i m using this command 'gdal_translate -of JPEG -a_ullr ullon ullat lrlon lrlat -a_srs EPSG:4326 input.jpg output.jpg' and it is working well to georef my image, but now my question is i have series of images e.g image1.jpg, image 2.jpg, image3.jpg with their corner coordinates in txt file like image1.txt, image2.txt, image3.txt and so on.. So my question is how can i ammend this above mentioned code to read path of the folder in which these files are present and georef it and place it some other new folder – Amjad Khan May 26 '18 at 11:17
-
Than you cannot avoid to write a script. The code depends on which operating system you use. – Zoltan May 26 '18 at 19:03
-
I m uising windows 10, here is my code
gdal_translate -of JPEG -a_ullr ullon ullat lrlon lrlat -a_srs EPSG:4326 input.jpg output.jpg
now plz help me to ammend it, i want to add folder directory in this code from where i can fetch my non-georeferenced images and assign coorner coordinates from a txt file of the same name, and then store it to some other folder.
– Amjad Khan May 28 '18 at 06:17 -
Unfortunatelly I'm using Linux not Windows. You can use for loop to read coordinates from the file (see: https://stackoverflow.com/questions/206114/batch-files-how-to-read-a-file) and to remove extension from file name (see: https://stackoverflow.com/questions/3215501/batch-remove-file-extension) – Zoltan May 29 '18 at 07:09
-a_ullr? It requires that the image is not rotated. – user30184 May 24 '18 at 20:25