|
POST
|
Your right I am on 2.7.14. I figured that I was on 3.6.10 because that the version of the shell I am using. 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] 1.5.2 1.9.3 0.17.0
... View more
09-11-2020
08:13 AM
|
0
|
0
|
2307
|
|
POST
|
I was able to find something that works but it currently only works for one feature at a time, I need it to work with one or 10,20,50. How can I get this to work with with multiple selected features? import arcpy,os
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r'Database Connections\Connection to blah.sde'
ptSelection = "WellPoints"
pointLayer = arcpy.env.workspace + os.sep + "WellPoints"
parcel = 'WellParcels'
sjpoints = "In_memory\sjpoints"
ptCount = int(arcpy.GetCount_management(ptSelection).getOutput(0))
dsc = arcpy.Describe(ptSelection)
selection_set = dsc.FIDSet
if len(selection_set) == 0:
print "There are no features selected"
elif ptCount >= 1:
arcpy.SelectLayerByLocation_management(parcel,"INTERSECT",ptSelection)
arcpy.MakeFeatureLayer_management(parcel,"parcel_lyr")
fldList = ['WellID', 'dept', 'type', ' Geothermal' 'GeoWaterUs', 'Temp', 'TempDate']
fldDict ={}
if int(arcpy.GetCount_management("parcel_lyr").getOutput(0))==1:
for parrow in arcpy.da.SearchCursor("parcel_lyr",fldList):
for w in range(len(fldList)):
fldDict[fldList ]=parrow
del parrow
targetFields = ['W_ID', 'dept', 'type', ' Geothermal' 'GeoWaterUs', 'Temp', 'TempDate']
with arcpy.da.UpdateCursor(ptSelection, targetFields) as cursor:
for row in cursor
row = []
row.append(fldDict['WellID']
row.append(fldDict['dep']
row.append(fldDict['type']
row.append(fldDict['Geothermal']
row.append(fldDict['GeoWaterUs']
row.append(fldDict['Temp']
row.append(fldDict['TempDate']
rows.updateRow(row)
del row
... View more
09-11-2020
08:11 AM
|
0
|
5
|
2307
|
|
POST
|
Got it, thanks. So with arcpy.da.UpdateCursor can on be updated with arcpy.da.Editor. I am trying to do this inside Arcmap with an editor session started but it seems as if i use arcpy.da.UpdateCurosr it won't let me.
... View more
09-10-2020
02:25 PM
|
0
|
1
|
2307
|
|
POST
|
Trying to update some well data from another layer. I am trying to do this in Arcmap (10.6) with a tool/script (3.6.10 Python). I need to transfer attributes from WellParcels to WellsPoints. I would like to do this with out starting a Edit session in python if possible as this tends to slow down the process...? I would manual start an edit session in ArcMap then run the tool/script when I have points selected, I currently have the following but error out on line 44. I am not sure this is the best/fastest way of doing it, so if someone has a different idea please share how I would do this with my data. import arcpy,os
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r'Database Connections\Connection to blah.sde'
ptSelection = "WellPoints"
pointLayer = arcpy.env.workspace + os.sep + "WellPoints"
parcel = 'WellParcels'
sjpoints = "In_memory\sjpoints"
try:
ptCount = int(arcpy.GetCount_management(ptSelection).getOutput(0))
dsc = arcpy.Describe(ptSelection)
selection_set = dsc.FIDSet
if len(selection_set) == 0:
print "There are no features selected"
elif ptCount >= 1:
arcpy.SelectLayerByLocation_management(parcel,"INTERSECT",ptSelection)
arcpy.MakeFeatureLayer_management(parcel,"parcel_lyr")
arcpy.SpatialJoin_analysis(ptSelection, "parcel_lyr" , sjpoints)
#sourceFieldsList = 'WellID', 'dept', 'type', ' Geothermal' 'GeoWaterUs', 'Temp', 'TempDate'
#valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sjpoints, sourceFieldsList)}
fldList = ['WellID', 'dept', 'type', ' Geothermal' 'GeoWaterUs', 'Temp', 'TempDate']
fldDict ={}
print (fldDict)
targetFields = ['W_ID', 'dept', 'type', ' Geothermal' 'GeoWaterUs', 'Temp', 'TempDate']
with arcpy.da.UpdateCursor(ptSelection, targetFields) as cursor:
for row in cursor
row[0] = ['W_ID']
row[1] = ['dep']
row[2] = ['type']
row[3] = ['Geothermal']
row[4] = ['GeoWaterUs']
row[5] = ['Temp']
row[6] = ['TempDate']
#Attributes from Wellparcels
curosr.append(fldDict['Account', 'dept', 'type', ' Geothermal' 'GeoWaterUs', 'Temp', 'TempDate'])
except Exception, e:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
print("Line %i" % tb.tb_lineno)
arcpy.AddMessage("Line %i" % tb.tb_lineno)
print(e.message)
arcpy.AddMessage(e.message)
... View more
09-10-2020
11:06 AM
|
0
|
20
|
5046
|
|
POST
|
After your suggestion I am getting error 000539 invalid syntax expression line 1.
... View more
08-31-2020
01:57 PM
|
0
|
1
|
1512
|
|
POST
|
This worked, although would it be best to do just do it through Calculate field management.
... View more
08-31-2020
01:52 PM
|
0
|
0
|
1512
|
|
POST
|
I have but for some reason it won't work no matter how many spaces(indents) I put in, in line 6 gives me the same error.
... View more
08-31-2020
01:12 PM
|
0
|
0
|
2803
|
|
POST
|
I am getting error 000989. If and else have two indent and the return have 4 indents. Field Calculator import string
nums = string.digits
def conv( WellID , nums):
"""docstring"""
if !WellID! [-2] in nums: # two space indents
return "{} {}".format( !WellID! [1:-2], !WellID! [-1:])#four spaces indents
else: # two space indents
return !WellID! [1:]#four spaces indents Code Block def conv( WellID , nums)
... View more
08-31-2020
10:06 AM
|
0
|
5
|
2803
|
|
POST
|
I am kind of lost on this one because it's not formatted with updatecusror, can you explain what's going on please?
... View more
08-28-2020
01:38 PM
|
0
|
7
|
2803
|
|
POST
|
I am getting error string index out of range on line 5. Also the "_" to " " because i need the space not the underscore. dict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(fc,['WellID','WPin'])}
with arcpy.da.UpdateCursor(fc,['WellID','WPin']) as cursor:
for row in cursor:
if row[0][10] == '0':
#print(row[0][:9]+"_"+row[0][-1:])
row [1] = row[0][:9]+" "+row[0][-1:]
else:
print(row[0])
cursor.updateRow(row)
... View more
08-28-2020
01:36 PM
|
0
|
0
|
2803
|
|
POST
|
Trying to format a field but I am not sure how accomplish it. The trouble I am having is the making the second to last 0 a space but only if there is no alph char. WellPin field is always 10 numbers and sometimes with an alph char. Can someone help me out by showing me how to do this with updatecurosr and in a filed calculator please? Well WPin W1234500000 --> 12345000 0 W1234501000--> 12345010 0 W12345010S0--> 12345010S0 W12345010S1--> 12345010S1 Here what I have so far. import arcpy
arcpy.env.overwriteOutput = True
fc = r"C:\Temp\Wells.shp"
count = 0
def maketv_cursor(fc):
rows = arcpy.SearchCursor(table,"WPin")
count = 0
for row in rows:
count += 1
#print(count)
with arcpy.da.UpdateCursor(fc,['WellID','WPin']) as cursor:
for row in cursor: #if row[0] in (None, "", " "):
row [1] = (row[0][1:11]) # Field Calculator!WellID! [1:11]
cursor.updateRow(row)
... View more
08-28-2020
11:57 AM
|
0
|
16
|
4481
|
|
POST
|
Thanks but after running the code with your suggestion it takes 1.48 min,sec to only select one feature. The following only copies one feature. print, prints 1 over and over 1 1 1 1 arcpy.MakeFeatureLayer_management(fc, 'FcLyr')
#oids = [row[0] for row in arcpy.da.SearchCursor('FcLyr', "OID@")]
with arcpy.da.SearchCursor('FcLyr', ["OID@"]) as selected_fc:
for row in selected_fc:
#print (row)
arcpy.SelectLayerByAttribute_management('FcLyr', "NEW_SELECTION", "OBJECTID_1 = {}".format(str(row[0]))) #"OBJECTID_1 = {}".format(row[0])
result = int(arcpy.GetCount_management('FcLyr').getOutput(0))
print (result)
arcpy.CopyFeatures_management('FcLyr', "C:/Temp/blah/blah.gdb/blah")
... View more
08-24-2020
08:39 AM
|
0
|
1
|
4589
|
|
POST
|
I didn't think of that but I am still curious on how you would do that with selectbyattributes or other ways.
... View more
08-20-2020
03:17 PM
|
1
|
0
|
4589
|
|
POST
|
I am trying to select all the features/attributes of a feature class but I am unable accomplish this, can someone help me out. I have tried the following but i get arcgisscripting.ExecuteError: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute)." on line 6. If this is not the best/easiest way please share what would be. arcpy.MakeFeatureLayer_management(fc, 'FcLyr')
#oids = [row[0] for row in arcpy.da.SearchCursor('FcLyr', "OID@")]
with arcpy.da.SearchCursor('FcLyr', ["OID@"]) as selected_fc:
for row in selected_fc:
print (row)
arcpy.SelectLayerByAttribute_management('FcLyr', "NEW_SELECTION", row[0]) #"OBJECTID = {}".format(row[0])
... View more
08-20-2020
02:19 PM
|
0
|
8
|
4761
|
|
IDEA
|
I was able to figure it out but my zoom is not working, no matter what I change the lvl to 1-20 nothing ever happens, anyone have any idea as to why the lvl doesn't work? "https://www.bing.com/maps?&style=o&lvl=20&dir=0&cp=" + text(Latitude) + "~" + text(Longitude);
... View more
08-18-2020
01:55 PM
|
0
|
0
|
3044
|
| 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 |
02-12-2026
12:36 PM
|