|
POST
|
Hi Joe, I am dealing with something similar to the original question from Jeff Thomas. The difference is that instead of copying the selected features, I need to create a new field and add some values to those features. Here's my code: Import arcpy
# Set two geoprocessing environments
arcpy.env.workspace = r"D:\APRX, MXDS\Geo_Engine_Zoning_Project\Austin_Geo_Engine.gdb"
arcpy.env.overwriteOutput = True
# List of fields in Merged_Ovelays FC
fields = ["OBJECTID", "zoning_ove"]
# Convert austin_parcels feature class to feature layer
arcpy.MakeFeatureLayer_management("austin_parcels", "austin_parcels_layer")
# Convert Merged_Overlays feature class to feature layer
arcpy.MakeFeatureLayer_management("Merged_Overlays", "Merged_Overlays_Layer")
# arcpy.da.SearchCursor(in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {sql_clause})
with arcpy.da.SearchCursor("Merged_Overlays_Layer", fields) as cursor:
for row in cursor:
select = "OBJECTID = {}".format(row[0])
# SelectLayerByAttribute(in_layer_or_view, {selection_type}, {where_clause}, {invert_where_clause})
arcpy.management.SelectLayerByAttribute("Merged_Overlays_Layer", "NEW_SELECTION", select)
# SelectLayerByLocation(in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type}, {invert_spatial_relationship})
arcpy.management.SelectLayerByLocation("austin_parcels_layer", "HAVE_THEIR_CENTER_IN", "Merged_Overlays_Layer","","NEW_SELECTION")
# Syntax: AddField(in_table, field_name, field_type, {field_precision}, {field_scale}, {field_length}, {field_alias}, {field_is_nullable}, {field_is_required}, {field_domain})
arcpy.management.AddField('austin_parcels_layer', "Overlay_{}".format(row[1]), "TEXT")
# CalculateField(in_table, field, expression, {expression_type}, {code_block}, {field_type})
arcpy.management.CalculateField("austin_parcels_layer", "Overlay_{}".format(row[1]), '"Overlay_{}".format(row[1])') I am getting the following error and I am not sure how to fix it: Traceback (most recent call last): File "<string>", line 24, in <module> File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 4230, in CalculateField raise e File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 4227, in CalculateField retval = convertArcObjectToPythonObject(gp.CalculateField_management(*gp_fixargs((in_table, field, expression, expression_type, code_block), True))) File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 506, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds. Invalid pointer Failed to execute (CalculateField). Is it something with my line of code that is not working? arcpy.management.CalculateField("austin_parcels_layer", "Overlay_{}".format(row[1]), '"Overlay_{}".format(row[1])') My goal is to: Copy the text from the selected feature below: and put it into the newly created field. I would really appreciate your help, Thank you so much! Natalia
... View more
03-05-2020
03:26 PM
|
0
|
1
|
7816
|
|
POST
|
I am not sure if I understand what you mean... Sorry could you explain further
... View more
11-16-2018
12:09 PM
|
0
|
1
|
2516
|
|
POST
|
That is the table I am joining to the table I want to keep. I guess the join_table. And yes, these parcels are tiny ...
... View more
11-16-2018
11:52 AM
|
0
|
3
|
2516
|
|
POST
|
Joe, I just run a frequency on the parcel ID field and discovered that there are 2 parcel ID repeated twice: Should I delete the ones repeated and leave only 1 per parcel ID and that should solve the problem?
... View more
11-16-2018
10:07 AM
|
0
|
1
|
11098
|
|
POST
|
Joe, There are more parcel IDs on the table I am joining than the one I am joining to. I just don't know why it adds more features.. I am not sure if it is repeating parcel ID's or why is this happening and how do I identify the ones being repeated.
... View more
11-16-2018
09:23 AM
|
0
|
1
|
11098
|
|
POST
|
Dan, This is the attribute table after being exported with the Show field aliases toggle turned off. Things to have in mind: 1. The table being joined has more features than the original table. 2. I just want to keep the number of features on the original. 3. I am using Parcel ID as the unique field.
... View more
11-16-2018
08:52 AM
|
0
|
0
|
11098
|
|
POST
|
This is the file Geodatabase Feature Class Attribute Table with the joined fields already:
... View more
11-15-2018
03:28 PM
|
0
|
0
|
11098
|
|
POST
|
I do not understand your comment. Could you explain a bit more please. Thanks!
... View more
11-15-2018
03:14 PM
|
0
|
2
|
11098
|
|
POST
|
Yes sure! I am actually creating a tutorial and then i will share it here.
... View more
11-15-2018
03:02 PM
|
2
|
1
|
8027
|
|
POST
|
Hello, I am using the Add Join tool to join a File Geodatabase Feature Class attribute table to another File Geodatabase Feature Class using parcel ID as the common field. After the join I end up with more features than the original File Geodatabase Feature Class (Original 245,146, after the join 245,149) and I get this message next to the total number of features in a yellow triangle at the bottom of the attribute table after the join has been made: "You have duplicate OIDs in this table as a result of the join. The selection count is for unique OIDs, the total count is for all rows." (please see attached picture named Add_Join) I tried both with the unchecked "Keep All Target Features" and checking it but both ave me the same result. I used the Copy Features tool to make the join permanent and the extra features were still there. (Please see picture named Export_Features). 1. I would like to identify the extra features that were added with the join and why this is happening. 2. How to avoid this from happening ? Note: I was not having this problem when I was joining shapefile feature classes to file geodatabase feature classes. I cannot keep on doing it this way because it was taking too long (days) to process. I am guessing I was not having this problem with shapefiles because shapefiles use FID instead of OBJECTID? I would appreciate someone to help me with this matter, thanks,
... View more
11-15-2018
02:42 PM
|
1
|
16
|
14506
|
|
POST
|
Adrian I figured it out with very specific steps after trying many times. Thank you so much for your help.
... View more
11-15-2018
02:11 PM
|
0
|
3
|
8027
|
|
POST
|
It is actually on the same server and it ended up finishing sooner than the percentage was telling me. It stayed on 2% and then it was completed after 5 minutes. I also wanted to let you know that I tried the steps you told me yesterday and the time it is taking to export the file has reduced dramatically! Thank you so much!
... View more
11-14-2018
12:22 PM
|
0
|
0
|
580
|
|
POST
|
I am using the Feature Class to Geodatabase tool to move the shapefile into the Geodatabase as a File Geodatabase Feature Class and it is taking too long. Is there another faster way to do this?
... View more
11-14-2018
11:42 AM
|
0
|
1
|
580
|
|
POST
|
ok perfect thank you so much! I really appreciate your help!
... View more
11-13-2018
01:01 PM
|
0
|
0
|
580
|
|
POST
|
Alright will try: 1. Removing the join for one File Geodatabase feature class 2. Then moving the shapefile inside the Geodatabase 3. Add Attribute Indexes to the two fields I am using to create the join. (The common field between the shapefile and the file geodatabase I using to create the join?) Does that sound correct?
... View more
11-13-2018
12:56 PM
|
0
|
1
|
1893
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-15-2018 02:42 PM | |
| 2 | 03-06-2020 09:18 AM | |
| 2 | 11-15-2018 03:02 PM |
| Online Status |
Offline
|
| Date Last Visited |
12-14-2020
03:44 PM
|