|
POST
|
ExecuteError: Failed to execute. Parameters are not valid. Error 000728: Field GRE_view.AldermanicDistrict does not exist within table Failed to to execute (CalculateField).
... View more
09-02-2016
11:04 AM
|
0
|
5
|
1541
|
|
POST
|
Darren, I know I am not an efficient python scripter, so bear with me. I have attempted to script it with spatial join. The goal is to calculate the zone of a concern for only the ones that the zone field is null. Both feature classes are in an enterprise environment (the concerns and the zones). Here is what I have so far from testing on a file geodatabase. I am not sure it is joining properly and the field calculator dies. Any suggestions? # import modules
import arcpy
# Set workspaces
workspace = r'C:\ESRITest\GeoReportingSystem\Testing9116\Testing9116.gdb'
outWorkspace = r'C:\ESRITest\GeoReportingSystem\Testing9116\Scratch.gdb'
targetFeatures = r'C:\ESRITest\GeoReportingSystem\Testing9116\Testing9116.gdb\GeoReporting'
joinFeatures = r'C:\ESRITest\GeoReportingSystem\Testing9116\Testing9116.gdb\GRSAldermanic'
outfc = r'C:\ESRITest\GeoReportingSystem\Testing9116\Scratch.gdb\AldermanicSJ'
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(targetFeatures)
fieldmappings.addTable(joinFeatures)
# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "GeoReporting Features", "GRSAldermanic"
arcpy.SpatialJoin_analysis(target_features=targetFeatures, join_features=joinFeatures, out_feature_class=outfc, join_operation="JOIN_ONE_TO_ONE", join_type="KEEP_COMMON", field_mapping=fieldmappings, match_option="INTERSECT", search_radius="", distance_field_name="")
print "Done with Spatial Join"
# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "AldermanicSJ"
arcpy.DeleteField_management(in_table=outfc, drop_field="SpecificConcern;DescriptionOfConcern;ReportingEmail;DateClosed;ConcernStatus;PriorityLevel;PrimaryDepartment;PrimaryContact;PrimaryInformation;DeptLogging;ReportingMethod;FollowUpRequest;FollowUpContactInfo;AldermanicDistrict;ApproriateYN;NUMVOTES;DaysToClose;Match_Addr;Loc_Name;created_user;created_date;last_edited_user;last_edited_date;Address;Visibility;Report_ID;DISTRICTID")
print "Done with Deleting Fields"
arcpy.MakeFeatureLayer_management(outfc, "outfc_view")
arcpy.MakeFeatureLayer_management(targetFeatures, "GRE_view")
# arcpy.MakeFeatureLayer_management(targetFeatures, "GRE_view")
arcpy.AddJoin_management("GRE_view", "ConcernID", "outfc_view", "ConcernID")
print "Joined Up Sir"
fieldName1 = "GRE_view.AldermanicDistrict"
fieldName2 = "!outfc_view.NAME!"
# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "GeoReporting Features"
arcpy.CalculateField_management(in_table=targetFeatures, field=fieldName1, expression=fieldName2, expression_type="PYTHON", code_block="")
print "Field Calculation Done"
arcpy.RemoveJoin_management(in_layer_or_view=targetFeatures)
print "Removed Join"
arcpy.DeleteFeatures_management(outfc)
print "Spatial Join feature class deleted"
... View more
09-02-2016
10:47 AM
|
0
|
7
|
1541
|
|
POST
|
Darren, In my workflow option 3 might be a better an option. Spatial Join produces a whole new feature class as an output, instead of transferring an attribute from a selected polygon to the point features within the selected polygon. Thoughts?
... View more
09-01-2016
02:17 PM
|
0
|
9
|
1541
|
|
POST
|
Ryan, Did you ever find a solution to your question? Which option did you choose?
... View more
09-01-2016
02:00 PM
|
0
|
11
|
1541
|
|
POST
|
Joshua, The idea is to use the Crowdsource reporter app to allow people to place features, and using GeoEvent Processor fire off emails with a concernID within a reasonable amount of time after someone submits something. So short answer, more frequently than not, like every 10 minutes or so, and the dataset will grow over time. From my understanding GeoEvent does not (correct me if I am wrong) does not handle versioned data very well. So the data is not versioned. I researched a bit on sequences and triggers, and that seems like the way to go, and I also found where the original script came from. The link to the script is: arcgis desktop - How to auto increment a field in a feature class? - Geographic Information Systems Stack Exchange. I also found this link where it shows pretty much what I want done: http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server. What I cannot get my head wrap my head around are couple things: - the object ID is useless to attach to or join on because of way ESRI sets up their "locking" of object IDs for editing. - Basically, each entry has to be has to be on its own merit when creating that concern ID. - Attribute assistant isn't that just a desktop tool? So I am kind of at loss here on how to proceed. Thoughts?
... View more
08-26-2016
01:08 PM
|
0
|
3
|
1404
|
|
POST
|
I tested it. It works. I am trying to get it to be "smarter" where it builds on the highest number value rather than what the picture shows. It rewrites when there is a "gap" in OIDs. I would like to keep it so that the highest number regardless of what was deleted before it is the starting point to add 1 to the count to generate the new Concern ID.
... View more
08-25-2016
02:34 PM
|
0
|
0
|
1639
|
|
POST
|
08-25-2016
02:27 PM
|
0
|
1
|
1639
|
|
POST
|
I know what it does. Basically, it uses a field with a prefix letter that is the default value. It then goes sorts the objectID and then adds calculates an ID based on the next value. It works for what it is designed to do. However, it "starts" over from the deletion point and rewrites going forward. What I am aiming for is to generate what it outputs, but not have it start over from a deleted value.
... View more
08-25-2016
02:17 PM
|
0
|
0
|
1639
|
|
POST
|
import arcpy
# Create update cursor for feature class
fc = r'C:\Requests\Test\Seq.gdb\GeoReportingManagement\GeoReporting'
fields = "ConcernPrefix; Point; ConcernID"
sort_fields="OBJECTID"
# Workspace is the connection to the database where fc is stored - DMB
workspace = r'C:\Requests\Test\Seq.gdb'
# Starting an Edit Session - DMB
edit = arcpy.da.Editor(workspace)
edit.startEditing(False, True)
edit.startOperation()
rows = arcpy.UpdateCursor(fc, fields=fields, sort_fields=sort_fields)
previousPoint = None
i = 0
for row in rows:
munic = row.getValue('ConcernPrefix')
# point = row.getValue('Point')
if not previousPoint:
i += 1
elif previousPoint <> point:
i = 1
else:
i += 1
row.setValue('ConcernID','-'.join([str(munic),str(i)]))
# previousPoint = point
rows.updateRow(row)
# Closing the Edit Session - DMB
edit.stopOperation()
edit.stopEditing(True)
... View more
08-25-2016
02:07 PM
|
0
|
4
|
1639
|
|
POST
|
I what i am trying to accomplish is a script that generates a concern ID that is based on a the last highest number that will run as a scheduled task. An example would be C100, C101, (C102, C103, and C104 were deleted), C105 where the next ID would be C106 and not overwrite C105 as C102 and continue to C103. I found main part of this code somewhere, and I like how it concatenates a letter along with a number. I am up for adding fields that store a number and then concatenates the final ID later, or whatever it takes so long as it quick. Example would be: ConcernID, PrefixCode, LastNumber (all fields used in script). PrefixCode would be a default value of C and the LastNumber field would hold the number portion, and combine them to form the ConcernID. This will be eventually used with an enterprise geodatabase feature class. Any suggestions would be greatly appreciated. import arcpy
# Create update cursor for feature class
fc = r'C:\Requests\Test\Seq.gdb\GeoReportingManagement\GeoReporting'
fields = "ConcernPrefix; Point; ConcernID"
sort_fields="OBJECTID"
# Workspace is the connection to the database where fc is stored - DMB
workspace = r'C:\Requests\Test\Seq.gdb'
# Starting an Edit Session - DMB
edit = arcpy.da.Editor(workspace)
edit.startEditing(False, True)
edit.startOperation()
rows = arcpy.UpdateCursor(fc, fields=fields, sort_fields=sort_fields)
previousPoint = None
i = 0
for row in rows:
munic = row.getValue('ConcernPrefix')
# point = row.getValue('Point')
if not previousPoint:
i += 1
elif previousPoint <> point:
i = 1
else:
i += 1
row.setValue('ConcernID','-'.join([str(munic),str(i)]))
# previousPoint = point
rows.updateRow(row)
# Closing the Edit Session - DMB
edit.stopOperation()
edit.stopEditing(True)
... View more
08-25-2016
01:56 PM
|
0
|
16
|
4239
|
|
POST
|
James, I found that very same link, and was reading it over. That is the issue. 32-bit vs 64-bit. I solved it by just telling the task scheduler to fun the 32-bit version. Thanks for your help.
... View more
03-10-2016
01:44 PM
|
2
|
0
|
2050
|
|
POST
|
Chris, Actually it does help. I was digging and digging and I found what both you and James are talking about. It is a 32-bit vs 64-bit issue. What I did to solve the problem was just tell the scheduled task to use the 32-bit version as the program to launch, and pointed it to the .py file. It worked like a charm. Now if I can figure out how to make it use the 32-bit version from inside the script and do a few more things, I will be all set. Thanks both of you for your help, and pointing me in the right direction.
... View more
03-10-2016
01:33 PM
|
0
|
0
|
2050
|
|
POST
|
Hi James, I think it just how it came across in Geonet. I did have it indented. Any other thoughts?
... View more
03-10-2016
12:44 PM
|
0
|
2
|
2050
|
|
POST
|
The goal is run a report via python script periodically via a scheduled task. If there is a better method for scheduling I am all ears, but the crux of my issue is getting the python script to run outside of ArcMap. It runs fine within ArcMap, but as a standalone script it throws errors. Below is my code and an image of what errors it giving me. Any help is much appreciated. import arcpy
import sys
import traceback
mxd = arcpy.mapping.MapDocument(r"C:\ESRITest\NewGeoReportingSystem\GeoReportingGC.mxd")
try:
df = arcpy.mapping.ListDataFrames(mxd)[0]
for lyr in arcpy.mapping.ListLayers(mxd,"",df):
if lyr.name == "Concerns":
arcpy.mapping.ExportReport(lyr,r"C:\ESRITest\NewGeoReportingSystem\GRS_GeneralReport.rlf",r"C:\ESRITest\NewGeoReportingSystem\GeneralReport.pdf")
except arcpy.ExecuteError:
# Get the tool error messages
msgs = arcpy.GetMessages(2)
# Return tool error messages for use with a script tool
arcpy.AddError(msgs)
# Print tool error messages for use in Python/PythonWin
print msgs
except:
# Get the traceback object
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
# Concatenate information together concerning the error into a message string
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
# Return python error messages for use in script tool or Python Window
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
# Print Python error messages for use in Python / Python Window
print pymsg + "\n"
print msgs
finally:
del mxd
... View more
03-10-2016
10:46 AM
|
0
|
7
|
4063
|
| Title | Kudos | Posted |
|---|---|---|
| 5 | 05-30-2023 02:04 PM | |
| 2 | 04-11-2022 02:07 PM | |
| 1 | 10-03-2022 02:28 PM | |
| 1 | 05-05-2021 12:25 PM | |
| 1 | 09-22-2017 01:45 PM |
| Online Status |
Offline
|
| Date Last Visited |
04-03-2024
11:21 AM
|