POST
|
IT WORKED!!!! Thank you SOOOO much!! I can't believe how quickly you responded and how helpful your advice was. Honestly, thanks again so much!
... View more
02-21-2017
12:49 PM
|
0
|
0
|
424
|
POST
|
Hi Darren, Thanks again for all your help. I started over, taking a subset of my data and creating a feature class layer of 500 points saved in the Default gdb (FloodTestFC). This is the code I use: import arcpy ... ... def main(): ... fc_in = r"C:\Users\ihwm\Documents\ArcGIS\Default.gdb\FloodTestFC" ... fc_out = r"C:\Users\ihwm\Documents\ArcGIS\Default.gdb\FloodTestFC2" ... ... fld_start = "fld_start" ... fld_end = "fld_end" ... fld_dist = "fld_dist" ... ... sr = arcpy.Describe(fc_in).spatialReference ... arcpy.env.overwriteOutput = True ... ... flds = ("SHAPE@", fld_start, fld_end, fld_dist) ... lst_polygons = [1] ... with arcpy.da.SearchCursor(fc_in, flds) as curs: ... for row in curs: ... pnt_g = row[0] ... start = row[1] ... end = row[2] ... length = row[3] ... circle = pnt_g.buffer(length) ... pnt = pnt_g.firstPoint ... arrPnts = arcpy.Array() ... arrPnts.add(pnt) ... for bearing in range(int(start), int(end) + 1): ... arrPnts.add(createPointAtAngleWithBearing(pnt, bearing, length)) ... polygon = arcpy.Polygon(arrPnts, sr) ... lst_polygons.append(polygon) ... ... arcpy.CopyFeatures_management(lst_polygons, fc_out) ... ... def createPointAtAngleWithBearing(pnt, angle, distance): ... import math ... angle = math.radians(angle) ... dist_x, dist_y = (distance * math.cos(angle), distance * math.sin(angle)) ... return arcpy.Point(pnt.X + dist_x, pnt.Y + dist_y) ... ... if __name__ == '__main__': ... main() ... And this is the error message: Runtime error Traceback (most recent call last): File "<string>", line 40, in <module> File "<string>", line 31, in main File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\management.py", line 2335, in CopyFeatures raise e RuntimeError: Object: Error in executing tool
... View more
02-20-2017
06:43 PM
|
0
|
2
|
424
|
POST
|
Thanks, Darren! I'm still getting the same message. Could it be because I'm using Arcgis 10.4.1 and that code was written for an earlier version? >>> import arcpy ... ... def main(): ... fc_in = r"C:\Users\ihwm\Documents\ArcGIS\Flood_NT_WA.gdb\points" ... fc_out = r"C:\Users\ihwm\Documents\ArcGIS\Flood_NT_WA.gdb\points2" ... ... fld_start = "fld_start" ... fld_end = "fld_end" ... fld_dist = "fld_dist" ... ... sr = arcpy.Describe(fc_in).spatialReference ... arcpy.env.overwriteOutput = True ... ... flds = ("SHAPE@", fld_start, fld_end, fld_dist) ... lst_polygons = [1] ... with arcpy.da.SearchCursor(fc_in, flds) as curs: ... for row in curs: ... pnt_g = row[0] ... start = row[1] ... end = row[2] ... length = row[3] ... circle = pnt_g.buffer(length) ... pnt = pnt_g.firstPoint ... arrPnts = arcpy.Array() ... arrPnts.add(pnt) ... for bearing in range(int(start), int(end) + 1): ... arrPnts.add(createPointAtAngleWithBearing(pnt, bearing, length)) ... polygon = arcpy.Polygon(arrPnts, sr) ... lst_polygons.append(polygon) ... ... arcpy.CopyFeatures_management(lst_polygons, fc_out) ... ... def createPointAtAngleWithBearing(pnt, angle, distance): ... import math ... angle = math.radians(angle) ... dist_x, dist_y = (distance * math.cos(angle), distance * math.sin(angle)) ... return arcpy.Point(pnt.X + dist_x, pnt.Y + dist_y) ... ... if __name__ == '__main__': ... main() ... Runtime error Traceback (most recent call last): File "<string>", line 40, in <module> File "<string>", line 11, in main AttributeError: DescribeData: Method spatialReference does not exist
... View more
02-20-2017
04:15 PM
|
0
|
5
|
424
|
POST
|
Thanks Dan. I really appreciate the quick response. I changed the lines to include the field names, but I still receive the below error message: Runtime error Traceback (most recent call last): File "<string>", line 40, in <module> File "<string>", line 11, in main AttributeError: DescribeData: Method spatialReference does not exist >>> import arcpy ... ... def main(): ... fc_in = "C:\Users\ihwm\Documents\ArcGIS\Flood_NT_WA.gdb\points" ... fc_out = "C:\Users\ihwm\Documents\ArcGIS\Flood_NT_WA.gdb\points2" ... ... fld_start = "fld_start" ... fld_end = "fld_end" ... fld_dist = "fld_dist" ... ... sr = arcpy.Describe(fc_in).spatialReference ... arcpy.env.overwriteOutput = True ... ... flds = ("SHAPE@", fld_start, fld_end, fld_dist) ... lst_polygons = [1] ... with arcpy.da.SearchCursor(fc_in, flds) as curs: ... for row in curs: ... pnt_g = row[0] ... start = row[1] ... end = row[2] ... length = row[3] ... circle = pnt_g.buffer(length) ... pnt = pnt_g.firstPoint ... arrPnts = arcpy.Array() ... arrPnts.add(pnt) ... for bearing in range(int(start), int(end) + 1): ... arrPnts.add(createPointAtAngleWithBearing(pnt, bearing, length)) ... polygon = arcpy.Polygon(arrPnts, sr) ... lst_polygons.append(polygon) ... ... arcpy.CopyFeatures_management(lst_polygons, fc_out) ... ... def createPointAtAngleWithBearing(pnt, angle, distance): ... import math ... angle = math.radians(angle) ... dist_x, dist_y = (distance * math.cos(angle), distance * math.sin(angle)) ... return arcpy.Point(pnt.X + dist_x, pnt.Y + dist_y) ... ... if __name__ == '__main__': ... main() ... Runtime error Traceback (most recent call last): File "<string>", line 40, in <module> File "<string>", line 11, in main AttributeError: DescribeData: Method spatialReference does not exist
... View more
02-20-2017
02:32 PM
|
0
|
7
|
422
|
POST
|
Xander Bakker Thanks so much for this! I'm trying to create 4 90degree buffers around all points in my data frame. I tried using your code and I keep getting this below error. I'm pretty new to Python, do you know how to fix this? Thanks again! >>> import arcpy ... ... def main(): ... fc_in = "C:\Users\A0701216\Documents\ArcGIS\Default.gdb\ALEX" ... fc_out = "C:\Users\A0701216\Documents\ArcGIS\Default.gdb\ALEX_" ... ... fld_start = 180 ... fld_end = 225 ... fld_dist = 15 ... ... sr = arcpy.Describe(fc_in).spatialReference ... arcpy.env.overwriteOutput = True ... ... flds = ("SHAPE@", fld_start, fld_end, fld_dist) ... lst_polygons = [1] ... with arcpy.da.SearchCursor(fc_in, flds) as curs: ... for row in curs: ... pnt_g = row[0] ... start = row[1] ... end = row[2] ... length = row[3] ... circle = pnt_g.buffer(length) ... pnt = pnt_g.firstPoint ... arrPnts = arcpy.Array() ... arrPnts.add(pnt) ... for bearing in range(int(start), int(end) + 1): ... arrPnts.add(createPointAtAngleWithBearing(pnt, bearing, length)) ... polygon = arcpy.Polygon(arrPnts, sr) ... lst_polygons.append(polygon) ... ... arcpy.CopyFeatures_management(lst_polygons, fc_out) ... ... def createPointAtAngleWithBearing(pnt, angle, distance): ... import math ... angle = math.radians(angle) ... dist_x, dist_y = (distance * math.cos(angle), distance * math.sin(angle)) ... return arcpy.Point(pnt.X + dist_x, pnt.Y + dist_y) ... ... if __name__ == '__main__': ... main() ... Runtime error Traceback (most recent call last): File "<string>", line 40, in <module> File "<string>", line 16, in main TypeError: 'field_names' must be string or non empty sequence of strings >>>
... View more
02-18-2017
01:33 AM
|
0
|
9
|
602
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|