|
POST
|
* Edit: I like BlakeTerhune's reply! That's better than my idea. * That's great that you're trying out cursors! When you say "each row in a field," by "row" do you mean feature/record, and by "field" do you mean an actual field/attribute? I ask because usually with cursors, the word "row" can be a variable that might refer to attributes of one feature/record, in certain forms of syntax. Just wanting to make sure I understand what you're getting at. Say you are wanting to assign those values in your list to three separate features/records in your table. One way to achieve what you mentioned is to use a counter. There might be a better way to do it; I'm experienced but not an expert. Just keep in mind that the first item in your list is index number 0, of course. Also keep in mind that which value gets applied to which record in your table depends on how the table is sorted when you run your code. It does not necessarily run in order of ObjectID's. I'm not sure what the scenario could be where you are doing what you're describing - maybe it would help if you explain that. Here's an example of using a counter: import arcpy
arcpy.env.workspace = r"path\to\geodatabase"
fc = "fc_name"
field = "fieldname"
valuelist = ["a", "b", "e", "z"] # Values to be inserted
with arcpy.da.UpdateCursor(fc, field) as cursor:
count = 0 # Starts at zero because list index starts with zero
for row in cursor: # For each record in the table:
# This is supposed to prevent the following line from erroring
# out if count exceeds the length of the list
while count < len(valuelist):
# Assign value from the valuelist to the record in the table
row = valuelist[count]
# Increment count to select next valuelist item next time
count += 1
cursor.updateRow(row)
... View more
11-01-2023
11:39 AM
|
1
|
0
|
2103
|
|
IDEA
|
Create a way to change a feature's color to another color from the selected color palette / color scheme when using Unique Values symbology. I am working with a polygon feature class and using Unique Values to make each polygon visually distinct, like on classic political maps where each country is a different color. I'm using the "pastel" color scheme. But in some cases, there are so many polygons adjacent to each other (very odd sizes and shapes) that some adjacent polygons are just about the same color. I have to go through and manually change the color of some polygons to make the colors more distinct. It is frustrating that I can only pick colors from the standard ArcGIS color picker, or else create custom colors via RGB, HSV, etc., and I cannot pick from the "pastel" color scheme I selected for the layer's symbology. This is making the layer's symbology look pretty random and unprofessional. It would be a giant help to be able to change a feature's color to another color from the color palette I chose for the layer.
... View more
10-25-2023
11:34 AM
|
12
|
2
|
1535
|
|
POST
|
I came up with a workaround. Instead of using a "where clause," I just added an "if" statement later in the script to exclude records that would have been excluded by the "where clause." Basically, within a Search Cursor, I put lines to this effect: with arcpy.da.SearchCursor(fc, fields) as cursor:
for row in cursor:
# Only include records where APN exists:
if row[0]: # row[0] is the APN
# then do stuff This works, but it would be less clunky to just be able to use a "where clause" in MakeTableView. I'd still be very interested to find out why it doesn't seem to work with the type of table I'm using.
... View more
10-17-2023
04:18 PM
|
0
|
1
|
2098
|
|
POST
|
Later in the script, data from the table view is manipulated - hyphens are inserted between the numbers in the field "APN". This throws an error, because that action can't be done on Nulls. So that means the records where APN is null were mistakenly included in the table view (meaning the Where Clause was ignored). For troubleshooting, I also included a print statement that prints out the APN's of the records included in the table view - print("APN is " + APN). For the records that have a value in the APN field, it prints, but for other records it errors out, saying it can't concatenate string and NoneType. For troubleshooting, I tried running MakeTableView, including a Where Clause, on a geodatabase feature class rather than a SQL Server database table (which was the original data format I was running it on), and the Where Clause worked! So now my theory is that the problem is the data table type. Maybe I will try adding code to my script to first convert the database table into a geodatabase table or something, before doing MakeTableView. That would defeat the purpose of having intermediate products just be in memory, but that could be okay.
... View more
10-12-2023
08:33 AM
|
0
|
0
|
2131
|
|
POST
|
Thank you very much for your suggestion! I tried your suggestions, and sadly, the "where clause" is still being ignored. So weird.
... View more
10-11-2023
03:18 PM
|
0
|
2
|
2145
|
|
POST
|
In a standalone script, I am trying to use arcpy.MakeTableView_management(). I'm including a "where clause" in the parameters in order to include only certain records in the resulting Table View. With the ArcMap arcpy runtime, it worked, but with Pro, the "where clause" gets ignored - it has no effect. It doesn't throw an error; the script just runs into trouble later on because it is trying to work with records that it's not designed to work with. I have tried a variety of different where clauses that target a variety of fields in the source table. None have an effect. I tried manually doing Select by Attributes in Pro (rather than in the script), and that worked fine. I even copied the SQL from the Pro Select by Attributes GUI into my script, but still it had no effect. I can probably come up with a workaround, but this function should work! Or at least I'd like to know why it isn't working. The input table is a SQL Server database table, not from any kind of geodatabase. Here are the relevant lines: (of course my script uses the real names, and bus_lic_tv is used later in the script) import arcpy
arcpy.env.workspace = r"C:\Path\to\Geodatabase.gdb"
table_data = r"C:\Users\adailey\AppData\Roaming\Esri\ArcGISPro\Favorites\DatabaseName.sde\Database.dbo.TableName"
bus_lic_tv = arcpy.MakeTableView_management(table_data, "bus_lic_no_null_apns", where_clause='APN IS NOT NULL') Does anyone know why the "where clause" is being ignored?? Thank you!
... View more
10-10-2023
05:23 PM
|
0
|
6
|
2236
|
|
POST
|
I also got this error, and for me, the solution was this: I had added a new feature class to an enterprise geodatabase in a dataset, and this undid the original settings like making the geodatabase versioned. So I eventually found that I needed to re-enable versioning for this enterprise geodatabase. This solved the problem, and I was then able to edit the feature class.
... View more
09-26-2023
09:38 AM
|
9
|
1
|
5101
|
|
POST
|
How about if you use "Contains the text" instead of "is equal to," in the middle drop-down?
... View more
07-27-2023
02:14 PM
|
1
|
1
|
4622
|
|
POST
|
Hello, I'm not an expert in SQL, but I looked around a little and found something that worked for me when I tested it. It's the last comment on this page: https://ask.sqlservercentral.com/questions/1743/how-to-select-records-with-letters-in-an-nvarchar.html It looks like this in ArcGIS Pro, select by attributes: You could add another clause for lower case, as in the last comment on that website above. I hope that helps!
... View more
07-27-2023
11:34 AM
|
0
|
3
|
4639
|
|
POST
|
I created a new domain for a file geodatabase by using the Create Domain geoprocessing tool. It ran successfully. Then I opened Domains View by right clicking on the file geodatabase > domains. Domains View opened, but the new domain was not listed. In the Catalog pane, I did: right click on file geodatabase > Refresh. I also refreshed the folder that the file geodatabase is in. The domain did not show up in Domains View. Then I closed Domains View and refreshed the folder and file geodatabase again. I re-opened Domains View, but the new domain still did not show up. I waited a few minutes and repeated the process - still nothing. Finally, I closed Pro and reopened my project. Then the domain showed up. Is this a known problem? It would be great if it wasn't that hard. Going forward, I will try creating domains in Domains View, rather than with the geoprocessing tool, and I'm hoping that will work more smoothly.
... View more
07-27-2023
11:17 AM
|
1
|
2
|
1031
|
|
IDEA
|
Good idea! I have a way of doing this with Python, but of course that's a lot more complicated than simply being able to perform a selection. You use an arcpy Update Cursor, add each row's value for that field to a list if the value is not in the list already, and if it is in the list, then you put a value in a different field to indicate that it's a duplicate value. Like, the field could be "Duplicate" and the value you enter for that row would be "yes." Then later you can select all the rows that have "yes." That wouldn't select the first row that had the duplicate value, but I know it would be possible to do that, with different use of the value list or what you put into the "Duplicate" field.
... View more
07-11-2023
11:33 AM
|
0
|
0
|
4324
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-30-2025 03:01 PM | |
| 1 | 09-30-2025 05:42 PM | |
| 1 | 11-01-2023 11:39 AM | |
| 1 | 11-21-2024 04:21 PM | |
| 1 | 08-05-2025 12:29 PM |
| Online Status |
Offline
|
| Date Last Visited |
12-18-2025
12:06 PM
|