# Adding image to existing data frame using ArcPy

Geographic Information Systems Asked by Megan on September 17, 2020

This is the first time I am using Python on my own, and I have searched for this answer for a few hours with no luck. I am wanting to take a .JPG image and put it in a data frame. The image has to be in color, and needs to change with data driven pages.

Sounds like you want a 'dynamic image' like 'dynamic attributes' - this might be a starting point:

Insert dynamic pictures with Map Series

If you are using Map Series, you can make your picture element dynamic and have it update for each page. To do this, double-click the picture to open the Element pane. There are two options from which you can choose: Simple path and Dynamic (Map Series).

Dynamic (Map Series) allows you to reference images that you have as attachments on index layer features. You can also reference a raster field as well. In cases where you have more than one attachment for a feature, you should use the Name filter. For example, you can filer on the file type (.png) or on a portion of text in the name.

Answered by Barrett on September 17, 2020

I would suggest for you to template out your map document with a pseudo image and just replace the source using python instead of adding and removing the layer. I take that your image is an element, not actually apart of a data frame. If so, you may swap out the reference path to that image by using the

sourceImage

property, see code example below:

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:ProjectProject.mxd")
for elm in arcpy.mapping.ListLayoutElements(mxd, "PICTURE_ELEMENT"):
if elm.name == "Photo":
elm.sourceImage = r"C:ProjectDataNewPhoto.bmp"
mxd.save()
del mxd


Otherwise, you could technically store this image in a seperate data frame and resource it by the layer replaceDataSource method.

Answered by artwork21 on September 17, 2020

I don't think you need Python for this, unless there are other complicating factors not mentioned in the question.

Assuming that your JPG files are georeferenced (i.e. have *.jgw world files), and that you have a polygon feature class with one rectangular polygon that corresponds to each JPG file, then you should be able to use that polygon feature class as an index in Data Driven Pages.

Make sure the map you are enabling DDP on has all the JPG files in its Table of Contents and turned on.

Answered by PolyGeo on September 17, 2020

## Related Questions

### GeoServer WMS layers not working on Azure app service

1  Asked on August 4, 2020 by tvrtko

### Extracting “World Reference Base (2006) Soil Groups” data in R and searching for the legend of the extracted values

1  Asked on August 3, 2020

### Using Photo points to “geotag” old images in QGIS

1  Asked on August 3, 2020 by john10710

### Filter geometry based on map extent using OpenLayers

1  Asked on August 3, 2020 by massimiliano-moraca

### Finding closest point to shapefile coastline Python

1  Asked on August 3, 2020 by dannytg

### How do I create a rectangular feature in ArcGIS Pro given only 2 coordinates and a width?

1  Asked on August 2, 2020 by maps_spam

### How to plot NDVI time series for two features on same plot?

0  Asked on August 2, 2020 by sankarshan-rastogi

### Can I copy files using QGIS browser?

1  Asked on August 2, 2020 by user1521655

### gdal_merge with python for PDS4 does not generate xml

0  Asked on August 1, 2020 by shen

### Access SpatiaLite connections with PyQGIS QgsProviderMetadata (QGIS 3.10.7 LTR)

1  Asked on July 31, 2020 by jochen-schwarze

### Display .kml file in Leaflet

2  Asked on July 31, 2020

### Error message qgis-ltr-bin.exe

1  Asked on July 31, 2020 by sarath

### st_intersection only if specific conditions are satisfied

0  Asked on July 30, 2020

### R cartography package colored pencil – Get Pencil Layer problem

1  Asked on July 30, 2020 by james-holland

### Copy & Paste Feature in same Layer but not editable seperately?

0  Asked on July 29, 2020 by gmuerovic

### GeoServer 2.18. Setting Min & Max Scales

1  Asked on July 29, 2020 by zakariah1

### Buffer zone intersection proportion using ArcMap

0  Asked on July 29, 2020 by nigel-lawton

### Displaying features by multi-attributes using proportional symbols

0  Asked on July 29, 2020 by florian-mahl

### Is there a command line tool like gdalinfo for vector files?

1  Asked on July 29, 2020