|
POST
|
Try returning a list instead of a parameter - i.e return [param]
... View more
09-27-2013
01:21 AM
|
0
|
0
|
1596
|
|
POST
|
The timeit code I posted runs each loop 10 times and prints the average - i.e. "number=10". The timeit default number of repetitions is 10,000. I just left it at 10 as the first set took so long. SearchCursor setup overhead is relevant, but not when timing loops, it should be timed separately. Anyway, da searchcursors setup is much faster than arcpy searchcursors if __name__ == '__main__':
import timeit
shp = r"D:\TEMP\test.shp"
s='rows = arcpy.da.SearchCursor(r"%s", ["PNTID"])'%shp
c=timeit.timeit(s,number=100,setup='import arcpy')
s='rows = arcpy.SearchCursor(r"%s", "", "", "PNTID")'%shp
d=timeit.timeit(s,number=100,setup='import arcpy')
print '1. da.SearchCursor:',c
print '2. arcpy.SearchCursor:',d
1. da.SearchCursor: 0.032812795193
2. arcpy.SearchCursor: 0.497164226788
... View more
09-25-2013
04:29 PM
|
0
|
0
|
1776
|
|
POST
|
A few suggestions: Take out the print statement from inside the loop, that is adding a big overhead. There's overhead in searchcursor setup, take that out of the timing Pass a field list to arcpy.SearchCursor as you are doing with da.SearchCursor i.e. arcpy.SearchCursor(shp, "", "", "TOWN;TOTAL_SQMI") In case there's some caching going on behind the scenes, put the tests in separate scripts (one that times the arcpy cursor and one that times the da searchcursor) Use the timeit module instead, example below: if __name__ == '__main__': import timeit shp = r"D:\TEMP\test.shp" print(timeit.timeit('for row in rows:id = row[0]', number=10,#run loop 10x and return average setup='import arcpy; rows = arcpy.da.SearchCursor(r"%s", ["PNTID"])'%shp)) print(timeit.timeit('for row in rows:id = row.getValue("PNTID")', number=10, #run loop 10x and return average setup='import arcpy; rows = arcpy.SearchCursor(r"%s", "", "", "PNTID")'%shp)) EDIT:Some performance tests on 1000 points, getting value of a single field. * Printing field value in for loop * Not passing field list to arcpy.SearchCursor * searchcursor setup is included in timing 1. da.SearchCursor: 4.1257697098717925 2. arcpy.SearchCursor: 6.2084034116828475 * Not printing field value in for loop * Not passing field list to arcpy.SearchCursor * searchcursor setup is included in timing 3. da.SearchCursor: 0.07970193086012323 4. arcpy.SearchCursor: 2.196710119083276 * Not printing field value in for loop * Not passing field list to arcpy.SearchCursor * searchcursor setup is not included in timing 5. da.SearchCursor: 0.00738222613381 6. arcpy.SearchCursor: 0.160204482864 * Not printing field value in for loop * Passing field list to arcpy.SearchCursor * searchcursor setup is not included in timing 7. da.SearchCursor: 0.0075200788871 8. arcpy.SearchCursor: 0.118301085773 The above was generated using the following code: if __name__ == '__main__': import timeit shp = r"D:\TEMP\test.shp" s=''' rows = arcpy.da.SearchCursor(r"%s", ["PNTID"]) for row in rows: print row[0]'''%shp a=timeit.timeit(s,number=10,setup='import arcpy') s=''' rows = arcpy.SearchCursor(r"%s") for row in rows: print row.getValue("PNTID")'''%shp b=timeit.timeit(s,number=10,setup='import arcpy') s=''' rows = arcpy.da.SearchCursor(r"%s", ["PNTID"]) for row in rows: id=row[0]'''%shp c=timeit.timeit(s,number=10,setup='import arcpy') s=''' rows = arcpy.SearchCursor(r"%s") for row in rows: id=row.getValue("PNTID")'''%shp d=timeit.timeit(s,number=10, setup='import arcpy') e=timeit.timeit('for row in rows:id = row[0]', number=10,#run loop 10x and return average setup='import arcpy; rows = arcpy.da.SearchCursor(r"%s", ["PNTID"])'%shp) f=timeit.timeit('for row in rows:id = row.getValue("PNTID")', number=10, #run loop 10x and return average setup='import arcpy; rows = arcpy.SearchCursor(r"%s")'%shp) g=timeit.timeit('for row in rows:id = row[0]', number=10,#run loop 10x and return average setup='import arcpy; rows = arcpy.da.SearchCursor(r"%s", ["PNTID"])'%shp) h=timeit.timeit('for row in rows:id = row.getValue("PNTID")', number=10, #run loop 10x and return average setup='import arcpy; rows = arcpy.SearchCursor(r"%s", "", "", "PNTID")'%shp) print '1. da.SearchCursor:',a print '2. arcpy.SearchCursor:',b print '3. da.SearchCursor:',c print '4. arcpy.SearchCursor:',d print '5. da.SearchCursor:',e print '6. arcpy.SearchCursor:',f print '7. da.SearchCursor:',g print '8. arcpy.SearchCursor:',h
... View more
09-23-2013
08:32 PM
|
0
|
0
|
1776
|
|
POST
|
Firstly, read this: http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code Then do something like this: Expression: Reclass(!WELL_YIELD!,!Field_A!) Code Block: def Reclass(WellYield, Field_A):
if (WellYield >= 0 and WellYield <= 10):
return Field_A +90
elif (WellYield > 10 and WellYield <= 20):
return 2
elif (WellYield > 20 and WellYield <= 30):
return 3
elif (WellYield > 30):
return 4
... View more
09-18-2013
06:12 PM
|
0
|
0
|
881
|
|
POST
|
For example: Time 1 (2003): [ATTACH=CONFIG]27285[/ATTACH] Time 2 (2013): [ATTACH=CONFIG]27286[/ATTACH] Changes 2003-2013: [ATTACH=CONFIG]27287[/ATTACH] The difference image is the output of the Union tool and was symbolised using the "Categories"->"Unique values, many fields" renderer on the 2003 and 2013 name fields.
... View more
09-08-2013
06:09 PM
|
0
|
0
|
1736
|
|
POST
|
For example: Time 1 (2003): [ATTACH=CONFIG]27282[/ATTACH] Time 2 (2013): [ATTACH=CONFIG]27283[/ATTACH] Changes 2003-2013: [ATTACH=CONFIG]27284[/ATTACH] The difference image is the output of the Union tool and was symbolised using the "Categories"->"Unique values, many fields" renderer on the 2003 and 2013 name fields.
... View more
09-08-2013
05:34 PM
|
0
|
0
|
1736
|
|
POST
|
If you use the union tool, the output attribute table will contain all attributes from both input feature classes so can be used to identify areas that haven't changed and those that have, and what they have changed to and from.
... View more
09-07-2013
01:35 PM
|
0
|
0
|
1736
|
|
POST
|
Try the union tool http://resources.arcgis.com/en/help/main/10.1/index.html#//00080000000s000000
... View more
09-07-2013
03:50 AM
|
0
|
0
|
1736
|
|
POST
|
Try restarting the data reviewer service: http://resources.arcgis.com/en/help/install-guides/arcgis-data-reviewer/10.1/index.html#//00z800000011000000. If that doesn't work, try adding the location of that dll to your PATH environment variable.
... View more
08-30-2013
01:39 PM
|
0
|
0
|
378
|
|
POST
|
Out of curiosity, how did you know about the 0.10.1 requirement? I wasn't able to find a version requirement when I looked. Googlefoo 😉
... View more
08-28-2013
01:46 PM
|
0
|
0
|
678
|
|
POST
|
ArcGIS requires numpy 1.6.1.http://resources.arcgis.com/en/help/install-guides/arcgis-desktop/10.2/index.html#//008700000007000000 You'll need to reinstall numpy 1.6.1 and downgrade scipy to v 0.10.1 (or 0.11.0) http://sourceforge.net/projects/numpy/files/NumPy/1.6.1/ http://sourceforge.net/projects/scipy/files/scipy/0.10.1/
... View more
08-24-2013
02:21 PM
|
0
|
0
|
678
|
|
POST
|
Do you have ECW for ArcGIS Server installed and licensed? See http://geospatial.intergraph.com/products/other/ecw/ecw_for_arcgis_server/Downloads.aspx and http://support.esri.com/en/knowledgebase/techarticles/detail/36261 I don't know, but assume there's a similar requirement for MrSID.
... View more
08-18-2013
02:52 AM
|
0
|
0
|
2058
|
|
POST
|
The code block, which is simply a python function that takes an input and returns an output, should use a Python variable -- not field names. (The insertion of the field value for [fieldname] only happens in the expression block.)
Expression: FindLabel(![FIELDNAME]!)
Code:
def FindLabel(fn):
rs = fn[:3] # first three chars
ls = fn[3:] # characters four-> end
return "{0}+{1}".format(rs, ls)
In 10.1 there's no separate expression and code blocks, just an expression block in which you write the label function (in the Advanced view). The function def and the function code accepts field names: [ATTACH=CONFIG]26686[/ATTACH]
... View more
08-13-2013
03:09 PM
|
0
|
0
|
1393
|
|
POST
|
Square brackets work fine in the label expression (tested on 10.1) def FindLabel ( [FIELD_NAME] ):
rs = [FIELD_NAME][-2:]
ls = [FIELD_NAME][:-2]
return ls + "+" + rs
... View more
08-12-2013
06:18 PM
|
0
|
0
|
2798
|
|
POST
|
Can't edit my previous post for some reason...? Anyways: the following raster calculator expression is better as it will ensure that 0 values don't get included when the FocalStatistics expression is executed: Con("raster" == 0, FocalStatistics(SetNull("raster" == 0, "raster"), NbrRectangle(3, 3, "CELL"), "MAJORITY"), "raster")
... View more
08-11-2013
07:19 PM
|
0
|
0
|
650
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-24-2022 03:08 PM | |
| 1 | 07-30-2025 03:00 PM | |
| 1 | 06-10-2025 08:06 PM | |
| 5 | 05-20-2025 07:56 PM | |
| 1 | 05-04-2025 10:34 PM |