|
POST
|
I did add print statements but 'None' is being printed. search_feats ={f[0] for f in arcpy.da.SearchCursor(sjpoints,"State_1")}
print(search_feats)
place_dict = {"AL": "Alabama", "Ala": "Alaska", "OR": "Oregen", "Cal": "California", "WA": "Wasington"}
print(place_dict)
with arcpy.da.UpdateCursor(StSele, "State") as upd_cur:
for upd_row in upd_cur:
print(str(upd_row[0]))
upd_row[0] = place_dict.get(upd_row[0], upd_row[0])
print (str(upd_row[0]))
upd_cur.updateRow(upd_row) Print out set([u'OR']) {'OR': 'Oregen'} None None
... View more
03-08-2023
09:53 AM
|
0
|
2
|
1865
|
|
POST
|
Have you added those new values as domain values? Those domains were already there and I didn't not add them as new. I can't delete the domain as i am an editor on this feature class. Part of this snippet of code is ran when one of a few features are selected. If I were to click on that field attribute, I get a list to select from. So is the issue that there is domains?
... View more
03-07-2023
01:40 PM
|
0
|
0
|
1883
|
|
POST
|
I am using the following but I get no error but it doesn't update the "State" field. I've tested this on a different field and it works. The only thing about the "State" field is that it has a domain. Is there something different I have to do in order for this to update the "State" field? Also, this is in Pro. import arcpy, os,sys
## Works in file geodatabase
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r'C:\Temp\Sates.gdb'
StSele = "States"
StStates = 'Statefile'
sjpoints = "In_memory\sjpoints"
arcpy.SpatialJoin_analysis(StSele, StStates, sjpoints)
search_feats ={f[0] for f in arcpy.da.SearchCursor(sjpoints,"State_1")}
print(search_feats)
place_dict = {"AL": "Alabama", "Ala": "Alaska", "OR": "Oregen", "Cal": "California", "WA": "Wasington"}
#print(place_dict)
with arcpy.da.UpdateCursor(StSele, "State") as upd_cur:
for upd_row in upd_cur:
upd_row[0] = place_dict.get(upd_row[0], upd_row[0])
upd_cur.updateRow(upd_row)
... View more
03-07-2023
11:46 AM
|
1
|
9
|
1908
|
|
POST
|
I was given a project with some models that are scheduled. I am trying to figure what project the actual scheduled model resides. It would be nice to right click or hover the scheduled model and see properties with location of where the schedule model is coming from. I know I can hover over the Model Builder view tab will display the model's location and that's great but that doesn't help if you don't know what project that model is coming from. Unless I am totally missing something?
... View more
01-17-2023
02:20 PM
|
0
|
0
|
341
|
|
POST
|
After trying your suggestion but, but after I run the code the zoomed scale changed. I am curious to see how people, if anyone is getting zoomed scale like in Arcmap with Python.
... View more
01-05-2023
11:23 AM
|
0
|
0
|
830
|
|
POST
|
Is there a way to set the scale of the layout view in Pro, similar to ArcMap? For example in Arcmap lyr = arcpy.mapping.ListLayers(mxd, "lyr")[0]
df.extent = lyr.getSelectedExtent()
df.scale = 24000
arcpy.RefreshActiveView()
arcpy.RefreshTOC() In pro I can't seem to get set aprx = arcpy.mp.ArcGISProject("CURRENT")
map = aprx.listMaps()[0]
#lyr = map.listLayers("SUBJECT_PROPERTY")[0]
lyt = aprx.listLayouts("Map")[0]
mf = lyt.listElements("MAPFRAME_ELEMENT")[0]
#mf.camera.setExtent(mf.getLayerExtent(lyr, False, True))
ext = map.defaultCamera.getExtent()
mf.camera.scale *= 1.25 #some how set this to 1:24,000
... View more
12-09-2022
09:39 AM
|
0
|
2
|
939
|
|
POST
|
I need to transfer an entire layers features to another layer. I am trying to use the SearchCursor and InsertCursor to do this( I know I can use append, but I am trying to this way). Both Features have the same fields and same type of geometry, both are polygons. in_features = "FeatureClass"
out_path = = "OtherFeatureClass"
dsc = arcpy.Describe(in_features)
fields = dsc.fields
# List all field names except the OID field
out_fields = [dsc.OIDFieldName, dsc.lengthFieldName, dsc.areaFieldName]
fieldnames = [field.name if field.name != 'Shape' else 'SHAPE@' for field in fields if field.name not in out_fields]
#out_fields = [dsc.OIDFieldName]
#fieldnames = [fields.name for fields in fields if fields.name not in out_fields]
# Create cursors and insert new rows
#
with arcpy.da.SearchCursor(in_features,fieldnames) as sCur:
with arcpy.da.InsertCursor(out_path,fieldnames) as iCur:
for row in sCur:
iCur.insertRow(row)
del sCur I get the following error. iCur.insertRow(row) RuntimeError: Number of parts in shape is incorrect for its geometry type
... View more
11-18-2022
09:55 AM
|
0
|
1
|
798
|
|
POST
|
I have a feature class that I need to concentrate multiple fields into one, but the issue is that some have blanks or nulls. I need Field1, Field2, Field3 concentrated into Field4. The feature class tables looks like this after I run my code below. Field1 Field2 Feild3 Field4 /Blue/ /yellow/ /Blue/none/yellow/ /Red/ /Yellow/ none/Red/Yellow /Purple/ /Pink/ /Purple/Pink/none I need this. If there is a blank or null I don't need it in Field4. Field1 Field2 Feild3 Field4 /Blue/ /yellow/ /Blue/yellow/ /Red/ /Yellow/ /Red/Yellow/ /Purple/ /Pink/ /Purple/Pink/ I have the following code. PTa = "feature class"
with arcpy.da.UpdateCursor(PTa, ['Field1','Field2','Field3','Field4']) as cursor:
for row in cursor:
row[3] = '{} {} {}'.format(row[0],row[1],row[2])
cursor.updateRow(row)
... View more
11-04-2022
10:29 AM
|
0
|
3
|
945
|
|
POST
|
Sorry for the delay, I got caught up. I get the following with what you suggested. ERROR 000539: Traceback (most recent call last): File "<expression>", line 1, in <module> File "<string>", line 3, in calcYear TypeError: strptime() argument 1 must be str, not int I get the following If I do this . WARNING 002858: Certain rows set to NULL due to error while evaluating python expression: File "<string>", line 3, in calcYear calcYear(!Year!) import datetime
def calcYear(strYear):
return datetime.datetime.strptime("{}".format(strYear), '%Y') There is nulls in this field, how do I get past those nulls? import datetime
def calcYear(strYear):
if (strYear == None):
return 0
else:
return datetime.datetime.strptime("{}".format(strYear), '%Y')
... View more
09-27-2022
01:21 PM
|
0
|
1
|
2021
|
|
POST
|
My apologizes for number of responses. So field "Year" has just years, 2015,1997, 2022, etc and is a "text" field. It doesn't have month or days When I replace the "%Y" with "%m/%d/%Y" d1 = datetime.strptime(row[0], "%m/%d/%Y").year I get; ERROR 000539: Traceback (most recent call last): File "<expression>", line 1, in <module> File "<string>", line 11, in calcYear TypeError: strptime() argument 1 must be str, not int Failed to execute If i use the following from datetime import datetime
from datetime import time
import datetime
def calcYear():
fc = "Lyr"
#testdate = '04/25/2015'
with arcpy.da.UpdateCursor(fc,['Year','Year1']) as cursor:
for row in cursor:
if row[0] not in (""," ",None):
d1 = datetime.datetime.strptime("{}".format(row[0]),"%Y").year
return d1
#formattedTime = datetime.datetime.strptime("{}".format(!Year!), "%Y")
#row[1] = d1
#cursor.updateRow(row) I get Value = 1997 the Field "Year1" doesn't get updated I tested this in python window import arcpy
from datetime import datetime
from datetime import time
import datetime
#def calcYear():
fc = "Lyr"
#testdate = '04/25/2015'
with arcpy.da.UpdateCursor(fc,['Year','Year1']) as cursor:
for row in cursor:
if row[0] not in (""," ",None):
d1 = datetime.datetime.strptime("{}".format(row[0]),"%Y").year
print (d1)
#formattedTime = datetime.datetime.strptime("{}".format(!Year!), "%Y")
row[1] = d1
cursor.updateRow(row) I get the year printed 2022 2022 2022 2022 2022 2022 2022 2007 But the field "Year1" doesn't get populated/updated.
... View more
09-20-2022
03:26 PM
|
0
|
3
|
2096
|
|
POST
|
Thanks fro the replay. Tried the following but nothing happens, no print, no error. def calcYear():
fc = "Lyr"
#testdate = '04/25/2015'
with arcpy.da.UpdateCursor(fc,['Year','Year1']) as cursor:
for row in cursor:
if row[0] not in (""," ",None):
d1 = datetime.strptime(row[0],"%Y").year
print(d1) #"{}".formate(d1)
row[1] = d1
cursor.updateRow(row)
... View more
09-20-2022
12:49 PM
|
0
|
5
|
2126
|
|
POST
|
I need to convert a text field "Year1" into a date filed (Year1) with just the year. Field Year is a text field, with just a year date, "2015" and field Year1 is a date field. from datetime import datetime
from datetime import time
import datetime as dt
from time import gmtime, strftime
def calcYear():
fc = "Lyr"
#testdate = '04/25/2015'
with arcpy.da.UpdateCursor(fc,['Year','Year1']) as cursor:
for row in cursor:
if row[0] not in (""," ",None):
d1 = datetime.strptime(datetime.strftime(row[0], "%Y"), "%Y")
row[1] = d1.year
cursor.updateRow(row) I get the following error. I was thinking that line 11 was converting the text into a day(year). ERROR 000539: Traceback (most recent call last): File "<expression>", line 1, in <module> File "<string>", line 11, in calcYear TypeError: descriptor 'strftime' requires a 'datetime.date' object but received a 'int' Failed to execute (Calculate Field
... View more
09-20-2022
11:44 AM
|
0
|
7
|
2142
|
|
POST
|
I was trying to so this in the layout view, THANKS FOR THE REPLY.
... View more
09-07-2022
11:37 AM
|
0
|
0
|
1529
|
|
POST
|
Using Pro I've converted a layers labels to graphics, can they converted graphics be edited, if so how? I know they can be edited if labels are converted to Annotation. I have tried to to edit them in the layout and have tried activating the map frame. This was easily done in Arcmap. Thanks.
... View more
09-07-2022
09:54 AM
|
0
|
2
|
1559
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-01-2024 07:19 AM | |
| 1 | 07-26-2024 09:38 AM | |
| 1 | 01-08-2024 09:44 AM | |
| 1 | 03-07-2023 11:46 AM | |
| 1 | 11-02-2020 08:24 AM |
| Online Status |
Offline
|
| Date Last Visited |
07-14-2025
07:49 AM
|