POST
|
***I have corrected both issues mentioned earlier***
... View more
06-16-2020
02:02 PM
|
0
|
0
|
348
|
POST
|
Sorry Joe for the late response. To clarify, I was stuck on one portion of the presented code snippet then got stuck on the next. I have both issues mentioned earlier. I am not sure if I should start a new thread or not for a new error I have though. I figured out how to populate the table with the values i needed. The next step was to "Make Route Events" out of them. The results are interesting: The table population works like I said, containing all values required. However when I attempt to make them into route events, the result shows only 1001 records if between 0 - 2002, and will show 2002 of the records if between 2002 and 4008 records. Simply, I have a table that includes the RouteID field and measure/chainage values from 0 - 2768, when the script runs, it will only show up to the 2002nd measure/chainages. When I run the "Make Route Events" tool outside of the script, everything runs fine, and shows all 2768 records. I have attempted a "Table to table" conversion prior to running the "Make Route Events" however that did not solve my problem. If this requires a new thread please correct me.
... View more
06-16-2020
02:00 PM
|
0
|
1
|
348
|
POST
|
Max_Value is supposed to represent the value stored in the single only row of a polyline feature shape length. To better articulate my point: Polyline feature class attribute table reads value "4263.344" in shape length field. I want to store that value in a variable so that in the next loop I can make a table that populates rows with 2 fields: "RouteID" and "Chainage" RouteID will be used in order to make route events and match the routeID from the original polyline. The Chainage should start at value 0 then append a new row containing the next consecutive integer until it reaches the rounded down version of the stored "Max_Value" (Called_"Max_Round", my variables may not be descriptive enough). Then I want to append the final row with just the "Max_Value". Output table should look like: ROUTEID CHAINAGE Centerline 0 Centerline 1 Centerline 2 Centerline 3 .....continues...... Centerline 4263 Centerline 4263.344 Basically am making meter by meter points along a route, adding coordinates, extracting the elevation from the DEM, resorting and renaming the fields (through "Add XY" tool, automatically calls the fields "POINT X" and "POINT Y" etc. so i just want them renamed for the final step) and final export into an excel worksheet. I have all the other parts working fine, because I stripped them from another tool i made last year. Always getting hung up on the cursors. I'm stuck again trying to determine how to get the code in the table populating loop to work.
... View more
06-04-2020
03:23 PM
|
0
|
0
|
1414
|
POST
|
I got it now guys, I am stuck on another part now but I am certain Ill be able to troubleshoot the rest. I was never great at the Cursors in school and it has now been a while since I have scripted. I am slowly relearning these things. Thank you all for your guidance. The fixed code: # Store value in SHAPE_LENGTH from Route
with arcpy.da.SearchCursor(Route, ['Shape_Length']) as Cursor:
for row in Cursor:
Max_Value = row[0]
del row
del Cursor
... View more
06-04-2020
01:06 PM
|
0
|
1
|
1414
|
POST
|
To answer what Dan had said, I originally had it in that specific format. However I was faced with a different error: AttributeError: 'float' object has no attribute 'getValue' I understand that the Shape_Length field is a 'float' format data type but i am unsure as to why it wont let me store the value to be used later. To respond to Joshua, I believe that your comment aligns with Dan's? To answer Joe, I am aware that the 'row' in a search cursor is returned as a tuple and that it is indexed, hence the approach of what Joe had mentioned. For clarification in regard to your final statement "I'll let you you work on getting the max value...", the prerequisite for the tool I'm developing is a poly-line feature class with 1 row/feature of data, so the Max_Value is just the variable I store it as in order to append it to the table in line 17. Thanks for the feedback guys I really appreciate it.
... View more
06-04-2020
01:02 PM
|
0
|
2
|
1414
|
POST
|
Hello, I am writing a script and a portion of said script requires that I build a table that starts at 0 and increments by 1 until reaching the value of "Shape_Length" from a feature class. I have line work that I wish to read the "Shape_Length" from and I am having troubles getting the syntax correct. Route = arcpy.CreateRoutes_lr(Input_Linework, Linework_Field, Output_Name)
# Store value in SHAPE_LENGTH from Route
with arcpy.da.SearchCursor(Route, ['Shape_Length']) as cursor:
for row in Cursor:
Max_Value = row.getValue('Shape_Length')
del row
del cursor
# Create table with two fields, RouteID and Chainage
Route_Table = arcpy.CreateTable_management(str(Output_WS), Output_Name))
# Append additional rows to table in increments of 1 and end at the exact value of
# the Max_Value
fields = ['RouteID', 'Chainage']
Pop_Table = arcpy.da.InsertCursor(Route_Table, fields)
for x in range(0, Max_Value):
Pop_Table.insertRow(str(Linework_Field), x)
del x I get an error on line 6: AttributeError: 'tuple' object has no attribute 'getValue' I have tried reading through the page: Accessing data using cursors—Help | ArcGIS Desktop I messed around with the code a bit but this is where I am at now and can't determine how to move forward.
... View more
06-04-2020
07:58 AM
|
0
|
12
|
1860
|
POST
|
This was correct. I am just beginning to better familiarize myself with various string manipulation methods, and your comment makes sense although I don't fully understand it. I will research more into working with string methods. Thank you Randy!
... View more
09-03-2019
02:55 PM
|
0
|
1
|
496
|
POST
|
I am using a multivalue field parameter which is supposed to be used in a "keepList" of fields. Script makes a copy of a user defined feature class and deletes all fields from the copy except for required fields and fields from the "keepList". I am not receiving any run errors however, the fields I specify in the parameter don't show in the output feature class. What I have so far: # Appends fields detailed in the user input to keepList
Keep_Fields2 = Keep_Fields.split(";")
for item in Keep_Fields2:
keepList.append(item)
# Deletes unnecesary fields from the Copy_KP
fieldNames = [f.name for f in arcpy.Describe(Copy_KP).Fields if not (f.type in ["OID", "Geometry"] or f.name in ["Shape_Length", "Shape_Area"] or f.name.upper() in keepList)]
if fieldNames:
arcpy.DeleteField_management(Copy_KP, fieldNames) Notes: "Copy_KP" is the copied feature class variable. "Keep_Fields" is the the multivalue field parameter variable. The "keepList" is an empty list '[ ]' (I know this empty list may be redundant, however I have been experimenting with various methods of accomplishing this task). I am going to make the variables more intuitive after I get this thing working.
... View more
09-03-2019
01:23 PM
|
0
|
3
|
544
|
POST
|
Thanks everyone for your input... I used a combination of a few of the things suggested here and added other elements in to the mix. I am now trying to make it so that the user can CHOOSE feilds that they want to keep in the output file. An example of the code now: { Copy_KP = arcpy.GetParameterAsText(#) Keep_Fields = arcpy.GetParameterAsText(#) # Feild parameter, multivalue, obtained from original data source keepList = [] for item in Keep_Fields: keepList.append(item) fieldNames = [f.name for f in arcpy.Describe(Copy_KP).Fields if not (f.type in ["OID", "Geometry"] or f.name in ["Shape_Length", "Shape_Area"] or f.name.upper() in keepList )] if fieldNames: arcpy.DeleteField_management(Copy_KP, fieldNames) } I set the "Keep_Fields" parameter as "Field" type with multivalue enabled. The Keep_Fields part isn't working yet but the fields all delete except the "OID". So at least there is that. I will keep working at it next week. Again, thanks everyone for the help!
... View more
08-29-2019
04:07 PM
|
0
|
0
|
1340
|
POST
|
I just need the required fields for file geodatabases. All non-required fields need to be gone. I now realise that i cannot delete Shape either and that is fine. So keep OID and SHAPE fields. All else needs to be removed. I dont want to hard code it because the input will not be the same fields each time.
... View more
08-29-2019
11:34 AM
|
0
|
3
|
1340
|
POST
|
Ok so yes I only work with file geodatabases when working on anything related to custom built tools. I am aware that the OID and Shape fields are required. I just need to strip away any tabular data and keep the essentials. Did I miss something in what you had suggested?
... View more
08-29-2019
11:32 AM
|
0
|
0
|
1340
|
POST
|
Pretty straight forward. I am building a tool that outputs an Excel file with XYZ data pertaining to a polyline route. Parameters include: Input Points (points have been generated along a line fc every 1 meter) Input DEM Output Location for Excel sheet The tool takes the input points, make a copy, SUPPOSED TO DELETE ALL FIELDS EXCEPT OBJECT ID, uses Add XY tool, then uses Extract Value to get the elevation, and finally exports the table to an Excel file. So the issue is when i am trying to delete all the fields except Object ID. All i get is a runtime error: error executing tool. I have tried many versions of my code to delete the fields. Here is one example: SaveList = ["OBJECTID", "OBJECT_ID", "ObjectID"]
for feild in arcpy.ListFields(Copied_Points):
if feild.name not in SaveList:
arcpy.DeleteField_management(Copied_Points, feild)
del field Any thoughts on how to make this work? Thanks guys/gals.
... View more
08-29-2019
10:31 AM
|
0
|
9
|
1540
|
POST
|
Hello Python Community, I am currently working on a script right now that will generate a table and populate it based off of user defined inputs. The fields include "Measure" and "Offset". These field needs to have row values that increment at a user defined interval. For example, the "Measure" field needs to have a range like (0, 10000, User defined Interval). And for the "Offset" field, it needs to have a range like (0, User defined Max Offset Value, User defined Offset value). I feel like there is a rather simple solution to this that i am totally missing. I already understand the GetParamterAsText portion of the script, however I am trying to make use of the Insert Cursor and I'm not as experienced on the logic side of coding this. I know this is rather vague, but any response could help me. Thanks for your time.
... View more
08-26-2019
11:26 AM
|
0
|
1
|
328
|
POST
|
Hey Joshua thanks for the suggestion, I went through it and found that you were indeed correct! Thanks for the help!
... View more
05-30-2019
01:04 PM
|
0
|
0
|
590
|
POST
|
So this process is way faster than my loop however the results are showing only the closest point to the line segment. Im not sure how i can manipulate this process to give me the answers I need but I will keep trying... Attached are some screenshots. Note: Line segments are overlapping features 100m meters apart (See in image 1, and 2, how there is slight overlap) Image 3 shows the result table called "DWELLINGS_COUNT" and shows the corresponding features selected in the row. (One point seen selected to the right side near the line) I need all points within my search radius listed (to be counted after the fact) Image 4 shows what should be identified and counted
... View more
05-30-2019
11:51 AM
|
0
|
1
|
590
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|