Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem/question and hopefully someone of you is able to help me:

I have thousands of georeferenced raster files which have corresponding polygons (outer borders of rasters) with a hyperlink in the attribut table to open them in an image viewer. Now I want to load a raster (through selection or whatever) directly with the hyperlink into an MXD Document.

One possibility is

arcpy.MakeRasterLayer_management("G:\\TIFF\RasterXY.tif", "Test")

But now I have only a temporal layer which does not really fit my needs... Maybe someone of you has an idea/solution how to solve this problem.

Thanks, Jann

I tried some things but without any success... Here is my code till now:

import arcpy
data = "Polygone_31-4493"
rows = arcpy.SearchCursor(data, "location")
     for row in rows:
     cursor_path = row.getValue("location")
rows = arcpy.SearchCursor(data, "location")
     rows = arcpy.SearchCursor(data, "image")
     for row in rows:
     cursor_image = row.getValue("image")
arcpy.MakeRasterLayer_management(cursor_path, cursor_image)

Maybe you have some ideas for this. Thanks

Back again on this topic. After several trys I don't think I will work. Maybe someone has another idea how to do this.

fc = "Shapefile"
path = "location"
image = "image"

path = [row[0] for row in arcpy.da.SearchCursor(fc, (path))]
image = [row[0] for row in arcpy.da.SearchCursor(fc, (image))]

# Enconding the 'u
new_path = [str(item) for item in path]
new_image = [str(item) for item in image]

arcpy.MakeRasterLayer_management(new_path, new_image)
Runtime error 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\", line 6198, in MakeRasterLayer
    raise e
RuntimeError: Object: Error in executing tool

I would appreciate any kind of help!

Thanks, Jann

share|improve this question
This sounds like a use case for writing a Python Add-in - are you using ArcGIS 10.1? Also, when you say "I have only a temporal layer which does not really fit my needs" can you expand upon what you mean by a temporal layer and how this does not meet your needs, please? – PolyGeo Dec 18 '12 at 9:18
This is a use case for a Python Add-in. Okay forget about the temporal layer thing I understood something wrong. The code above works for me but now I have to include the hyperlink field into the code. – GIS Friend Dec 18 '12 at 10:55
Maybe it helps to give you an insight into my workaround: I have polygons with their outer borders. Based on this borders i use the Identify Tool to identify interesting images in the area of interest. Then I take a lot at each image in an image viewer with the hyperlink. Now I would like to add an interesting image/images to the map document. – GIS Friend Dec 18 '12 at 11:00
Are you using ArcGIS 10.1? If so, then your bit of code, coupled with a search cursor to read the field value, substituted into the onClick method is virtually the same as the example used for Creating a Python add-in button – PolyGeo Dec 18 '12 at 11:13
Thanks for the help! Yes I'm using ArcGIS 10.1. At the moment I'm not very familiar with python and search cursors etc. but I will try it. Thanks again! – GIS Friend Dec 18 '12 at 11:17

Okay I have it and it is pretty easy :)

cursor = arcpy.SearchCursor("shapefile")
for path in cursor:
    arcpy.MakeRasterLayer_management(path.getValue("location"), path.getValue("image"))
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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