|
POST
|
At this point i would like to just merge the features without the attributes.
... View more
01-21-2020
09:26 AM
|
0
|
7
|
4171
|
|
POST
|
Correct this is would not be a result of buffering, i don't wan to recreate a new feature class and I want to merge the attributes similar to the what you do in Arcmap when you select features,start editing, click editor tool bar- merge. This would all take place in ArcMap's Python not stand alone. I came close to this with the code i posted but i can't get it correct. Thanks for the reply.
... View more
01-13-2020
01:49 PM
|
0
|
0
|
4171
|
|
POST
|
I appreciate the info but I was trying to find a way to do this with out so many process.
... View more
01-13-2020
10:08 AM
|
0
|
2
|
7618
|
|
POST
|
sorry but i am not sure how i can incorporate what you posted into my code to do what i need it to do.
... View more
01-10-2020
08:14 AM
|
0
|
4
|
7618
|
|
POST
|
The lyr just happened to be one that I was testing try to see how I can accomplish the task. The real layer i have is a different layer. I tried the following with SHAPE@ and get the following. The other issue with this code is that none of the attributes get transferred, there is only OID, Shape in the new temp layer. array = arcpy.Array()
with arcpy.da.SearchCursor(lyr, ['SHAPE@']) as rows:
for r in rows:
for part in r[0]:
array.append(part)
poly = arcpy.Polygon(array, sr)
arcpy.management.CopyFeatures(poly, r'in_memory\multipart_poly_merge')
... View more
01-09-2020
01:28 PM
|
0
|
6
|
7618
|
|
POST
|
yes i can do it on pro, i am trying to do it in a python script. I have the following to start with but i am not quite here but my approach may not be the correct one. BD = str('BUFF_DIST')
array = arcpy.Array()
with arcpy.da.SearchCursor(lyr, BD) as rows:
for r in rows:
for part in r[0]:
array.append(part)
poly = arcpy.Polygon(array, sr)
arcpy.management.CopyFeatures(poly, r'in_memory\multipart_poly_merge')
... View more
01-09-2020
11:06 AM
|
0
|
9
|
7618
|
|
POST
|
I have a feature class that can have many features within it i would like to merge all the features in this feature class into just one based on the "BUFF_DIST" like you would in ArcMap when you start editing, select all the features and go to edit, merge and you get the popup "Chose the feature with which other features will be merged:" i am trying to avoid creating a new feature class. Anyone done this or have an example of some python code?
... View more
01-09-2020
08:35 AM
|
0
|
20
|
13139
|
|
POST
|
I don't, which is why i was looking into trying to do it with python.
... View more
12-16-2019
01:02 PM
|
0
|
1
|
1775
|
|
POST
|
I have a feature class of polylines that are duplicate, one on top of the other and i would like to delete all except for 1 and it doesn't matter witch one just as long as there is one left. I would like this to be done in arcmap. I have the following that identifies the duplicates but i am not sure on how to delete duplicates in the set. import itertools, arcpy
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Parcel_Lines1")[0]
dsc = arcpy.Describe(lyr)
sr = dsc.spatialReference
oid_field_name = dsc.oidFieldName
# get a cursor on the input features
rows1 = arcpy.SearchCursor(lyr)
# exclude features already compared once
exclude = []
# iterate through the first coursor
for row1 in rows1:
oid1 = row1.getValue(oid_field_name)
shp1 = row1.shape
# get a second cursor on the same input features
rows2 = arcpy.SearchCursor(lyr)
# add the feature to be compared to exclude list
exclude.append(oid1)
# create a set to hold duplicate features
group = set()
# iterate through the second cursor
for row2 in rows2:
oid2 = row2.getValue(oid_field_name)
shp2 = row2.shape
# ignore features already compared
if oid2 in exclude:
continue
# test equality
if shp1.equals(shp2):
# add both feature ids to the set of identical features
group.add(oid1)
group.add(oid2)
# add the feature just compared to the exclude list
exclude.append(oid2)
if group: # if the group is not empty
print group
... View more
12-16-2019
11:39 AM
|
0
|
4
|
1862
|
|
POST
|
Thanks everyone that replied. I was able to come with the following code that works for me. fyi, Michael Boyce your code did work by the way. import arcpy
from datetime import datetime as d
startTime = d.now()
start_time = time.time()
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "C:/Temp/blah.gdb"
fc1 = "C:/Temp/blah.gdb/Parcels"
arcpy.MakeFeatureLayer_management(fc1, "fc1Lyr")
CITY = "C:/Temp/blah.gdb/City_Limits"
arcpy.MakeFeatureLayer_management(CITY, "CityLyr")
with arcpy.da.SearchCursor("CityLyr", ["SHAPE@"]) as cursor:
for row in cursor:
#SELECT PROPERTIES BY CITYLIMITS
selection = arcpy.SelectLayerByLocation_management("fc1Lyr","HAVE_THEIR_CENTER_IN", "CityLyr")
result = int(arcpy.GetCount_management("fc1Lyr").getOutput(0))
with arcpy.da.UpdateCursor(selection, ['field1','field2','field3', 'field4']) as cursor:
for row in cursor:
# Select all parcels within the city limits layer
row[0] = "IN CITY"
row[1] = "IN CITY"
row[2] = "IN CITY"
row[3] = "IN CITY"
cursor.updateRow(row)
del row, cursor
try:
print ('(Elapsed time: ' + str(d.now() - startTime)[:-3] + ')')
print ('Number of features processed: ' + str(result))
except Exception as 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)
print (e.message)
... View more
12-12-2019
09:16 AM
|
1
|
1
|
1367
|
|
POST
|
The data is in file database i didn't think i need to start an edit session.
... View more
12-11-2019
03:29 PM
|
0
|
1
|
4023
|
|
POST
|
I tried the following nothing happens, no error and the fields don't get updated. import arcpy
from datetime import datetime as d
startTime = d.now()
start_time = time.time()
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "C:/Temp/blah.gdb"
fc1 = "C:/Temp/blah.gdb/Parcels"
arcpy.MakeFeatureLayer_management(fc1, "fc1tLyr")
CITY = "C:/Temp/blah.gdb/City_Limits"
arcpy.MakeFeatureLayer_management(CITY, "CityLyr")
with arcpy.da.UpdateCursor(fc1, ['field1','field2','field3', 'field4']) as cursor:
for row in cursor:
#Select all parcels within the city limits layer
arcpy.SelectLayerByLocation_management("fc1tLyr","HAVE_THEIR_CENTER_IN", "CityLyr")
result = arcpy.GetCount_management("fc1tLyr")
row [0] = "IN CITY"
row [1] = "IN CITY"
row [2] = "IN CITY"
row [3] = "IN CITY"
cursor.updateRow(row)
del row, cursor
print('Done')
try:
print ('(Elapsed time: ' + str(d.now() - startTime)[:-3] + ')')
except Exception as 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)
print (e.message)
... View more
12-11-2019
03:12 PM
|
0
|
3
|
4023
|
|
POST
|
I am trying to do a select by location and then update the selected features, seems easy enough but i am see to get it figured out. Basically i want to update only the parcels that are within the City limits layer and update the 4 fields. I have tried different variations but i can't seem to get to work. I don't get any errors and also doesn't stop. I would appreciate any help. Here is what i have. import arcpy
from datetime import datetime as d
startTime = d.now()
start_time = time.time()
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "C:/Temp/blah.gdb"
fc1 = "C:/Temp/blah.gdb/Parcels"
CITY = "C:/Temp/blah.gdb/City_Limits"
with arcpy.da.UpdateCursor(fc1, ['field1','field2','field3', 'field4']) as cursor:
for row in cursor:
#Select all parcels within the city limits layer
arcpy.SelectLayerByLocation_management(fc1,"HAVE_THEIR_CENTER_IN", CITY)
result = arcpy.GetCount_management(fc1)
row [0] = "IN CITY"
row [1] = "IN CITY"
row [2] = "IN CITY"
row [3] = "IN CITY"
cursor.updateRow(row)
del row, cursor
print('Done')
try:
print ('(Elapsed time: ' + str(d.now() - startTime)[:-3] + ')')
except Exception as 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)
print (e.message)
... View more
12-11-2019
12:05 PM
|
0
|
17
|
5592
|
|
POST
|
Jake, I get error on in TableToExcel raise e ExecuteError: ERROR 000814: Invalid file type Failed to execute (TableToExcel) with " .xlsx " If i change the output to ".xls" get "RuntimeError: Cannot find field ''. I need this to run in side python in Arcmap not in a stand alone script. This will be made into a tool script. import arcpy
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
lyr = arcpy.mapping.ListLayers(mxd, "Export_Output")[0]
# Create a fieldinfo object
fieldInfo = arcpy.FieldInfo()
# Fields to Hide
hiddenFields = ('FID', 'Shape', 'OBJECTID', 'Shape_Leng', 'Shape_Area')
# Get the fields from the input
fields= arcpy.ListFields(lyr)
for field in fields:
if field.name not in hiddenFields:
fieldInfo.addField(field.name, field.name, "VISIBLE", "")
else:
fieldInfo.addField(field.name, field.name, "HIDDEN", "")
# Create table view
arcpy.MakeTableView_management(lyr, "Notif_view", "", "", fieldInfo)
# Export to Excel
arcpy.conversion.TableToExcel("Notif_view", r"C:\temp\Notif_view.xlsx")
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
... View more
11-18-2019
02:21 PM
|
0
|
0
|
1309
|
|
POST
|
I have attached a sample of the data. Thanks for your help!
... View more
11-15-2019
10:11 AM
|
0
|
2
|
3514
|
| 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
|