IDEA
|
Better code - Again Thanks ! // Get map number from mapindex polygon layer var fsMapIndex = FeatureSetByName($datastore,"MapIndex",["MapNumber","ORMapNum","County"]) var fsIntersectMap = Intersects(fsMapIndex,$feature) if (fsIntersectMap == null) return {"errorMessage": "No Map Index Feature Found"} var MapNumber = "None" var ORMAPNum = "None" var County = 99 var intersectarea = 0 for (var f in fsIntersectMap){ var newintersectarea = Area(Intersection($feature,f)) if (newintersectarea > intersectarea){ var MapNumber = f.MapNumber var ORMAPNum = f.ORMAPNum var County = f.County intersectarea = newintersectarea} } return { "result": { "attributes" :{ "MapNumber" : MapNumber, "ORMapNum" : ORMAPNum, "County" : County } } }
... View more
09-25-2023
05:52 AM
|
0
|
0
|
1016
|
IDEA
|
Thanks - that makes sense. Built this off of old code and was just pretty focused on making the area check work.
... View more
09-25-2023
05:43 AM
|
0
|
0
|
1021
|
IDEA
|
The following code uses intersect and gets the largest intersecting polygon to make the assignment. It appears to be an OK workaround. // Get map number from mapindex polygon layer using interesect // Do interesect and county features. var fsMapIndex = FeatureSetByName($datastore,"MapIndex",["MapNumber","ORMapNum","County"]) var fsIntersectMap = Intersects(fsMapIndex,$feature) var MapIndex = first(fsIntersectMap) var intcount = Count(fsIntersectMap) // If no features return error if (MapIndex == null) return {"errorMessage": "No Map Index Feature Found"} if (MapIndex.Mapnumber == null) return {"errorMessage": "MapNumber is empty"} // If count is one then return values if (intcount == 1) return { "result": { "attributes" :{ "MapNumber" : MapIndex.MapNumber, "ORMapNum" : MapIndex.ORMAPNum, "County" : MapIndex.County } } } // if county > 1 (taxlot overlaps mapindex) then // loop thru and keep intersect with largest area. else { var MapNumber = " " var ORMAPNum = " " var County = 0 var intersectarea = 0 for (var f in fsIntersectMap){ var newintersectarea = Area(Intersection($feature,f)) if (newintersectarea > intersectarea){ var MapNumber = f.MapNumber var ORMAPNum = f.ORMAPNum var County = f.County intersectarea = newintersectarea} } return { "result": { "attributes" :{ "MapNumber" : MapNumber, "ORMapNum" : ORMAPNum, "County" : County } } } }
... View more
09-23-2023
05:51 AM
|
0
|
1
|
1038
|
POST
|
Tim (as usual sorry to be so late in responding) The Max_arc_Angle step is not available if the Fit To Segments option is selected. From the documentation.... "This parameter is not available if the Fit to segments option is specified for the Fitting Type parameter."
... View more
08-24-2023
10:22 AM
|
0
|
1
|
1072
|
POST
|
I have completed a bit more testing. I created a tool/python script that allows me to select any layer from my active map. Once selected I can then select any field and value to assign to that field (see attached zip that contains tool and python). What I found is that it appears that the errors ONLY occur with ArcPro Fabric Layers and does NOT happen with other layers in the branched version feature service. Perhaps I am calling the service incorrectly for fabric layers? I will report this to technical services. But, please try out the tool. It should operate on any branched version service. If not the code I uses is: Layer = arcpy.GetParameterAsText(0) FieldName = arcpy.GetParameterAsText(5) Value = arcpy.GetParameterAsText(6) thisProject = arcpy.mp.ArcGISProject("CURRENT") Map= thisProject.activeMap MapLayer = Map.listLayers(Layer)[0] MapLayerDataSource = MapLayer.dataSource lastslash = MapLayerDataSource.rfind("/") WorkSpace = MapLayerDataSource[:lastslash] arcpy.AddMessage("WorkSpace: " + WorkSpace) edit = arcpy.da.Editor(WorkSpace) edit.startEditing(with_undo=False, multiuser_mode=True) edit.startOperation() with arcpy.da.UpdateCursor(MapLayer,[FieldName]) as cursor: for row in cursor: if row[0] != None: arcpy.AddMessage(FieldName + ': ' + row[0]) row[0] = Value arcpy.AddMessage('-- ' + FieldName + ': ' + row[0]) cursor.updateRow(row) # End Edit Session edit.stopOperation() edit.stopEditing(save_changes=True) Thanks I would appreciate any second opinion on this problem.
... View more
08-07-2023
08:47 AM
|
0
|
0
|
1319
|
POST
|
Amir - thanks for checking. This is similar to the issue I reported at the meeting in Redlands (I was using append for that) and BUG-000156383 I worked for a couple of months with user support on the issue and they thought it would be fixed in 11.1. It appears to not be fixed. Tech support had a pretty hard time setting the environment up and then replicating the problem. In addition, the work around reported does not work consistently. I tried to explain that to support but they could not replicate my workaround issues. I developed by own work arounds for my append tool but having the similar issue happen with s simple calculate using update cursor is a whole lot more serious. I was hoping to validate that this is a problem with someone else before again starting the rather complicated interaction with technical support. (explaining the problem, providing them with all of our data, services setup, working with them to customize the tool work in there environment , etc). Again, thanks for checking.
... View more
08-04-2023
06:44 AM
|
0
|
0
|
1333
|
POST
|
The example fits around the entire script but you can use the same concept using python for each step. At the start of the step record your start time: starttime = datetime.datetime.now() At the end of the step record your endtime and calc the difference. endtime = datetime.datetime.now() timepassed = endtime - starttime
... View more
08-03-2023
12:28 PM
|
1
|
1
|
3210
|
POST
|
I am pretty explicit when I do python and I write stuff out to a log file for scheduled jobs. I print results as well as write them to a text file. Is a bit redundant but oh well. Below is the code (I did not include the traceback stuff but that is also pretty easy to add... Here is the code.... import arcpy,os,time,datetime,traceback # Log File - makes my log file and records start time logfile = "C:\\GISLogs\\01APImportAnno.txt" arcpy.Delete_management (logfile) logfile = open(logfile, "w") starttime = datetime.datetime.now() logfile.write ('\n' + '\n' + "StartTime:" + str(starttime) + '\n' + '\n') print ("StartTime:" + str(starttime)) CODE GOES HERE # Time stuff and close of log file endtime = datetime.datetime.now() timepassed = endtime - starttime print ("Run Time: " + str(timepassed)) print ( "Start-End Time: " + str(starttime) + "---" + str(endtime)) logfile.write ('\n' + '\n' + "AnnImport Succesful" + '\n' + '\n' ) logfile.write ('\n' + '\n' + "Run Time: " + str(timepassed) + '\n' + '\n' ) logfile.write ('\n' + '\n' + str(starttime) + "---" + str(endtime)) logfile.close()
... View more
08-03-2023
11:33 AM
|
4
|
0
|
3261
|
POST
|
It has been pointed out to me that this could all be done with an attribute rule and YES it could be. BUT... this problem seems to happen whenever I use the da.editor environment with branched versioning. I selected this example because what cold be simpler then calculating three fields for a selected set of polygons.
... View more
08-03-2023
09:44 AM
|
0
|
0
|
1372
|
POST
|
This issue or similar ones have been previously been reported to ESRI (Esri Case #03242592) by me. I thought it was fixed at 11.x. This was also reported to this group (with no solution) back in 2019 (arcpy.da.Editor Not Working Properly) I am working on a project to develop best practices for migrating a series of tools that run in an ArcPro/Fabric GDB environment to an ArcPro/Fabric branched version environment (ArcProFabric 3.1+/Enterprise 11.1+). I am running into a consistently inconsistent problem with converting my Scripts/tools. Attached is a zip file the contains a toolbox with the tool (UpdateCogoArea) and associated python script (UpdateCoGoArea.py). For selected taxlots this tool calculates two attributes (TaxlotFeet/TaxlotAcre) from the CalculatedArea field and calculates the MapAcres field from the Shape_Area field. It’s a simple calculation and the three attributes are required for our state standard. Tool Requirements: ActiveBranchVersion, Selected Taxlots (Fabric) with the CalculatedArea field and the three required fields ('TaxlotAcre',"TaxlotFeet",'MapAcre’) all numeric/double. You can run this tool on your data if you add the fields and change the reference to your parcel fabric layer. Options: Within the python script you can change how the tool runs. It can either use the CalculateFields tool or use “arcpy.da.Editor” with an update cursor. (Line 42/43) In the script (useCalcFields = True or False.) Issues: The CalcFields Option works great. I do not set the edit environment etc. The UpdateCusor option causes strange results. When you run it a) the attributes are not updated (however if you open and close the session) they will be. b) if you spatially select the polygons and try to look at the attributes the table will come up with two records selected but you will NOT be able to see them (unless you open and close the project). My Question? Am I referencing the versioned workspace incorrectly? (I display the version and workspace as part of the script messages) Am I using the UpdateCursor with the arcpy.da.Editor incorrectly ? Is there a problem with our services or the software ? To Test: Add the three fields ('TaxlotAcre',"TaxlotFeet",'MapAcre’) to your ParcelFabric parceltype. Edit the UpdateCogoArea script and tool to reference YOUR parcel fabric layer (my layer is called Taxlot) make sure the python script has useCalcFields = false (line 43). This will run the tool using the da.editor and update cursor option. Open the project, select a couple fabric polygons (with calculatedarea populated) and run the tool (messages are below). See if the calcs worked, with the table open spatially select your polygons again – Note if the fields are updated and attributes updated. Close and re-open the project. Does this look and act as expected ? Select the polygons and calculate the three fields equal to zero. Close the project. Edit the python script and change useCalcFields = True and save Open the project. Select the polygons and re-run the tool. Review the results (Everything should operate as expected). For those that do not want to to the test here the two alternative. Again CalculateFields works but UpdateCursor and edit session does not. I have included tool messages for reference after the following code. # -------- This works --------- if useCalcFields: arcpy.management.CalculateFields(mapTaxlotLyr, "Python3",[["TaxlotAcre", "round(!CalculatedArea! / 43560,2)"],["TaxlotFeet", "round(!CalculatedArea!,2)"],["MapAcres", "round(!Shape__Area! / 43560,2)"]]) arcpy.AddMessage('Used CalcFields') sys.exit('Calcone') # ----------- This does NOT work ---------- # get workspace and version thisProject = arcpy.mp.ArcGISProject("CURRENT") Map= thisProject.activeMap mapTaxlotLyr = Map.listLayers("Taxlot")[1] # set data source and version (Not Needed for "CalcFields" but used with edit session) MapLayerDataSource = mapTaxlotLyr.dataSource lastslash = MapLayerDataSource.rfind("/") WorkSpace = MapLayerDataSource[:lastslash] arcpy.AddMessage("WorkSpace: " + WorkSpace) AfterVEq = MapLayerDataSource.rfind("VERSION=") + 8 Version = MapLayerDataSource[AfterVEq:] BeforeVID = Version.rfind(";") Version = Version[:BeforeVID] arcpy.AddMessage ("Version: " + str(Version)) # Do the edit edit = arcpy.da.Editor(WorkSpace) edit.startEditing(with_undo=False, multiuser_mode=True) edit.startOperation() with arcpy.da.UpdateCursor(mapTaxlotLyr,['CalculatedArea','shape__Area','TaxlotAcre',"TaxlotFeet",'MapAcres','Taxlot']) as cursor: for row in cursor: row[2] = 0 row[3] = 0 row[4] = 0 if row[0] != None: row[2] = round(row[0] / 43560,2) row[3] = round(row[0],2) if row[1]!= None: row[4] = round(row[1] / 43560,2) arcpy.AddMessage('Taxlot: ' + row[5]) arcpy.AddMessage('TaxlotAcre: ' + str(row[2])) arcpy.AddMessage('TaxlotFeet: ' + str(row[3])) arcpy.AddMessage('MapAcre: ' + str(row[4])) cursor.updateRow(row) # End Edit Session edit.stopOperation() edit.stopEditing(save_changes=True) Below are my messages referencing the version and versioned workspace... I would VERY much appreciate ANY Help. Thanks
... View more
08-03-2023
09:36 AM
|
0
|
4
|
1379
|
POST
|
I am working with a new taxlot dataset that requires building the fabric from just polygons (which is new to me). I am following the documented recommendation to use "SimplifyByStraightLinesAndCircularArcs" (without it I end up creating WAY to many lines). In some cases the conversion converts lines to curves that I do not think should be converted and it is a problem. I have changed the parameters for max_offset, max_arc_angle_step, min_arc_angle, and min_vertex_count to MANY alternatives. Some of the silly (see below) and some push the options to extremes. But the changes do not seem to impact the outcome. For example, you would think a max offset of .01 would mean lines would not deviate from the original by more the .01 (or so). But that is not the case and it appears I get offsets close to .1. arcpy.edit.SimplifyByStraightLinesAndCircularArcs( in_features=OutClassTxLtPly, max_offset="0.01 Feet", fitting_type="FIT_TO_VERTICES", circular_arcs="CREATE", max_arc_angle_step=2, min_vertex_count=4, min_radius=None, max_radius=None, min_arc_angle=2, closed_ends="PRESERVE", anchor_points=None ) The taxlot dataset I am converting is pretty typical and contains rural and urban maps. My question is... Is there a best practice or are there recommended options (besides using the defaults) for running this tool on parcels to create an optimal result ???
... View more
07-03-2023
03:07 PM
|
0
|
3
|
1722
|
POST
|
Not sure, but I have found in 3.11 that when things run VERY slow when using a file geodatabase (not enterprise service), running compact on the database makes a HUGE difference.
... View more
04-27-2023
01:52 PM
|
0
|
0
|
870
|
POST
|
We had similar issues and selected our published "TAXMAP" as our record. Taxmaps are either section, quarter section or quarter/quarter section areas (approximately) and represent a published map. We used these as our default record. It works pretty well. The are an attribute of the taxlot polygons so it was easy to create records for them. Unfortunately, our pre-existing linework did not have a record. I used to following to associate the converted lines with the record: Create a new temp feature class by intersecting the converted lines with the record polygons (only keep the featuerids) Do a double join to join line work with the records Calc the creatdby record in linework to be equal to the record guiid. This seems to work pretty well. Obviously the result makes sure every line has a record but lines on the border are going to go one record or the other - but who cares. (See attached code snippet)
... View more
04-27-2023
01:48 PM
|
1
|
0
|
1799
|
POST
|
I have an issue with cleaning up after my conversion process. I am using 2.9X ArcPro. I have many multi-part taxlots in ArcMap and need these to persist in ArcPro/Fabric. I have good line attributes and want to build my taxlot parcel polygons from my good line attributes. (I understand the limitations of this and address it in my conversion process) Here is the part of my process that is generating the problem. Convert ArcMap taxlotlines to ArcPro Fabric Taxlot_lines (works as expected - uses esri tool etc...) Split the arcmap taxlot polygons into multipart ArcPro polygons (works as expected) Generate points (polygon centroids) from the new multi-part ArcPro polygons (works as expected) Create New ArcPro Polygons for converted ArcPro Taxlot_lines & New Points (works as expected) Use Dissolve (or pairwise dissolve) to re-created multi-part polygons (Problem - Dissolve generates a small number number of tiny slivers - see below). Dissolve has no tolerance and it does not matter what option I use. Dissolve just seems to do this. The rest of my process works as expected Question: What is the best way to get rid of these slivers in 2.9? When I build parcels from my polygons the slivers at duplicate lines or "near duplicate lines" in my taxlot_lines feature class. My fabric has less then 20,000 polygons. Due to upgrade issues with servers my folks will NOT be able to upgrade to 3.x / 11.x for quite some time.
... View more
04-27-2023
09:46 AM
|
0
|
0
|
620
|
POST
|
For it appear in the Web Service fabric it has to published as an expression as part of the service. It cannot be created post publishing. Not sure I follow. I am just moving this rule over to a branched service environment as setup by my Enterprise Admin Folks (11.X/3.11. The relationship classes are not visible in the portal but they are working because I can select all features associated with a record and it works. Are you saying that the relationship classes must be explicitly published (so I can see them in portal)?
... View more
04-25-2023
03:15 PM
|
1
|
0
|
1279
|
Title | Kudos | Posted |
---|---|---|
1 | 02-05-2025 06:39 AM | |
1 | 06-10-2024 10:15 AM | |
1 | 06-10-2024 05:19 AM | |
1 | 06-05-2024 11:55 AM | |
1 | 11-14-2022 05:13 AM |
Online Status |
Offline
|
Date Last Visited |
04-02-2025
10:45 AM
|