|
POST
|
When running the model using the custom toolbar, the layer is removed from the TOC, and also should be added to display-because it's checked on. But, when i right click the model, go to edit, and then run within the mxd the layer is not removed, and the most current buffer is added to display. Jake - you need to set it up as an output parameter. From the help: Note: Add To Display has no effect outside ModelBuilder. When running a model tool from its dialog box or the Python window, the Add To Display setting will not be honored. To add model data variables to the display when running the model from its dialog box or the Python window, make the data variable a model parameter, then enable the Add results of geoprocessing operations to the display option from the Standard toolbar: Geoprocessing > Geoprocessing Options > Add results of geoprocessing operations to the display Desktop 10.1 Help: Displaying model data
... View more
04-25-2013
09:30 AM
|
0
|
0
|
697
|
|
POST
|
newList is a list of field names, there should be 72 items in it Apparently not, if you're getting that error. I suggest using a try-except block to find which line is causing the problem (see my code for an example).
... View more
04-25-2013
09:16 AM
|
0
|
0
|
1327
|
|
POST
|
What is your ArcGIS version and SP? (See Help > About ArcMap) If not on the most recent, do update!
... View more
04-24-2013
10:27 AM
|
0
|
0
|
3257
|
|
POST
|
I keep getting a �??list index out of range�?� error message when doing this. How many fields are there in the line? If you only have 10, lineList[36] will raise an out of range error. Here's another shot at this:
# skip 5 rows
skipRows = 5
for n in range(skipRows + 1):
line = inFile.readline()
row = skipRows + 1
# read and clean up data
while line:
print 'Row', row, 'line info=', line[:72]
# clean line and split into list
lineList = [f.strip().replace("/","_") for f in line.split(',')]
print 'line info =', lineList
latidx,lonidx = 36, 37 # lat and long are in field 36 and 37
if len(lineList) > lonidx:
raise Exception, "line {0} too short".format(row)
for k in latidx, lonidx:
if lineList == "":
lineList = 0
outFile.write(','.join(newList) + "\n")
line = inFile.readline()
row += 1
... View more
04-24-2013
08:03 AM
|
0
|
0
|
1327
|
|
POST
|
If you construct a an intermediate filename using a built-in variables, the system won't modify them when the model is validated. (Note, %scratchfolder% is 10.1 only, %scratchworkspace% would be used in earlier versions). For example: %scratchfolder%\clip_%n%.tif will be interpreted at runtime as D:\work\scratch\clip_0.tif D:\work\scratch\clip_1.tif ... Depending on the iteration, the built-in iteration variable used could be either %n% or %i%. Hope this helps!
... View more
04-24-2013
07:31 AM
|
0
|
0
|
3257
|
|
POST
|
Neda, Please post your Python code in a code block. [thread=48475]Here's how.[/thread] 1. You may want to look into the Split Raster tool. It may be a lot easier to tile your data using that instead of making fishnets and using this scripting approach. 2. I did some once off code (not tested) to help you with working out how a script would work:
# only import arcpy - don't use arcgisscripting/gp at 10.x
import arcpy
from arcpy import env
arcpy.env.overwriteOutput = True ## 1
# in_fc is your polygon feature class
in_fc = r"X:\mohammadi\finalmunichGIS\clip0ffishnet9000\shapefilesoffc\fc_parent1"
# in_tif is your input
in_raster = "X:\mohammadi\finalmunichGIS\Testdaten-original data\munich_subset.tif"
# output location
outGDB = r"X:\mohammadi\finalmunichGIS\munich.gdb"
arcpy.MakeFeatureLayer_management(in_fc,lyrFC)
# get list of object ids
objIDs = []
objIDField = arcpy.Describe(lyrFC).OIDFieldName
Rows = arcpy.SearchCursor(lyrFC)
while Row in Rows:
objIDs.append(Row.getValue(objIDField))
del Row, Rows
# temp polygons
tmpFC = "in_memory/tmpPoly"
# one by one clip raster to polygons
arcpy.env.workspace= outGDB
for objID in objIDs:
where = "{0} = {1}".format(objIDField,objID)
arcpy.SelectLayerByAttributes_management(lyrFC,where)
arcpy.CopyFeatures_management(lyrFC,tmpFC)
ext = arcpy.Describe(tmpFC).Extent
extString = "{0} {1} {2} {3}".format(ext.XMin, ext.YMin, ext.XMax, ext.YMax)
out_raster = "clip{0}".format(objID)
arcpy.Clip_management(in_raster, extString, out_raster, tmpFC)
print arcpy.GetMessages(0)
arcpy.Delete_management(tmpFC)
... View more
04-22-2013
03:25 PM
|
0
|
0
|
9099
|
|
POST
|
I am trying to calculation the correlation coefficients for 26 environmental variables. When I put in some of my rasters, I get the following error message. ERROR 010240: Could not save raster dataset to E:\..... with output format GRID Stack 7.x. Failed to execute (BandCollectionStats). 1. It could be a path name issue The output grid stack name must be short (<10 characters), must start with a letter, and must not contain any non alphanumeric characters except "_". This is a limitation of the Esri grid format. (The extra-short 10 characters is because a grid stack needs to create output grid names <gridname>_c1, etc.). It's possible that some older and little-used tools may still need to write to the grid format as an intermediate step even if the destination is a tiff, so these naming limits may apply even for tiff output in this case. There are bugs sometimes if the path itself contains spaces or special characters, but these issues are becoming more rare with each version of ArcGIS. Encapsulating paths within the raster object at 10.x helped a lot with this. 2. There may be a file size problem with the raster table COUNT for a value. If an integer raster exceeds the 2.1G limit of COUNT for a values in an integer raster table, the raster attribute table build will fail. This usually brings up a different error message, but it's another possibility. This is a hard limit and you may need to tile your data to get it to work. The way to check this is to process a smaller area of the raster (by setting a limited geoprocessing extent) and seeing if it works with a smaller output. This is always a good idea when working out a complex processing chain so you don't have to wait a long time for tools to run that are just going to crash because of some issue you must resolve. When it's all working, you can just reset the extent and run it "for real". Another useful tip - especially when processing large rasters, set the output and scratch workspace to the same location (preferably a folder so the tired-and-true grid format is used). When a tool completes, the output raster can then be renamed instead of copied from scratch to current workspace paths.
... View more
04-22-2013
03:11 PM
|
0
|
0
|
1097
|
|
POST
|
Here's my response to Jordan copied from my email earlier today, with some edits for clarity: Jordan, I totally agree that it's tricky to integrate the two environments. Haven't tried Canopy yet, but I understand Canopy is pretty much the same with a juiced up UI and improved setup tools. I really do believe that the best way to handle this is to install python from the ArcGIS distribution, and separately install Canopy. (You need EPD 32-bit to import 32-bit arcpy and EPD 64-bit to import 64-bit arcpy.) If you install EPD 32 and 64 and ArcGIS Desktop x64 background geoprocessing, this adds up to no less than four python distributions to deal with. Jason Pardy from Esri suggested I just try putting the site-packages folders in the python path. From ArcGIS I have been successful accessing EPD packages by adding a similar .pth file to the ArcGIS python install site-packages folder. I haven't run into any problems with "circular searches", I think Python is smart enough not to look in a site-packages folder twice. One way to modify the Python path is to copy the file Desktop.pth from \Python27\ArcGIS10.1\lib\site-packages to the file zzArcGIS.pth in the 32-bit Canopy site-packages folder (the paths are loaded in alpha order). This should allow you to import arcpy just fine on the Canopy side. Another approach is to just add the paths to the PYTHONPATH variable (see bat scripts below). bat scripts are especially useful if you find you need full control of the PATH and other environment variables to get things to work right. I've attached an example. The way it's done in UNIX -- much less ugly than registering DLLs and messing with globally-applied environment variables! (When you run the scripts, the environment tweaks only apply to the shell and its children, not your global environment.) A few examples are attached:
:: epd32arc.bat
:: start EPD32 python prompt with arcpy
@echo off
set EPDPATH=E:\python27_epd32
set AGSPATH=D:\ArcGIS\Desktop10.1
:: save paths
set PATHENV=%PATH%
set PPATHENV=%PYTHONPATH%
:: set paths EPD with access to arcpy
set PATH=%EPDPATH%;%EPDPATH%\scripts;%PATH%
set PYTHONPATH=%PYTHONPATH%;%AGSPATH%\bin;%AGSPATH%\arcpy;%AGSPATH%\ArcToolbox\Scripts
cmd /c %EPDPATH%\python.exe
:: restore paths
set PATH=%PATHENV%
set PYTHONPATH=%PPATHENV%
:: delete variables
set EPDPATH=
set AGSPATH=
set PATHENV=
set PPATHENV=
:: arcmap_epd.bat - start ArcMap with EPD32 libraries available
@echo off
:: set the paths below to your install locations
set EPDPATH=E:\python27_epd32
set AGSPATH=D:\ArcGIS\Desktop10.1
:: save paths
set PATHENV=%PATH%
set PPATHENV=%PYTHONPATH%
:: set paths for ArcMap w/ EPD
set PATH=%EPDPATH%;%EPDPATH%\scripts;%PATH%
set PYTHONPATH=%PYTHONPATH%;%EPDPATH%\lib\site-packages
echo Starting ArcMap w/ Enthought Python Distribution modules...
start /b /d %AGSPATH%\bin ArcMap.exe
:: restore paths
set PATH=%PATHENV%
set PYTHONPATH=%PPATHENV%
:: delete variables
set EPDPATH=
set AGSPATH=
set PATHENV=
set PPATHENV=
... View more
04-22-2013
02:41 PM
|
0
|
0
|
4170
|
|
POST
|
This is done by modifying the Layer object's definitionQuery property. There are several examples to get you started in the help here: Desktop 10.1 Help: (arcpy.mapping) import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd") df = arcpy.mapping.ListDataFrames(mxd)[0] # first data frame lyrs = arcpy.mapping.ListLayers(mxd, "" , df) fixLayers = ["Test1 polygon","Test2 polygon"] newParcel = 5 for lyr in lyrs: if lyr.name in fixLayers: lyr.definitionQuery = "parcel_no = {0}".format(newParcel) arcpy.RefreshActiveView() del mxd # release the object (the map will not be deleted)
... View more
04-22-2013
04:44 AM
|
0
|
0
|
2682
|
|
POST
|
Help reference - Desktop Help 10.1: Adding an ASCII or text file table See the section: Overriding how text files are formatted
... View more
04-22-2013
04:23 AM
|
0
|
0
|
2223
|
|
POST
|
I did not rule out a spatial join. When I solved this issue with tables I did use a spatial join. But joins do take a long time and I thought a cursor could be faster. Now I want to solve this issue programmatically. Why are nested cursors a bad idea? I don't think there's a problem with nested cursors, as long as the datasets accessed inside the loops don't participate in the cursors. A cursor opens a file lock on the table you opened, so if you run a tool that accesses that dataset you are accessing it twice at the same time -- this is what can get you into trouble. Your example does not do this. Feel free to try this, but if there's a tool that will do the same thing, it's unlikely a cursor would be faster because most standard tools are written in C++, which will usually be much faster than Python. In my experience, the most effective way to speed up a really slow geoprocessing workflow is to try a different approach that more efficiently solves your problem.
... View more
04-22-2013
04:19 AM
|
0
|
0
|
1833
|
|
POST
|
If I'm understanding this right, the Slice tool could be used to find the area value at a given percentile. However, this could be derailed by the fact that the distribution of cell drainage areas is dramatically skewed, to the point where calculating a area distribution curve may be problematic. Most cells in a basin will have very small drainage areas, and just a few (in the drainage) have very large drainage areas.
... View more
04-18-2013
08:55 PM
|
0
|
0
|
940
|
|
POST
|
Is the legend property checkbox set to FixedFrame in the ArcMap interface? The help implies that that has to be the case for this property to be used.
... View more
04-18-2013
08:48 PM
|
0
|
0
|
1071
|
|
POST
|
This is where the repr() function comes in very handy: sqlSel = arcpy.GetParameterAsText(1) fo.write("sqlSel = {0}\n".format(repr(sqlSel)))
... View more
04-18-2013
08:43 PM
|
0
|
0
|
1123
|
|
POST
|
Sorry, I didn't quite get the picture. Clearly the validation is behaving differently inside Model Builder. I don't know why that should be the case. Another thing that bugs me about Field Calculator vs Calculate Field is that in table view when you right click a field and choose Calculate... the interface is similar, but not the same as, the real Calculate Field tool (that it eventually runs). Would be less confusing if they were the same! Both these issues are definitely worth submitting in an incident or on ideas.arcgis.com.
... View more
04-17-2013
05:19 PM
|
0
|
0
|
1186
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-11-2021 01:26 PM | |
| 5 | 12-10-2021 04:58 PM | |
| 1 | 02-27-2017 09:30 AM | |
| 2 | 12-04-2023 01:05 PM | |
| 1 | 04-12-2016 10:17 AM |
| Online Status |
Offline
|
| Date Last Visited |
06-19-2024
12:10 AM
|