<?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 UpdateCursor takes no arguments in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216651#M65692</link>
    <description>&lt;P&gt;Hello, I have been trying to fill a shapefile with EXIF data from pictures taken by a drone.&lt;/P&gt;&lt;P&gt;I was able to create the shapefile and the desired fields in the attribute table, but I failed to populate the fields with the data. The script below always returns UpdateCursor() takes no arguments.&lt;/P&gt;&lt;P&gt;As I wrote this script with the input from other people on the internet (suggestions and actual scripts), I have no idea what to do next and how to resolve this issue. I welcome any advice and will appreciate the help.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os
import arcpy
from pathlib import Path

IMAGE_FOLDER = Path(
    r"\\...\InspectionServicesData\DRONE_INSPECTION_SERVICE\01_Projects\...\2_FIELD-WORK\DATA-DUMP\2022-08-13...\DJI_202208131356_022")

img_path = r"\\...\InspectionServicesData\DRONE_INSPECTION_SERVICE\01_Projects\...\2_FIELD-WORK\DATA-DUMP\2022-08-13...\DJI_202208131356_022"
image_path = os.listdir(img_path)

for img in image_path:
    full_image_path = os.path.join(img_path, img)

exif_properties = {}
output_shpdata = r"C:\Users\...\OneDrive...\Desktop\EXIF_TEST\output_shpdata.shp"
shp_data = []
spatial_ref = arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(4326)


for image in IMAGE_FOLDER.glob("*.jpg"):
    exif_properties[image.name] = arcpy.GetImageEXIFProperties(image)

for name in exif_properties:
    target_data = exif_properties[name][3]
    root_path = r"\\...\InspectionServicesData\DRONE_INSPECTION_SERVICE\01_Projects\...\2_FIELD-WORK\DATA-DUMP\2022-08-13..."
    full_path = "".join([root_path, "\\", name])
    targlong = target_data['XMP:drone-dji:LRFTargetLon']
    tarlat = target_data['XMP:drone-dji:LRFTargetLat']
    tardist = target_data['XMP:drone-dji:LRFTargetDistance']
    gimbalyaw = target_data['XMP:drone-dji:GimbalYawDegree']

    shp_data.append([name, tardist, gimbalyaw, full_path, targlong, tarlat])

def output_shpdata_creator():

    pt = arcpy.Point()
    ptGeoms = []

    for p in shp_data:
        pt.X = p[4]
        pt.Y = p[5]

        ptGeoms.append(arcpy.PointGeometry(pt, spatial_ref))

    arcpy.CopyFeatures_management(ptGeoms, output_shpdata)
    arcpy.AddField_management(output_shpdata, "Name", "TEXT", 9, "", "", "refcode", "NULLABLE", "REQUIRED")
    arcpy.AddField_management(output_shpdata, "Distance", "DOUBLE", 9, "", "", "refcode", "NULLABLE", "REQUIRED")
    arcpy.AddField_management(output_shpdata, "YawDegree", "FLOAT", 9, "", "", "refcode", "NULLABLE", "REQUIRED")
    arcpy.AddField_management(output_shpdata, "ImagePath", "TEXT", 9, "", "", "refcode", "NULLABLE", "REQUIRED")
    arcpy.AddXY_management(output_shpdata)

    count = 0

    with arcpy.da.UpdateCursor(output_shpdata, ['Name', 'Distance', 'YawDegree', 'ImagePath']) as cursor:
        for r in cursor:
            r[0] = shp_data[count][0]
            r[1] = shp_data[count][1]
            r[2] = shp_data[count][2]
            r[3] = shp_data[count][3]

            cursor.updateRow(r)

            count += 1

print(shp_data)
output_shpdata_creator()&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 27 Sep 2022 19:40:06 GMT</pubDate>
    <dc:creator>RudyJamet</dc:creator>
    <dc:date>2022-09-27T19:40:06Z</dc:date>
    <item>
      <title>UpdateCursor takes no arguments</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216651#M65692</link>
      <description>&lt;P&gt;Hello, I have been trying to fill a shapefile with EXIF data from pictures taken by a drone.&lt;/P&gt;&lt;P&gt;I was able to create the shapefile and the desired fields in the attribute table, but I failed to populate the fields with the data. The script below always returns UpdateCursor() takes no arguments.&lt;/P&gt;&lt;P&gt;As I wrote this script with the input from other people on the internet (suggestions and actual scripts), I have no idea what to do next and how to resolve this issue. I welcome any advice and will appreciate the help.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os
import arcpy
from pathlib import Path

