|
POST
|
Here's one line of code that will essentially do your assignment for you, but at some point you will need to figure out what it means: arcpy.CopyFeatures_management([arcpy.Polygon(arcpy.Array([arcpy.Point(i,80),arcpy.Point(i+6,80),arcpy.Point(i+6,-80),arcpy.Point(i,-80),arcpy.Point(i,80)])) for i in range(-180,180,6)],r'in_memory\utm_zones')
... View more
04-27-2016
01:06 PM
|
0
|
0
|
1072
|
|
POST
|
Without you even trying, it's hard to help. Your assignment lays out the instructions. Here's a link with an example of creating a polygon. Good luck!
... View more
04-27-2016
09:00 AM
|
1
|
0
|
5975
|
|
POST
|
What have you got so far? What have you tried and what isn't working? You need to do some of it.
... View more
04-27-2016
07:28 AM
|
1
|
5
|
5975
|
|
POST
|
ptScue is an old-style cursor, which behave unpredictably (or predictably bad) when nested. Does it help to switch it to a da cursor? In general, I also suggest using ' with ' syntax on all cursors to avoid them hanging in the void if your run ends in an error.
... View more
04-26-2016
06:06 PM
|
1
|
3
|
3853
|
|
POST
|
Universal Transverse Mercator coordinate system - Wikipedia, the free encyclopedia See if you can find the pattern(s) for your loop(s).
... View more
04-26-2016
09:26 AM
|
0
|
0
|
1072
|
|
POST
|
Okay, we're starting to circle (see my previous example). Meeting adjourned.
... View more
04-23-2016
09:55 AM
|
0
|
0
|
1232
|
|
POST
|
But they only write to xls, not xlsx, as far as I know. Is there a method to write to xlsx out of the box?
... View more
04-23-2016
08:16 AM
|
0
|
3
|
3260
|
|
POST
|
See this thread to see how to merge outputs of an iterator: Merge error after Iterate Feature Selection
... View more
04-22-2016
03:24 PM
|
0
|
5
|
8053
|
|
POST
|
Not sure if this is the type of answer you're looking for, but since you're already using Python scripts... XlsxWriter 0.8.5 : Python Package Index >>> import xlsxwriter # import library
... fc = 'points' # feature class/layer
... workbook = xlsxwriter.Workbook('C:\junk\my_new_workbook.xlsx') # new workbook
... worksheet = workbook.add_worksheet() # create worksheet
... fieldnames = [i.name for i in arcpy.ListFields(fc)] # list fields in fc
... for field,fieldname in enumerate(fieldnames):
... worksheet.write(0,field,fieldname) # write field names to xlsx
... with arcpy.da.SearchCursor(fc,'*') as cursor: # loop through features
... for row,row_val in enumerate(cursor): # loop through rows
... for col,col_val in enumerate(row_val): # loop through columns
... try:
... worksheet.write(row+1,col,col_val) # if text or number, write value
... except:
... worksheet.write(row+1,col,repr(col_val)) # if something else (like a shape) write the representation
... workbook.close() # close the workbook edit: just realized the original post was made 5 years ago, so it's possible that xlsxwriter didn't exist then, but it does now!
... View more
04-22-2016
01:21 PM
|
0
|
10
|
3260
|
|
POST
|
Have you tried restarting ArcGIS since your problem started? My understanding of cursor syntax is that you should use 'with...' notation because it automatically cleans up your cursor, even if it errors out. Without it, if you make a run that ends in an error, your cursor can get stuck in memory until you delete it with a 'del' statement. Try restating ArcGIS and change your cursor to something like: with arcpy.da.SearchCursor(lyr_Park[0], ['park_']) as pCursor:
for park in pCursor: Also, certainly just a copy/paste/formatting error, but everything after 'for park in pCursor' should be indented.
... View more
04-22-2016
11:49 AM
|
0
|
1
|
2347
|
|
POST
|
This runs in about 40s, so similar to the cursor: my_list = arcpy.da.TableToNumPyArray('Pemberton_VRI', 'POLYGON_AR')
my_max = max(my_list['POLYGON_AR'])
def cfmax():
global my_max
return my_max ...and this doesn't get past 0% (a blue sliver did just appear in the progress bar after a couple minutes): def cfmax():
my_list = arcpy.da.TableToNumPyArray('Pemberton_VRI', 'POLYGON_AR')
my_max = max(my_list['POLYGON_AR'])
return my_max
... View more
04-22-2016
11:00 AM
|
1
|
1
|
2475
|
|
POST
|
That is a straight forward method to get the max, but not very fast (perhaps you meant fast, like, quick and dirty). The cursor is created, stored, and sorted for every row in the table. Move the cursor outside the function to run only once. Example, using 120000 features: Expression: cfmax() Code Block: def cfmax():
max = sorted(arcpy.da.SearchCursor("Pemberton_VRI", "POLYGON_AR"), reverse=True)[0][0]
return max Result: I ended the process after 5 minutes. Never finished. vs. Expression: cfmax() Code Block: max = sorted(arcpy.da.SearchCursor("Pemberton_VRI", "POLYGON_AR"), reverse=True)[0][0]
def cfmax():
global max # may not be necessary
return max Result: finished in 38s.
... View more
04-22-2016
10:34 AM
|
1
|
3
|
2475
|
|
POST
|
Just small edits: - should be: for rd in cleaned: - and elif rdup[0] == "U": key = 1 # US route
... View more
04-21-2016
11:39 AM
|
1
|
1
|
3187
|
|
POST
|
Similar to above, you can return a dummy value instead of changing the datetime format to flag your records. from datetime import datetime
def fnElapsed(STRDTTM, ENDDTTM):
try:
dateStart = datetime.strptime(STRDTTM, "%d/%m/%Y %I:%M:%S %p")
except:
return 9999
try:
dateEnd = datetime.strptime(ENDDTTM, "%d/%m/%Y %I:%M:%S %p")
except:
return -9999
timeDiff = dateEnd - dateStart
return timeDiff.total_seconds()/60
... View more
04-21-2016
11:24 AM
|
0
|
0
|
3467
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-25-2015 01:51 PM | |
| 1 | 08-30-2013 02:22 PM | |
| 1 | 04-12-2011 11:19 AM | |
| 1 | 09-17-2021 09:43 AM | |
| 1 | 04-04-2012 12:05 PM |
| Online Status |
Offline
|
| Date Last Visited |
07-15-2023
12:11 AM
|