I have several scans of the same map, which I would like to georeference. I can not use arcpy.WarpFromFile_management(...) as the rasters are slightly different due to scanning.

Is there a possibility to automatically (using python) recognise marker point on the map, which are than used as controll points for georeferencing? As the map is black and white the points could be of a specific colour to be easily identified. I am using ArcGIS 10.3 basic w/o and extensions. Any ideas?

  • I don't think you'll be able to recognize a marker point on the map. I once did a batch registration of several "similar" images by determining a baseline set of screen coordinates and using offsets to those (pixel shifts n, s, e, or w). The offsets need to be determined manually. It ran in the OSGeo4W shell though so if you are open to a QGIS solution, I'll post an answer. – jbchurchill Jan 5 '16 at 19:09
  • That sounds interesting. Even though I would prefer a ArcGIS solution I am open to QGIS aswell and would be grateful for your answer. – Alex Jan 6 '16 at 7:21

You commented that you'd be open to a QGIS solution. This worked for me.

As you know, georeferencing an image requires identifying points on the image and assigning real world coordinates to the screen coordinates in the image. As I commented on the question, I don’t know of any way to identify markers in an image automatically. if the images are the same resolution and have the same features/markers on them you can determine what the image coordinates are and then tie them to real world coordinates in a script. The difficult part that needs to be done manually is identifying the image coordinates. If most of the images have the same image coordinates but a few are different, this will be fairly easy. You can have a default and then identify an X-shift and Y-shift for each non-default image. I did this for about 1200 tif images. I used Photoshop’s XY tool to identify the image coordinates but you could also use IRFANVIEW which is a free download and excellent image editing tool (see instructions below for determining coordinates).

Image coordinates start in the upper left and our spatial system starts (has its axis) in the lower left but that won’t matter as we are just tying one to another using the gdal_translate command.

1) Identify default image coordinates. I had these in a list like this and most of my images (animal range maps in my case) worked fine using these numbers...
1) 4, 366
2) 586, 167
3) 239, 6
4) 287, 507 (middle of the peninsula)
5) 68, 570
6) 19, 256

Sometimes though the “markers” were not in the same location and I had to identify a shift in X and/or Y where the screen coordinates were different by n number of pixels (shift could be positive or negative).
T_02_01.tiff (has a Y shift of 5)
1) 4, 371

2) Next I had to write the first of 2 windows batch files (.bat) that work together. The variables being set at the top x1-x6 and y1-y6 represent my default screen coordinates. Then I used IF statements for shifts on the individual images that weren't default (had X or Y shifts or both). Then I use new x, y variables and add together the shift and original x, y. The %1 variable is the file name which is passed to this batch file from the second batch file. You will need to update Input and Output paths (my input folder was INPUT_NEW and output was TMP). Put both batch files at the root of the input and output folders and it will work the way I have it here. SET x1=4
SET x2=586
SET x3=239
SET x4=287
SET x5=68
SET x6=19
SET y1=366
SET y2=167
SET y3=6
SET y4=507
SET y5=570
SET y6=256
IF %1 == T_01_04.tiff (
IF %1 == T_01_06.tiff (
IF %1 == T_02_01.tiff (
IF %1 == T_64_17.tiff (

SET /a x1b=%XSHIFT%+%x1%
SET /a x2b=%XSHIFT%+%x2%
SET /a x3b=%XSHIFT%+%x3%
SET /a x4b=%XSHIFT%+%x4%
SET /a x5b=%XSHIFT%+%x5%
SET /a x6b=%XSHIFT%+%x6%
SET /a y1b=%YSHIFT%+%y1%
SET /a y2b=%YSHIFT%+%y2%
SET /a y3b=%YSHIFT%+%y3%
SET /a y4b=%YSHIFT%+%y4%
SET /a y5b=%YSHIFT%+%y5%
SET /a y6b=%YSHIFT%+%y6%
gdal_translate -of GTiff -gcp %x1b% %y1b% 498353 9.75475e+06 -gcp %x2b% %y2b% 1.13853e+06 9.99319e+06 -gcp %x3b% %y3b% 747172 1.01571e+07 -gcp %x4b% %y4b% 818043 9.6109e+06 -gcp %x5b% %y5b% 572611 9.5335e+06 -gcp %x6b% %y6b% 508386 9.87613e+06 "INPUT_NEW\%1" "TMP\%1"

The second batch file for /f %%f in ('dir /b *.tiff INPUT_NEW') do (
echo "Processing %%f"
gd3trans655s %%f
gdwarp %%f

3) Next you need to run these batch files at the OSGeo4W shell which gets installed with QGIS. It is sort of a Windows Command line that gives you access to the gdal library (necessary for us to run the gdal_translate and gdwarp commands).

Methods for determining Image Coordinates

Just hold down the left mouse button and it will show the coordinates in the titlebar.

  • Thanks for your effort. I am just starting with Python in comination with QGIS. It seems very different to Python in combination using ArcGIS. I will give your solution a try once I am a bit furthe with QGIS/Python. – Alex Jan 13 '16 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.