IMAGE_FOLDER = Path(
    r"\\...\InspectionServicesData\DRONE_INSPECTION_SERVICE\01_Projects\...\2_FIELD-WORK\DATA-DUMP\2022-08-13...\DJI_202208131356_022")

img_path = r"\\...\InspectionServicesData\DRONE_INSPECTION_SERVICE\01_Projects\...\2_FIELD-WORK\DATA-DUMP\2022-08-13...\DJI_202208131356_022"
image_path = os.listdir(img_path)

for img in image_path:
    full_image_path = os.path.join(img_path, img)

exif_properties = {}
output_shpdata = r"C:\Users\...\OneDrive...\Desktop\EXIF_TEST\output_shpdata.shp"
shp_data = []
spatial_ref = arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(4326)


for image in IMAGE_FOLDER.glob("*.jpg"):
    exif_properties[image.name] = arcpy.GetImageEXIFProperties(image)

for name in exif_properties:
    target_data = exif_properties[name][3]
    root_path = r"\\...\InspectionServicesData\DRONE_INSPECTION_SERVICE\01_Projects\...\2_FIELD-WORK\DATA-DUMP\2022-08-13..."
    full_path = "".join([root_path, "\\", name])
    targlong = target_data['XMP:drone-dji:LRFTargetLon']
    tarlat = target_data['XMP:drone-dji:LRFTargetLat']
    tardist = target_data['XMP:drone-dji:LRFTargetDistance']
    gimbalyaw = target_data['XMP:drone-dji:GimbalYawDegree']

    shp_data.append([name, tardist, gimbalyaw, full_path, targlong, tarlat])

def output_shpdata_creator():

    pt = arcpy.Point()
    ptGeoms = []

    for p in shp_data:
        pt.X = p[4]
        pt.Y = p[5]

        ptGeoms.append(arcpy.PointGeometry(pt, spatial_ref))

    arcpy.CopyFeatures_management(ptGeoms, output_shpdata)
    arcpy.AddField_management(output_shpdata, "Name", "TEXT", 9, "", "", "refcode", "NULLABLE", "REQUIRED")
    arcpy.AddField_management(output_shpdata, "Distance", "DOUBLE", 9, "", "", "refcode", "NULLABLE", "REQUIRED")
    arcpy.AddField_management(output_shpdata, "YawDegree", "FLOAT", 9, "", "", "refcode", "NULLABLE", "REQUIRED")
    arcpy.AddField_management(output_shpdata, "ImagePath", "TEXT", 9, "", "", "refcode", "NULLABLE", "REQUIRED")
    arcpy.AddXY_management(output_shpdata)

    count = 0

    with arcpy.da.UpdateCursor(output_shpdata, ['Name', 'Distance', 'YawDegree', 'ImagePath']) as cursor:
        for r in cursor:
            r[0] = shp_data[count][0]
            r[1] = shp_data[count][1]
            r[2] = shp_data[count][2]
            r[3] = shp_data[count][3]

            cursor.updateRow(r)

            count += 1

print(shp_data)
output_shpdata_creator()&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 27 Sep 2022 19:40:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216651#M65692</guid>
      <dc:creator>RudyJamet</dc:creator>
      <dc:date>2022-09-27T19:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor takes no arguments</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216666#M65693</link>
      <description>&lt;P&gt;It would help if you used the code formatter (click the ..., then the &amp;lt;/&amp;gt; icon to open the window to paste your code)&lt;/P&gt;&lt;P&gt;I would move the pt = arcpy.Point() under the for p in shp_data: loop.&amp;nbsp; With it being outside of the loop, each iteration is using the same pt and it can be messing things up referencing the same object.&lt;/P&gt;&lt;P&gt;The shapefile gets created with fields, but do the points make it into the fc?&amp;nbsp; You might have an empty shapefile and nothing for the updateRow() to update.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 18:37:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216666#M65693</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-09-27T18:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor takes no arguments</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216669#M65694</link>
      <description>&lt;P&gt;It's very hard to read your script in plain text. Please post it formatted as code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1664303901166.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52321iF1B8C4C1E1B87D97/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1664303901166.png" alt="JohannesLindner_0-1664303901166.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1664303911535.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52322i3E1F64AB9810302F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1664303911535.png" alt="JohannesLindner_1-1664303911535.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 18:38:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216669#M65694</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-09-27T18:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor takes no arguments</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216702#M65696</link>
      <description>&lt;P&gt;Thanks Johannes for the tip. I had no idea.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 19:40:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216702#M65696</guid>
      <dc:creator>RudyJamet</dc:creator>
      <dc:date>2022-09-27T19:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor takes no arguments</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216709#M65697</link>
      <description>&lt;P&gt;Hi Jeff, thanks for your reply. The points are created as well, maybe thanks to the function arcpy.AddXY_mangement. I mean, the attribute table shows the long/lat coordinates for all records, and all records/points are displayed. The other fields are empty.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 19:51:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216709#M65697</guid>
      <dc:creator>RudyJamet</dc:creator>
      <dc:date>2022-09-27T19:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor takes no arguments</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216771#M65699</link>
      <description>&lt;P&gt;and if you need a bookmark for formatting&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 22:13:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216771#M65699</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-09-27T22:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor takes no arguments</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216887#M65701</link>
      <description>&lt;P&gt;Hmmm. I couldn't reproduce your error, and I have no idea what could cause it, the UpdateCursor part is OK.&lt;/P&gt;&lt;P&gt;General tips:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;your lines 8-12 don't do anything&lt;/LI&gt;&lt;LI&gt;you use 4 for loops (lines 20, 23, 39, 55) that basically loop over the same data. you can just do it in 1.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Try using InsertCursor instead:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
