12

I have a series of point features which represent road signs and each point has one photo of each sign associated with it.

I want to create a mapbook with the locations of the signs shown as points and the photo displayed next to the point. Each page in the mapbook will have multiple sign locations and photos on it.

Is there an easy way to automate importing photos into an MXD in data view next to a point feature?

There are about 1000 hence need for automation. Or somehow "labeling" a feature with a photo?

1 Answer 1

16
+50

Modify (scale, shiftX, shiftY) and run this script

import arcpy, traceback, os, sys
from arcpy import env
env.overwriteoutput=True

scale=10
shiftX=50
shiftY=25

points = r'D:\Scratch\points.shp'
try:
    def showPyMessage():
        arcpy.AddMessage(str(time.ctime()) + " - " + message)
    
    with arcpy.da.SearchCursor(points,("Shape@","HLINK")) as scur:
        for shp,image in scur:
            worldFile=image.replace(".jpg",".jgw")
            f = open(worldFile, 'w')
            f.write('%s\n'%(float(1)/scale))
            f.write('0.0000000\n')
            f.write('0.0000000\n')
            f.write('%s\n' %(-float(1)/scale))
            f.write('%s\n' %(shp.firstPoint.X+shiftX))
            f.write('%s\n' %(shp.firstPoint.Y+shiftY))
        f.close
except:
    message = "\n*** PYTHON ERRORS *** "; showPyMessage()
    message = "Python Traceback Info: " + traceback.format_tb(sys.exc_info()[2])[0]; showPyMessage()
    message = "Python Error Info: " +  str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"; showPyMessage()            

Script assumes that points table has hyperlink to picture and they are jpegs: enter image description here

Script writes world file using user specified parameters scale factor and coordinates shifts. Play with them to achieve best match for your scale and image position.

After running the script you might use number of approaches to create image catalogue, e.g. Extracting information from world file of images into DBF catalog file through ArcPy or just create mosaic dataset to get this:

enter image description here

NOTE: Some of catalogues support page definition query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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