<?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: How to load image to Raster attribute field with python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-load-image-to-raster-attribute-field-with/m-p/442416#M34637</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;SPAN style="font-style: italic;"&gt;Any intent I did with code to load the raster resulted in an error. Since I could not find any documentation on doing this in Python I assume it is not supported.&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Xander,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this supported in arcpy for ArcGIS Pro? I'm currently looking for a way to update raster fields in FC table with Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a&amp;nbsp;script that uses the updatecursor to populate a text field with a path to the directory where the rasters are stored. But, what I really need is to update the raster field with the image itself. And apparently you can't use cursors for this. I started a thread the other day:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/thread/231019-raster-fields-not-supported-using-cursors"&gt;https://community.esri.com/thread/231019-raster-fields-not-supported-using-cursors&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Mar 2019 15:46:49 GMT</pubDate>
    <dc:creator>JaredPilbeam2</dc:creator>
    <dc:date>2019-03-26T15:46:49Z</dc:date>
    <item>
      <title>How to load image to Raster attribute field with python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-load-image-to-raster-attribute-field-with/m-p/442412#M34633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm working with ArcGis 10.0 and I try to load dinamically images to Raster attribute field using python, anyone knows any method to load an image in this field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is my code&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
arcpy.env.workspace = r'D:\LABSIG\CAU\trabajos_diarios\Pruebas Raster\mbd_proyecto_arbolado.mdb'

entityDataset = arcpy.ListDatasets("arbolado")
featureClass = arcpy.ListFeatureClasses("Arbol_censo", "", entityDataset[0])
image = r'D:/Proyecto Arbolado/C12/C12_657.JPG'
cursor = arcpy.UpdateCursor(featureClass[0])
for row in cursor:
 row.setValue("raster_field", image) 
 cursor.updateRow(row)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I try to do this, nothing happened. Should exist an special method or function to load an image in a Raster field?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please help me to find a solution. Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Apr 2014 15:55:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-load-image-to-raster-attribute-field-with/m-p/442412#M34633</guid>
      <dc:creator>AndrésSantos_Lozano</dc:creator>
      <dc:date>2014-04-28T15:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to load image to Raster attribute field with python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-load-image-to-raster-attribute-field-with/m-p/442413#M34634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Andrés,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The thing that goes wrong is that you are not writing the binary representation of the image, but a string containing the path to the image.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Changing the code to something like this might help:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.env.workspace = r'D:\LABSIG\CAU\trabajos_diarios\Pruebas Raster\mbd_proyecto_arbolado.mdb'

entityDataset = arcpy.ListDatasets("arbolado")
featureClass = arcpy.ListFeatureClasses("Arbol_censo", "", entityDataset[0])
image = r'D:/Proyecto Arbolado/C12/C12_657.JPG'
&lt;STRONG&gt;image_blob = open(image,'rb').read()&lt;/STRONG&gt;

cursor = arcpy.UpdateCursor(featureClass[0])
for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue("raster_field", &lt;STRONG&gt;image_blob&lt;/STRONG&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I notice you are using a field of type raster. The code above might not work with a raster field. It does work using a &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;BLOB&lt;/SPAN&gt;&lt;SPAN&gt; field. What I don't know is if BLOB fields are supported in a personal geodatabase (MDB). I would recommend switching to a file geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can read more about reading and writing images to a &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;BLOB&lt;/SPAN&gt;&lt;SPAN&gt; field in the following blog:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://anothergisblog.blogspot.nl/2012/06/working-with-blob-data-at-101-arcpyda.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://anothergisblog.blogspot.nl/2012/06/working-with-blob-data-at-101-arcpyda.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:47:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-load-image-to-raster-attribute-field-with/m-p/442413#M34634</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T19:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to load image to Raster attribute field with python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-load-image-to-raster-attribute-field-with/m-p/442414#M34635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Xander, thanks for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Right now, I'm using ArcGIS 10.2.1, in this release there are many improves to the arcpy library.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then doesn't exist any method to load an image in a &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;RASTER&lt;/SPAN&gt;&lt;SPAN&gt; field with python, may be something similiar how read the image, compressed, and save it in the &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;Raster&lt;/SPAN&gt;&lt;SPAN&gt; field?, because I need to do it for that way. It doesn't matter if I need to switch to a file geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrés Santos&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2014 13:00:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-load-image-to-raster-attribute-field-with/m-p/442414#M34635</guid>
      <dc:creator>AndrésSantos_Lozano</dc:creator>
      <dc:date>2014-05-07T13:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to load image to Raster attribute field with python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-load-image-to-raster-attribute-field-with/m-p/442415#M34636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Andrés,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only way I found to load images into raster fields (not doing it manually as described in Help topic "&lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//003n0000001m000000"&gt;&lt;SPAN style="font-style:italic;"&gt;Adding raster datasets as attributes in a feature class&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;") is using a raster catalog. You can &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00170000008z000000"&gt;create a new raster catalog&lt;/A&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;set Managed By GDB to Yes&lt;/SPAN&gt;&lt;SPAN&gt;) in a file geodatabase and load all the images that you may have stored in a folder with the tool "&lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/Workspace_To_Raster_Catalog/001700000093000000/"&gt;Workspace To Raster Catalog&lt;/A&gt;&lt;SPAN&gt;".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will load all the images into a raster catalog, which is kinda like a table. It also contains a raster field holding the raster. If in the table where you want to load the rasters as attribute, you have a field with the name of the raster, this field can be used to join the raster catalog into the table. Please note the a table or featureclass cannot have more than 1 field of type raster!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After joining the raster catalog the result can be exported to make the join permanent. The output table or featureclass will contain a field called Raster with the actual raster inside.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;Any intent I did with code to load the raster resulted in an error. Since I could not find any documentation on doing this in Python I assume it is not supported.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 May 2014 12:07:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-load-image-to-raster-attribute-field-with/m-p/442415#M34636</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-05-08T12:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to load image to Raster attribute field with python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-load-image-to-raster-attribute-field-with/m-p/442416#M34637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;SPAN style="font-style: italic;"&gt;Any intent I did with code to load the raster resulted in an error. Since I could not find any documentation on doing this in Python I assume it is not supported.&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Xander,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this supported in arcpy for ArcGIS Pro? I'm currently looking for a way to update raster fields in FC table with Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a&amp;nbsp;script that uses the updatecursor to populate a text field with a path to the directory where the rasters are stored. But, what I really need is to update the raster field with the image itself. And apparently you can't use cursors for this. I started a thread the other day:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/thread/231019-raster-fields-not-supported-using-cursors"&gt;https://community.esri.com/thread/231019-raster-fields-not-supported-using-cursors&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Mar 2019 15:46:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-load-image-to-raster-attribute-field-with/m-p/442416#M34637</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2019-03-26T15:46:49Z</dc:date>
    </item>
  </channel>
</rss>