from pathlib import Path

IMAGE_FOLDER = Path(r"\\...\InspectionServicesData\DRONE_INSPECTION_SERVICE\01_Projects\...\2_FIELD-WORK\DATA-DUMP\2022-08-13...\DJI_202208131356_022")

output_path = r"C:\Users\...\OneDrive...\Desktop\EXIF_TEST\"
output_name = "output_shpdata.shp"
spatial_ref = arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(4326)

# create the ouput shape file and add fields
out_shp = arcpy.management.CreateFeatureclass(output_path, output_name, "POINT", spatial_reference=spatial_ref)
arcpy.management.AddField(out_shp, "Name", "TEXT")
arcpy.management.AddField(out_shp, "Distance", "DOUBLE")
arcpy.management.AddField(out_shp, "YawDegree", "FLOAT")
arcpy.management.AddField(out_shp, "ImagePath", "TEXT")
arcpy.management.AddField(out_shp, "Long", "DOUBLE")
arcpy.management.AddField(out_shp, "Lat", "DOUBLE")

# start the InsertCursor
with arcpy.da.InsertCursor(out_shp, ["SHAPE@", "Name", "Distance", "YawDegree", "ImagePath", "Long", "Lat"]) as cursor:
    # loop through the image files
    for image in IMAGE_FOLDER.glob("*.jpg"):
        # extract exif properties
        target_data = arcpy.GetImageEXIFProperties(image)[3]
        long = target_data['XMP:drone-dji:LRFTargetLon']
        lat = target_data['XMP:drone-dji:LRFTargetLat']
        dist = target_data['XMP:drone-dji:LRFTargetDistance']
        gimbalyaw = target_data['XMP:drone-dji:GimbalYawDegree']
        # create the point geometry
        geo_wgs84 = arcpy.PointGeometry(arcpy.Point(long, lat), arcpy.SpatialReference(4326))
        geo = geo_wgs84.projectAs(spatial_ref)
        # insert the values
        row = [geo, image.name, dist, gimbalyaw, str(image), long, lat]
        cursor.insertRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 10:41:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1216887#M65701</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-09-28T10:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor takes no arguments</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1217044#M65707</link>
      <description>&lt;P&gt;It works perfectly! Thanks a lot Johannes, you made my day.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 17:46:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1217044#M65707</guid>
      <dc:creator>RudyJamet</dc:creator>
      <dc:date>2022-09-28T17:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor takes no arguments</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1220032#M65791</link>
      <description>&lt;P&gt;Just another question. I am trying to convert the Python script into a geoprocessing script in ArcGIS Pro. Ideally, it would contain parameters for the user to fill in, like Image Folder and Destination Folder. In the Python script, the parameters would be linked to IMAGE_FOLDER, output_path and output_name. I don't know how to do that.&lt;/P&gt;&lt;P&gt;Also, I thought the result of the geoprocessing would be automatically added to the Contents pane, but it doesn't, even though in Options\Geoprocessing the Add output datasets to an open map is checked.&lt;/P&gt;&lt;P&gt;If you have some suggestions, I would appreciate. Thanks Johannes.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 20:01:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-takes-no-arguments/m-p/1220032#M65791</guid>
      <dc:creator>RudyJamet</dc:creator>
      <dc:date>2022-10-07T20:01:34Z</dc:date>
    </item>
  </channel>
</rss>

