|
POST
|
I have a basic UpdateCursor to update a field value but for some reason the row with "5280" won't update to "1". It only updates the "10560" to "2". it's probably something i am over looking but not sure what's going on. Any help would be great. arcpy.Buffer_analysis(SP, outfile, distance, "OUTSIDE_ONLY", "ROUND", "", "BUFF_DIST")
arcpy.Merge_management(["wp2 Mile","wp1 Mile"], "1_2")
with arcpy.da.UpdateCursor("1_2" , "BUFF_DIST") as cursor:
for row in cursor:
if row[0] == 5280:
row[0] = '1'
elif row[0] == 10560:
row[0] = '2'
cursor.updateRow(row)
del row I have tried else: but i get the same results. with arcpy.da.UpdateCursor("1_2" , "BUFF_DIST") as cursor:
for row in cursor:
if row[0] == 5280:
row[0] = '1'
else:
row[0] = '2'
cursor.updateRow(row)
del row
... View more
09-29-2016
11:05 AM
|
0
|
2
|
1441
|
|
POST
|
Before i posted i did have "LIST" for the dissolve_type. i was trying with out it to see how it behaved and with or without "LIST" as the dissolve_type. With "LIST" it still doesn't' get populated. When i run the tool it runs fine but it is with "one" distance not two. When i ran the tool i used 1 linear unit as miles and i did not use the dissolve type and the field BUFF_LIST got populated with 5280 ft.
... View more
09-26-2016
11:29 AM
|
0
|
0
|
870
|
|
POST
|
The BUFF_DIST field is not being populated and i am not sure why. Can some one explain to me what i am doing wrong please? Current code. import arcpy, os
mxd = arcpy.mapping.MapDocument("CURRENT")
lyr = arcpy.mapping.ListLayers(mxd, "SUBJECT_PROPERTY")[0]
#lyrpath = lyr.workspacePath
arcpy.env.workspace = os.path.dirname(mxd.filePath)
wp = os.path.dirname(mxd.filePath)
try:
SP = "SUBJECT_PROPERTY"
lyr.replaceDataSource(wp, "SHAPEFILE_WORKSPACE", SP, True )
except:
pass
try:
if arcpy.ListFields(SP, "BUFF_DIST"):
print "Field exists"
else:
arcpy.AddField_management("SUBJECT_PROPERTY","BUFF_DIST","Double")
except:
pass
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
distances = ["2 Mile", "1 Mile"]
for distance in distances:
outfile = "wp%s" % distance
arcpy.Buffer_analysis(SP, outfile, distance, "OUTSIDE_ONLY", "ROUND", "", "BUFF_DIST") i tried to use the arcpy.da.UpdateCursor to update the BUFF_DIST field of the new feature classes but on the the first one gets populated. Code with arcpy.da.UpdateCursor import arcpy, os
mxd = arcpy.mapping.MapDocument("CURRENT")
lyr = arcpy.mapping.ListLayers(mxd, "SUBJECT_PROPERTY")[0]
#lyrpath = lyr.workspacePath
arcpy.env.workspace = os.path.dirname(mxd.filePath)
wp = os.path.dirname(mxd.filePath)
try:
SP = "SUBJECT_PROPERTY"
lyr.replaceDataSource(wp, "SHAPEFILE_WORKSPACE", SP, True )
except:
pass
try:
if arcpy.ListFields(SP, "BUFF_DIST"):
print "Field exists"
else:
arcpy.AddField_management("SUBJECT_PROPERTY","BUFF_DIST","Double")
except:
pass
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
distances = ["2 Mile", "1 Mile"]
for distance in distances:
outfile = "wp%s" % distance
arcpy.Buffer_analysis(SP, outfile, distance, "OUTSIDE_ONLY", "ROUND", "", "BUFF_DIST")
with arcpy.da.UpdateCursor("wp%s" % distance, "ToBufDist") as cursor:
for row in cursor:
if row[0] in (""," ",None):
row[0] = '1'
cursor.updateRow(row)
else:
pass
with arcpy.da.UpdateCursor("wp%s" % distance, "ToBufDist") as cursor:
for row in cursor:
if row[0] in (""," ",None):
row[0] = '2'
cursor.updateRow(row)
else:
pass
... View more
09-23-2016
12:38 PM
|
0
|
2
|
1732
|
|
POST
|
I was able to get the features to be created by adding "Miles" to the following line. distances = ["1 Mile", "2 Miles"] Why isn't the BUFF_DIST being populated with 1 mile and 2 mile for each new feature class?
... View more
09-23-2016
08:51 AM
|
0
|
1
|
1410
|
|
POST
|
I am trying to create multiple buffer rings of 1 mile and 2 mile for a polygon. I tried the MulipleRingBuffer Analysis but it take about 2 minutes to do 2 buffer rings. so i am trying the buffer analysis. I have the following script, it creates the 1 mile and the 2 mile feature classes but it's on the outline of the subject polygon . I do not get an error but some how i am not correctly getting what i am after, any help would be great. import arcpy, os
mxd = arcpy.mapping.MapDocument("CURRENT")
lyr = arcpy.mapping.ListLayers(mxd, "SUBJECT_PROPERTY")[0]
#lyrpath = lyr.workspacePath
arcpy.env.workspace = os.path.dirname(mxd.filePath)
wp = os.path.dirname(mxd.filePath)
try:
SP = "SUBJECT_PROPERTY"
lyr.replaceDataSource(wp, "SHAPEFILE_WORKSPACE", SP, True )
except:
pass
if arcpy.ListFields(SP, "BUFF_DIST"):
print "Field exists"
else:
arcpy.AddField_management("SUBJECT_PROPERTY","BUFF_DIST","TEXT",10)
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
distances = [1, 2]
for distance in distances:
outfile = "wp%s" % distance
arcpy.Buffer_analysis(SP, outfile, distance, "OUTSIDE_ONLY", "ROUND", "LIST", "BUFF_DIST")
... View more
09-23-2016
08:35 AM
|
0
|
3
|
2250
|
|
POST
|
Doh! I looked into your suggest to parse that into a def but was not successful at all. I appreciate the help. Thanks.
... View more
08-22-2016
01:24 PM
|
0
|
0
|
640
|
|
POST
|
I've been trying to do something like this but attributes don't seem to change. with arcpy.da.UpdateCursor("In_memory\PT_Lyr", "FEMA_ZONE") as cursor:
for row in cursor:
if row[0] in ['AEX','AEXX']:
row[0] = 'AE/X'
elif row[0] in ['AAEAEXX','AAEX','AAEAEX']:
row[0] = 'A/AE/X'
elif row[0] in ['AAE','AAEAE']:
row[0] = 'A/AE'
cursor.updateRow(row)
del row
... View more
08-22-2016
11:59 AM
|
0
|
2
|
4297
|
|
POST
|
Dissolving the FEMA Layer seemed to reduce the number of them but completely give me the results i am after. Thank you for the suggestions
... View more
08-17-2016
11:30 AM
|
0
|
0
|
4297
|
|
POST
|
No there are not separators. In the attached picture the blue highlighted is the parcel and you can see that FEMA_ZONES 'X', 'AE', 'AE', 'AE', 'X', 'X' intersect the parcel so it's adding/joining all the FEMA_ZONES into one attribute 'AEXXXAEXAE' which i believe that's what it is suppose to do. i just need it to have AE/X or AE,X i don't need all the extra AE's and X's.
... View more
08-17-2016
08:19 AM
|
0
|
1
|
4297
|
|
POST
|
Its a string These are all the conditions yes they have different lengths In the FEMA Layer they are only 'A', 'AE', 'AH', 'AO' or 'X' Just text ('A', 'AE', 'AH', 'AO' or 'X') Thanks.
... View more
08-16-2016
04:01 PM
|
0
|
3
|
4297
|
|
POST
|
When i do a spatial join from a FEMA layer and Taxparcels it get multiple Fema zones like 'AEXXXAEXAE', 'AEAEXAEAEXAEAEAEXAEXAEXAEX'. I use the following + """FEMA_ZONE "FEMA_ZONE" true false false 60 Text 0 0 ,Join,#,"""+ FEMA09 + """,FLD_ZONE,-1,-1;"""\. I know the tool is doing what it is suppose to be doing. There is multiple "X" and "AE" zones that overlap this parcel. For the most part there are hundreds like this. Is there a why for example to just put "AE,X" instead of "AEAEXAEAEXAEAEAEXAEXAEXAEX". The only thing i can think of is to write and update cursor for each different FEMA_ZONE, but that would alot of update Cursor's. I would appreciate any help, thanks.
... View more
08-16-2016
03:37 PM
|
0
|
10
|
5843
|
|
POST
|
my second attempted was row[0] = ''.join(('\'row[0],'\')) but now I see thanks,
... View more
08-08-2016
01:15 PM
|
0
|
0
|
915
|
|
POST
|
I need help with some code. I need to add a back slash in front and end of values in a fields. I can do it in arcpy.CalculateField_management like this arcpy.CalculateField_management(Merge_Layer, "Location", "''.join(('\'CITY!,'\'))", "PYTHON_9.3", "") But i am not sure who to do it with arcpy.da.UpdateCursor, any help would be great. I have this but it's not working. with arcpy.da.UpdateCursor(fc, "CITY") as cursor:
for row in cursor:
row[0] = row[0].format(str(!CITY!),"/")
cursor.updateRow(row)
... View more
08-08-2016
12:01 PM
|
0
|
2
|
1714
|
|
POST
|
Trying to do a spatial join with two layers but i keep getting the following error. When i look up the error 001156 it indicates that the field length my not be long enough but the FZone_Code field mapping length is set to 60, so i am not sure what' it's not working, the longest attribute i have in the FZ is 12 characters long (AG/ComComRes) It should fit right? there is also a few NULL attributes. Any help would be great, thanks. Traceback (most recent call last): File "C:\GIS\Python\\TaxJoin.py", line 149, in <module> arcpy.SpatialJoin_analysis(FZon1, UG, "In_memory\UG1", "JOIN_ONE_TO_ONE", "KEEP_ALL", Layers2(FZon1,UG), "HAVE_THEIR_CENTER_IN") File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\analysis.py", line 461, in SpatialJoin raise e ExecuteError: ERROR 001156: Failed on input OID 20670, could not write value 'AG/ComIndInd' to output field FZONE_CODE Failed to execute (SpatialJoin). never mind I called Fzone field twice and that's why i was getting the error. my bad.
... View more
08-04-2016
09:16 AM
|
0
|
0
|
2684
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-27-2022 11:37 AM | |
| 1 | 10-31-2023 10:16 AM | |
| 1 | 02-16-2023 01:50 PM | |
| 1 | 08-11-2021 11:13 AM | |
| 1 | 01-06-2021 10:45 AM |
| Online Status |
Offline
|
| Date Last Visited |
09-10-2024
10:42 AM
|