|
POST
|
Like @JoeBorgione mentioned below, run the tool from the geoprocessing toolbox (Data Management, Projections and Transformations). You can do the same thing in ArcMap 10.6.1 if you don't have ArcGIS Pro. If you can get it to work there, you can copy the geoprocessing result as a python snippet and paste it into a text editor. This will give you a starting place to work out from.
... View more
12-21-2020
08:35 AM
|
2
|
1
|
3847
|
|
POST
|
Going even further, try simplifying your parameters too. Instead of running it on everything with arcpy.ListFeatureClasses(), just specify one feature class you know should work (meaning it is in NAD_1983). Try different combinations of specifying a projection or using a template, and with or without the transformation.
... View more
12-21-2020
08:07 AM
|
0
|
3
|
3858
|
|
DOC
|
My suggestion @UmarNawaz would be to not delete features, but mark them as "removed" or something with a new column. Users would then update it rather than delete it and they would be hidden from view on the map with a definition query or filter. Then, you could slightly modify this original script to only look at the latest date modified on features with a value of "removed".
... View more
12-21-2020
06:28 AM
|
0
|
0
|
19182
|
|
POST
|
Haha, yeah, we all jumped on this like a pack of hungry wolves pythons.
... View more
12-18-2020
02:01 PM
|
1
|
1
|
3806
|
|
POST
|
I would use rsplit() to ensure you only split once on the last separator. You can use .reverse() to put the last value first, then join it all back together. with arcpy.da.UpdateCursor(Table, ['Fld_1']) as cursor:
for row in cursor:
value_split = row[0].rsplit(", ", 1)
value_split.reverse()
row[0] = " ".join(value_split)
cursor.updateRow(row) Also note: you don't need to del the cursor when using with
... View more
12-18-2020
10:35 AM
|
2
|
0
|
3831
|
|
POST
|
None of my examples using CALL with ArcSDESQLExecute have parameters. The one place I do have parameters, I used cx_Oracle. In my case, the procedure returned a REF CURSOR so I write that data to a CSV file. # Create connection
conn_str = u"{}/{}@{}".format(dbUser, dbPass, dbOracleInstance)
oracle_dbconn = cx_Oracle.connect(conn_str)
# Execute package procedure
cursor = oracle_dbconn.cursor()
ref_cursor = oracle_dbconn.cursor()
procedure = "schema.package.procedurename"
cursor.callproc(procedure, [ref_cursor, input_param])
# Process resulting ref_cursor
if not csv_fields_out:
# Write field name header line
csv_fields_out = [result_column[0] for result_column in ref_cursor.description]
csv_writer.writerow(csv_fields_out)
for data_row in ref_cursor:
# Write data lines
csv_writer.writerow(data_row)
... View more
12-18-2020
07:00 AM
|
0
|
0
|
1005
|
|
POST
|
I've never heard of itertools.dropwhile(). Just another clever tool I'll have to remember for the future!
... View more
12-14-2020
04:52 PM
|
0
|
0
|
3927
|
|
POST
|
Interesting problem. Here's my first thought... import arcpy
import random
row_count = int(arcpy.GetCount_management(fc).getOutput(0))
random_rownum = random.randint(1, row_count)
with arcpy.da.SearchCursor(fc, fields) as cursor:
for rownum, row in enumerate(cursor, start=1):
if rownum >= random_rownum:
# do something
cursor.reset()
for rownum, row in enumerate(cursor, start=1):
if rownum < random_rownum:
# do something
else:
break This isn't ultra efficient so if performance matters and you have many (millions) of rows, this might be a little slower because it's looping over all the rows twice. EDIT: I added a break at the end after finishing the first portion of records so it reduces the extra iteration by half.
... View more
12-14-2020
01:12 PM
|
1
|
1
|
3953
|
|
POST
|
I've come to prefer simply reading the contents of the join table (your CSV) into a dictionary and then looping through each feature class and looking up the field values to calculate. For example, if Model field is your key field, read the data into a dictionary like: csv_values = {
row[3]: {"ID": row[0], "NAME": row[1], "Category": row[2]}
for row in arcpy.da.SearchCursor(csv, ["ID", "NAME", "Category", "Model"])
} So each key is a unique Model (assuming there are no duplicates here) and the value is another dictionary with the other fields. This would let you look up the values like: for fc in fcList:
with arcpy.da.UpdateCursor(fc, ["FILENAME", "ID", "NAME", "Category"]) as u_cursor:
for filename, id, name, category in u_cursor:
csv_record = csv_data.get(filename)
assert csv_record, "No value found for {} filename {} in CSV".format(fc, filename)
id = csv_record["ID"]
name = csv_record["NAME"]
category = csv_record["Category"]
u_cursor.updateRow([filename, id, name, category]) If you have millions of records, this might hog memory.
... View more
12-14-2020
10:05 AM
|
2
|
1
|
1795
|
|
POST
|
I built something similar with SketchViewModel. Here is a sample app that should have most of the pieces you need.
... View more
12-14-2020
08:23 AM
|
0
|
1
|
2243
|
|
POST
|
If I'm understanding your intention correctly, you could query all the features (something like 1=1) then loop through the features in the FeatureSet to display only the ones you want. Here's a sample you could start with.
... View more
12-03-2020
10:17 AM
|
2
|
1
|
2276
|
|
POST
|
I'm assuming it's the path to the oms_span feature class that isn't working? Try changing oms_span = "Blink Outages\\oms_span" to oms_span = "your_geodatabase_path\\oms_span"
... View more
12-01-2020
09:08 AM
|
0
|
5
|
2376
|
|
POST
|
I haven't tested this so there's likely something wrong, but give it a try and let me know how it goes. import arcpy
fc = path_to_fc
# Get list of fields, ignoring ObjectID
# Assumes that all other fields are valid for the separated list values to go
fields = [f.name for f in arcpy.ListFields(fc) if f.type != "OID" or f.name != "OBJECTID"]
# Put the field with the sparated values at the end of the list
# so it's easy to identify.
sep_field = fields.pop(fields.index("test"))
fields.append(sep_field)
with arcpy.da.UpdateCursor(fc, fields) as cursor:
for row in cursor:
# Make list of individual values
# Assumes separators are always a comma (no space).
sep_values = row[-1].split(",")
# Make list of columns to receive values
sep_columns = row[:-1]
for i, value in enumerate(sep_values):
# Put each value into a column.
# Will yield IndexError if there are too many values for the columns.
sep_columns[i] = value
# Any additional columns that don't have a new value
# will retain their original value (if any).
# Put the original separated list of values
# back with the new column values.
row = sep_columns.append(sep_values)
# Update the row in the table
cursor.updateRow(row)
... View more
11-18-2020
03:46 PM
|
2
|
0
|
2701
|
|
POST
|
I see that there can be a variable number of values in the list. Will they always be sequential? In other words, if it skips a column, will there be an empty value? Like a,b,c,,e,f
... View more
11-18-2020
02:00 PM
|
0
|
1
|
2722
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 4 weeks ago | |
| 1 | 10-23-2025 03:53 PM | |
| 1 | 04-28-2026 07:25 AM | |
| 1 | 03-19-2026 08:59 AM | |
| 1 | 02-12-2026 01:37 PM |