<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python: Insert Photographs into ArcMap Data View Programattically in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-insert-photographs-into-arcmap-data-view/m-p/748612#M57852</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jake&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the following, great idea n generating the rasters from the current spatial extent. I'll post my final script once complete.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Nov 2013 06:45:12 GMT</pubDate>
    <dc:creator>PeterWilson</dc:creator>
    <dc:date>2013-11-26T06:45:12Z</dc:date>
    <item>
      <title>Python: Insert Photographs into ArcMap Data View Programattically</title>
      <link>https://community.esri.com/t5/python-questions/python-insert-photographs-into-arcmap-data-view/m-p/748610#M57850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have hundreds of photographs that have been taken as part of a survey. I've created point features that represent the location of each photograph as well as added a field to the point features with the full path to the photographs. I'd like to insert the photographs into the data view of ArcMap, specify the width and height to display the photograph and have them centered at the point feature associated&amp;nbsp; with the photograph. I wouldn't like to do this manually as there are a couple hundred photographs. The photographs need to be inserted not hyperlinked as I need to print the various sections of the surveyed area and display the photographs on the printed map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 15:51:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-insert-photographs-into-arcmap-data-view/m-p/748610#M57850</guid>
      <dc:creator>PeterWilson</dc:creator>
      <dc:date>2013-11-22T15:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Python: Insert Photographs into ArcMap Data View Programattically</title>
      <link>https://community.esri.com/t5/python-questions/python-insert-photographs-into-arcmap-data-view/m-p/748611#M57851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Peter,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is some code that zooms to each point, creates a polygon feature class from the extent, then converts the polygon to a raster in a new directory.&amp;nbsp; The code then copies the original photo to the new directory (overwriting the raster previously created), so that it can use the coordinate information, and then defines the projection of the rasters.&amp;nbsp; If you need to change the size of the raster, you can try adding in the &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00170000007r000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Rescale&lt;/A&gt;&lt;SPAN&gt; function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
from arcpy import mapping
env.overwriteOutput = 1

mxd = mapping.MapDocument(r"C:\temp\python\Points.mxd")
df = mapping.ListDataFrames(mxd)[0]

lyr = arcpy.mapping.ListLayers(mxd)[0]

# Create new photo directory
newPhoto = r"C:\Temp\Python\Photos\New Photos"

dict = {}

# Create dictionary of OBJECTIDs and the path to the photo
with arcpy.da.SearchCursor(lyr, ["OBJECTID", "PHOTO"]) as cursor:
&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterName = row[1].split("\\")[-1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dict[row[0]] = rasterName

firstTime = "True"

# Select each point, zoom/pan to the selected point, create a polygon feature class from extent,
# convert polygon to raster dataset
for key in dict:
&amp;nbsp;&amp;nbsp; if firstTime == 'True':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", "OBJECTID = " + str(key))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df.extent = lyr.getSelectedExtent()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XMAX = df.extent.XMax
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XMIN = df.extent.XMin
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; YMAX = df.extent.YMax
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; YMIN = df.extent.YMin
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt1 = arcpy.Point(XMIN, YMIN)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt2 = arcpy.Point(XMIN, YMAX)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt3 = arcpy.Point(XMAX, YMAX)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt4 = arcpy.Point(XMAX, YMIN)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array = arcpy.Array()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt3)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt4)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polygon = arcpy.Polygon(array)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(polygon, r"IN_MEMORY\polygon")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.PolygonToRaster_conversion(r"IN_MEMORY\polygon", "OID", r"IN_MEMORY\raster")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyRaster_management(r"IN_MEMORY\raster", newPhoto + "\\" + dict[key])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstTime = "False"
&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", "OBJECTID = " + str(key))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df.panToExtent(lyr.getSelectedExtent())
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XMAX = df.extent.XMax
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XMIN = df.extent.XMin
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; YMAX = df.extent.YMax
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; YMIN = df.extent.YMin
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt1 = arcpy.Point(XMIN, YMIN)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt2 = arcpy.Point(XMIN, YMAX)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt3 = arcpy.Point(XMAX, YMAX)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt4 = arcpy.Point(XMAX, YMIN)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array = arcpy.Array()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt3)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt4)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; polygon = arcpy.Polygon(array)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(polygon, r"IN_MEMORY\polygon")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.PolygonToRaster_conversion(r"IN_MEMORY\polygon", "OID", r"IN_MEMORY\raster")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyRaster_management(r"IN_MEMORY\raster", newPhoto + "\\" + dict[key])

del mxd

# Clear the selection
arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")

list = []

with arcpy.da.SearchCursor(lyr, ["PHOTO"]) as cursor:
&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list.append(row[0])

# Copy original photo to the new photo directory, replacing the raster created previously
for photo in list:
&amp;nbsp;&amp;nbsp; shutil.copy(photo, newPhoto)

spatial_ref = arcpy.Describe(lyr).spatialReference

# Project each raster
env.workspace = newPhoto
for raster in arcpy.ListRasters("*"):
&amp;nbsp;&amp;nbsp; arcpy.DefineProjection_management(raster, spatial_ref)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:49:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-insert-photographs-into-arcmap-data-view/m-p/748611#M57851</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T07:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Python: Insert Photographs into ArcMap Data View Programattically</title>
      <link>https://community.esri.com/t5/python-questions/python-insert-photographs-into-arcmap-data-view/m-p/748612#M57852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jake&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the following, great idea n generating the rasters from the current spatial extent. I'll post my final script once complete.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Nov 2013 06:45:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-insert-photographs-into-arcmap-data-view/m-p/748612#M57852</guid>
      <dc:creator>PeterWilson</dc:creator>
      <dc:date>2013-11-26T06:45:12Z</dc:date>
    </item>
  </channel>
</rss>

