POST
|
Tried it, but the problem persists. I thought the with.. as.. statement will automatically clear the cursor and row? ##Create output featureclass to be populated with bottom of dam points, dam id, and elevation arcpy.AddMessage("Writing output dam elevation featureclass") outpt = arcpy.management.CreateFeatureclass(outpt_path, "{}_BottomOfDam".format(outpt_name), "POINT", spatial_reference = temp_inpt_lyr_spref) arcpy.management.AddField(outpt, fid, "TEXT", field_length = 6) arcpy.management.AddField(outpt, "BottomOfDam_Elevation", "DOUBLE") ##Populate output bottom of dam point featureclass with arcpy.da.InsertCursor(outpt, ["SHAPE@", fid, "BottomOfDam_Elevation"]) as cursor: for row in bt_points: cursor.insertRow(row) del cursor, row ##Create output featureclass to be populated with transect lines moving away from dams in downstream direction arcpy.AddMessage("Writing output transect line featureclass") outln = arcpy.management.CreateFeatureclass(outpt_path, "{}_Transect_Temp".format(outpt_name), "POLYLINE", spatial_reference = temp_inpt_lyr_spref) arcpy.management.AddField(outln, fid, "TEXT", field_length = 6) ##Populate output transect line featureclass with arcpy.da.InsertCursor(outln, ["SHAPE@", fid]) as cursor: for row in lines: cursor.insertRow(row) del cursor, row arcpy.ddd.InterpolateShape(indem, outln, r"{}\{}_Transect".format(outpt_path, outpt_name))
... View more
10-19-2017
10:53 AM
|
0
|
1
|
1317
|
POST
|
I'm trying that at the moment, I'm seeing some odd behavior.. I have saved the outln featureclass to a geodatabase instead of in_memory, and when I print GetCount() after running through the InsertCursor, there are 0 features. But.. when I look at this featureclass in my geodatabase there are 25 records, one for each item in the list lines. Now.. I'm using outln as input to InterpolateShape to create a 3D Line, and the output of that tool is still empty, just as the GetCount() print statement suggests. Something really strange is going on. ##Create output featureclass to be populated with transect lines moving away from dams in downstream direction arcpy.AddMessage("Writing output transect line featureclass") outln = arcpy.management.CreateFeatureclass(outpt_path, "{}_Transect_Temp".format(outpt_name), "POLYLINE", spatial_reference = temp_inpt_lyr_spref) arcpy.management.AddField(outln, fid, "TEXT", field_length = 6) arcpy.AddMessage(len(lines)) #DEBUG# ##Populate output transect line featureclass cursor = arcpy.da.InsertCursor(outln, ["SHAPE@", fid]) for row in lines: arcpy.AddMessage(row) #DEBUG# cursor.insertRow(row) arcpy.AddMessage(arcpy.management.GetCount(outln)) #DEBUG# arcpy.ddd.InterpolateShape(indem, outln, r"{}\{}_Transect".format(outpt_path, outpt_name)) del row, cursor
... View more
10-18-2017
09:59 AM
|
0
|
3
|
1317
|
POST
|
Oh sorry, my mistake. No, it is a polyline featureclass.
... View more
10-18-2017
09:45 AM
|
0
|
0
|
700
|
POST
|
Hi Dan, does that method work for da.InsertCursors? I am getting an error message, I can also not find any satisfactory documentation of this method.
... View more
10-18-2017
09:34 AM
|
0
|
0
|
700
|
POST
|
The fid is just a text object with a unique id for each item - but not the object id. It's something like 'D 1403'.
... View more
10-18-2017
09:26 AM
|
0
|
0
|
700
|
POST
|
But I do the same for a point featureclass, bt_points, and it works just fine using the exact same code (except it uses point geometry instead of Polyline geometry objects). ##Populate output bottom of dam point featureclass cursor = arcpy.da.InsertCursor(outpt, ["SHAPE@", fid, "BottomOfDam_Elevation"]) for row in bt_points: cursor.insertRow(row) del cursor, row
... View more
10-18-2017
08:32 AM
|
0
|
2
|
700
|
POST
|
Hi Joshua, yupp. The entire script is tool long I think, here are the relevant excerpts: First I create empty lists (including one for lines), then I start a cursor to go through a points featureclass and find start and end points for a transect line I draw. Then I produce the line array object using those points. ##Step through each point in temp_inpt_lyr. arcpy.AddMessage("Stepping through each top of dam point and finding bottom of dam point and corresponding elevation...") bt_points, txt_data, lines = [], [], [] ##bottom points geometry, output data for csv table, and line geometry are stored in these lists. cursor = arcpy.da.SearchCursor(temp_inpt_lyr, ["START_X", "START_Y", "UNIT_VECTOR_X", "UNIT_VECTOR_Y", fid]) for row in cursor: arcpy.AddMessage(row[4]) ##Print the dam id for current point. st_point = arcpy.Point(row[0], row[1]) ##starting point (START_X, START_Y). ed_point = arcpy.Point(linext*row[2]+row[0], linext*row[3]+row[1]) ##Point at end of line drawn from st_point to linext map units in the opposite direction of the line from the same point to the nearest polygon (of dam surface area) using unit vector. line_arr = arcpy.Array([st_point, ed_point]) ##Array object to contain the st_point and ed_point coordinates that define the transect line used to profile the dam and identify the bottom of dam. I then do some other stuff that isn't relevant to the lines geometry (just a bunch of processing reading the geometry and using data from it). Then I use vectors to find a new point, and more importantly for the problem I'm having, I copy create a line object that contains the line geometry and append that to the lines list. After this it goes into the code in my original post. magnitude = slp_profile[bod][0] ##Find magnitude for vector bod. bt_points.append([arcpy.Point(magnitude*row[2]+st_point.X, magnitude*row[3]+st_point.Y), row[4], elv_profile[bod][1]]) ##Store bottom of dam point geometry, DAMNO, and elevation in list bt_points. line = arcpy.Polyline(line_arr, temp_inpt_lyr_spref) ##Have to create line object anew, not sure why but line object loses information after being input into InterpolateShape tool. lines.append([line, row[4]]) ##Add lines to polyline geometry for output transect featureclass. Code in my original post (plus a little extra setting up fields). ##Create output featureclass to be populated with transect lines moving away from dams in downstream direction arcpy.AddMessage("Writing output transect line featureclass") outln_m = arcpy.management.CreateFeatureclass("in_memory", "{}_Transect".format(outpt_name), "POLYLINE", spatial_reference = temp_inpt_lyr_spref) arcpy.management.AddField(outln_m, fid, "TEXT", field_length = 6) arcpy.AddMessage(lines) arcpy.AddMessage(len(lines)) #DEBUG# ##Populate output transect line featureclass workspace = r"in_memory" with arcpy.da.Editor(workspace) as edit: cursor = arcpy.da.InsertCursor(outln_m, ["SHAPE@", fid]) for row in lines: arcpy.AddMessage(row) #DEBUG# cursor.insertRow(row) del cursor, row arcpy.AddMessage(arcpy.management.GetCount(outln_m)) #DEBUG# Sorry, it's a lot of code.
... View more
10-18-2017
08:29 AM
|
0
|
5
|
1317
|
POST
|
Hi Holley, the contents of the list is printed out by the script (one line per item in the list) as seen in my original post. I've added a print statement for the raw list as well, see below: Thank you!
... View more
10-18-2017
08:18 AM
|
1
|
4
|
1317
|
POST
|
Hello, I'm working on a script that gathers a bunch of line geometry (created using arcpy.Polyline function) into a list (called lines in the script), and then inserts this geometry into an empty polygon featureclass (called outln_m in the script). However, for some reason, only the last item in the list is there in the output polyline featureclass after the script runs, and I'm baffled. Can anyone shed some light on what might be causing this? I checked and all my cursor/row objects are being deleted before creating a new cursor. I tried wrapping the whole thing in an editor session but that did not change the result. And the result of my debugging print statements: You can see the list contains 25 items, but only one record is written to the output featureclass after running the list through a for-loop. That record happens to always be the last item in the list. Thank you for any help! I'm sure I'm missing something obvious.. I just can't see it.
... View more
10-17-2017
01:40 PM
|
1
|
18
|
3311
|
POST
|
Yes, that's exactly what I did. Sorry for the late response, it got busy and then I forgot to reply.
... View more
09-20-2017
07:02 AM
|
0
|
0
|
939
|
POST
|
I have a raster DEM that has the vertical coordinate system NAVD88 (height) with linear units Meter. I would like to convert the linear units to US_Feet. As far as I know, ArcGIS does not support conversion between vertical datum. Since the datum remains the same (NAVD88), I assume I can use raster calculator to apply the following transformation to each cell value: Value * (39.37/12) {Convert linear unit from Meter to US_Feet) However, the metadata would still state that the units are in Meter. So, I have a few questions about converting linear units of a vertical datum. Is applying the above transformation valid? How does this affect the vertical datum stored in the metadata (i.e. if I were to now use VDATUM to convert to NAVD88 to NGVD29, how would my cell values be affected)? After using raster calculator, can I just re-define the projection (using define projection tool) to from NAVD88 (height) to NAVD88 (height) (ftUS)? Thank you!
... View more
09-18-2017
07:24 AM
|
1
|
1
|
3311
|
POST
|
No other way around, I had one layer in ArcMap, multiple in AGOL map.
... View more
08-31-2017
12:04 PM
|
0
|
2
|
939
|
POST
|
Yes, there is. Check out this link: http://support.esri.com/en/technical-article/000012460
... View more
08-31-2017
10:36 AM
|
0
|
0
|
939
|
POST
|
Thank you for the suggestion, I tested it out but I am unfortunately still getting the error message.
... View more
08-31-2017
05:04 AM
|
0
|
0
|
4372
|
POST
|
Yes, I'm trying to overwrite a hosted feature layer, the service definition file is present in AGOL. I'm not sure this is the problem, however, because I did try to create a completely new hosted feature layer and I got the same error. I even created an entirely new .gdb, created an entirely empty featureclass, gave it a single geometry and attribute, and tried to share it as a hosted feature service using an entirely new .mxd and I also got the same error message.. I recently installed ArcGIS 10.5, I wonder if that has something to do with it?
... View more
08-30-2017
04:56 AM
|
0
|
0
|
4373
|
Title | Kudos | Posted |
---|---|---|
1 | 09-18-2017 07:24 AM | |
1 | 10-18-2017 08:18 AM | |
1 | 10-20-2017 06:19 AM | |
1 | 03-29-2018 01:59 PM | |
1 | 08-08-2017 04:47 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|