POST
|
You can use sets to find the unique values of a bunch of values...
... View more
10-31-2013
01:07 PM
|
0
|
0
|
300
|
POST
|
Try making the bottom part just: for points in range (0,RangeCount):
FID = "FID=%s" % (points)
##Get bare earth elevation of parcel
#extract parcel raster cells
arcpy.SelectLayerByAttribute_management(PointsFL,"NEW_SELECTION",FID)
print arcpy.GetMessages(), "\n\n"
arcpy.SelectLayerByLocation_management(footprintFL,"INTERSECT",PointsFL)
print arcpy.GetMessages(), "\n\n"
outExtractByMask = ExtractByMask(BareElevation,footprintFL)
outExtractByMask.save(IntermediateFiles+"\\fp_1")#+str(1)+"_"+str(FID)[4:])
print arcpy.GetMessages(), "\n\n"
print "done" I have had trouble wrapping stuff in try...except statements before. In reality you want to know if something throws an exception...
... View more
10-31-2013
12:56 PM
|
0
|
0
|
690
|
POST
|
You need the 64-bit version (to match your Python), and I think it needs to be an older one like 0.10 or 0.11 64-bit versions that old aren't available from the normal Scipy page, but you can google "64 bit scipy" and should be able to find some compiled binaries...
... View more
10-29-2013
01:48 PM
|
0
|
0
|
302
|
POST
|
You have a single slash in the destination layer name: arcpy.CopyFeatures_management(mapLyr1, "in_memory\pyLyr1") You have a few options: "in_memory\\pyLyr1"
"in_memory/pyLyr1"
r"in_memory\pyLyr1" If that doesn't help, you could try changing it to MakeFeatureLayer instead of CopyFeatures...
... View more
10-24-2013
12:21 PM
|
0
|
0
|
111
|
POST
|
Typically a computer will read data from disk into RAM, select from RAM and pass to CPU for calculation, the result is passed back to RAM, then it is written to disk. The computer pretty much does this when you do any calculation (note that database management systems, including ArcGIS, are heavily optimized to try and do this as fast as possible, and will not load the whole dataset into memory at one time unnecessarily). The advantage of in_memory is that operations in RAM are very fast, compared to reading/writing from a hard disk, and that you can skip some disk writes/reads if you are doing sequential calculations on a set of data. The more calculation steps you have between reading and writing, the greater the potential benefit of using in_memory. However, if you are only doing one calculation, using in_memory may be no faster (and possibly slower, given the additional steps) than calculating directly. I understand that in_memory is good until it's all used up and then it's super slow. Correct. If your computer has 2GB of RAM installed (physical memory), about 1.5 might be available for processes to use. Sometimes this amount won't be enough, so modern operating systems take some disk space to be used as extra memory in emergencies, called virtual memory, which is stored in a Page file/Swap file. The idea is that it is better for your computer to slow down than crash if you put too much data into memory. Virtual memory is incredibly slow because it really isn't optimized like the original file was on the disk. Given the large number of read/writes required in any calculation it will usually completely choke up your computer. Now, Solid State Drives (SSDs) are a lot faster to read/write than HDDs, so the advantages of in_memory may completely disappear if you have a fast SSD... The number of features you are dealing with (130,000) is not particularly high, but it depends on the type and number of attributes you have associated with each feature. Obviously the amount of RAM you have will make a difference, and whether or not your setup is 64bit - this requires a 64bit operating system and ArcGIS 64bit background geoprocessing.
... View more
10-23-2013
05:23 PM
|
1
|
0
|
707
|
POST
|
OK. To get an extension to show up in the Extension dialogue you have to close and re-open ArcMap after installing the add-in... I also found that extensions will not show up at all in the Extension dialogue if there are errors, such as syntax errors, in the Python file for the add-in (which lives in the Install folder of the add-in). To test for these errors pass the file to the Python at the command line; if you get ImportError: No module named pythonaddins you don't have syntax errors (this is because the compiler checks for syntax errors before importing; I guess pythonaddins can only be imported from within ArcGIS, so it will fail here, getting to this point indicates that it has passed the syntax, etc., checks.)
... View more
09-29-2013
02:40 PM
|
0
|
0
|
660
|
POST
|
if pntcount % 3 == 0:
f.write('{0:12.1f}{1:12.1f}\n'.format(pnt.X,pnt.Y))
else:
f.write('{0:12.1f}{1:12.1f}\n'.format(pnt.X,pnt.Y)) The == sign tells it to test if the left side is equal to the right side, = is an assignment... You are also missing the newline from the second statement. I am guessing that the top problem caused it to always end up in the second statement, which was missing the newline. I have one other idea if these changes don't fix the problem, so please let me know.
... View more
09-29-2013
12:59 PM
|
0
|
0
|
213
|
POST
|
Interesting! I was in a rush when I did the post, and didn't see that when I took the screen shot! However, it is definitely not working all the time... I will do some more testing and post my findings.
... View more
09-29-2013
12:47 PM
|
0
|
0
|
660
|
POST
|
I would also recommend repeating a bunch of times and averaging - with (non-Arc) database applications I have seen a lot of variability. Cursor setup time should be noted as well! Most of the time users are probably doing small calculations, if da.SearchCursor takes a lot more time to set up, the increased speed of its operation may well be pointless...
... View more
09-25-2013
02:39 PM
|
0
|
0
|
948
|
POST
|
I realize how long it is, but it does work and that's what matters most to me. But since I'm still pretty new to scripting I'm very happy to learn other ways of coding. I have a little brushing up to do on matrices, but is it possible to replace my entire capacity function with a matrix or table and under the specific conditions a cell value is returned? It's not exactly the length of the code that is the problem, but the fact you do the exact same thing 400 times, that is: row.F[YEAR]_[DIR]_C = capacity(**dic) * lan[YEAR] It would not be particularly hard to write code to do what you want in about 20 lines... There are three main problems with your code at the moment that will affect you: it is very easy to make mistakes extremely hard to locate mistakes time consuming and difficult to make changes. To write code you need to figure out exactly what you are trying to do each step. I mean get a piece of paper and think the actual calculation steps through.
... View more
09-23-2013
01:02 PM
|
0
|
0
|
337
|
POST
|
The first thing I notice about your code is that there is a lot of repetition... Your first two conditions do exactly the same thing, and the third condition repeats it. Else: pass is not required. updateRow won't hurt anything if you have made no changes. You can also use in to test multiple conditions. This should work replicate the behaviour of your first code block (sorry, no way to test it!): #begin capacity calculation
if (row.BUILD_STAT == 10) and (row.F2010_DIR in [1, -1]):
row.F2010_AB_C = capacity(**dic) * lan
elif (row.BUILD_STAT == 10) and (row.F2010_DIR == 0):
row.F2010_AB_C = capacity(**dic) * lan
row.F2010_BA_C = capacity(**dic) * lan
rows.updateRow(row)
del row, rows Or was your repetition of row.F2010_AB_C = capacity(**dic) * lan a mistake? For your more advanced one you should note that each row only has one build_stat value, either 10, 19, 25 or 45. Furthermore you can use setValue to set a value by name. This should do what you want for your second code block (sorry, no way to test it!): import arcpy, os, sys
#set map doc and the layer to be used
mxd = arcpy.mapping.MapDocument("Current")
mapLyr = arcpy.mapping.ListLayers(mxd, "CUR_Master_Network_2045")[0]
rows = arcpy.UpdateCursor(mapLyr)
for row in rows:
row.F2010_AB_C = 0 #clear all capacities to 0
row.F2010_BA_C = 0
row.F2019_AB_C = 0
row.F2019_BA_C = 0
row.F2025_AB_C = 0
row.F2025_BA_C = 0
row.F2045_AB_C = 0
row.F2045_BA_C = 0
#find capacity variables
rnam = row.getValue("ROAD_NAM")
ffc = row.getValue("LRTP_FFC")
at = row.getValue("TYPE_AREA")
lan = row.getValue("F2010_NUML")
dic = {"ROAD_NAM": rnam, "LRTP_FFC": ffc, "TYPE_AREA": at}
#capacity calculation
yr = row.BUILD_STAT # any row can only have one year state...
if row.getValue('row.F20%s_DIR' % yr) in [1, -1]:
row.setValue('F20%s_AB_C' % yr, capacity(**dic) * lan)
elif row.getValue('F20%s_DIR' % yr) == 0:
row.setValue('F20%s_AB_C' % yr, capacity(**dic) * lan)
row.setValue('F20%s_BA_C' % yr, capacity(**dic) * lan)
rows.updateRow(row)
del row, rows
... View more
09-19-2013
05:04 PM
|
0
|
0
|
337
|
POST
|
I would guess you are not using the Python installed by ArcGIS. It is possible (but I think unlikely) that somehow the *.pth file got lost or messed up, but if it did Waynes solution will help. You could end up using the wrong Python if you already had it installed, or installed another Python after ArcGIS. The IDLE associated with ArcGIS Python is found here: Start Menu ... > ArcGIS > Python ... > IDLE (Python GUI) You can check the paths available to Python in IDLE with: File > Path Browser
... View more
09-17-2013
02:32 PM
|
0
|
0
|
193
|
POST
|
Stacy, I've had some success. I'm running late getting out of the office today, but I plan to write it all up on Monday. Your never going to believe how I got it to work. Sorry to leave you hanging in suspense over the weekend. Eric Great, look forward to hearing what works! Cheers, Stacy
... View more
09-15-2013
01:52 PM
|
0
|
0
|
806
|
POST
|
After creating an Add-In with Toolbar, Menu and Extension objects and doing Add From File... in the Customize dialog box only Toolbar and Menu objects are available. The Added Objects dialog after installing is shown below, note that no Extensions are listed (x.EsriAddin attachment). [ATTACH=CONFIG]27418[/ATTACH] The Toolbar and Menu objects can be accessed and added from the Customize dialogue, as is expected, but the Extension does not show in the Extensions dialog: [ATTACH=CONFIG]27422[/ATTACH] I have tried the add-in extension example specified in the docs, with the same result. This example only contains an Extension, which causes the Added Objects dialog box to show the following (arcAddin.EsriAddin attachment): [ATTACH=CONFIG]27419[/ATTACH] As above the Extensions dialog does not show the Add-In Extension... I have attached the corresponding files, as specified above. System Specs: ArcGIS 10.1 Desktop, SP1, 64bit Background Geoprocessing, Windows XP SP3
... View more
09-12-2013
09:07 PM
|
0
|
5
|
5105
|
Title | Kudos | Posted |
---|---|---|
1 | 03-02-2012 11:29 AM | |
1 | 01-13-2014 02:04 PM | |
1 | 09-26-2011 02:52 PM | |
1 | 10-23-2013 05:23 PM | |
1 | 04-01-2012 08:16 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|