|
POST
|
Try adding the directory name to the source: mdblist.append(os.path.join("Z:\\COMMON\\GIS\\WORK\\Ron\\NEW", item))
... View more
08-23-2010
08:51 AM
|
0
|
0
|
800
|
|
POST
|
You would do something like this: a = "c:\\data\\my.gdb\\featureclass"
b = 5
func(a, b) No need to get sys.argv involved.
... View more
08-11-2010
12:13 PM
|
0
|
0
|
3044
|
|
POST
|
Typically you'd set it up to behave like a module: def mainfunc(a, b):
return do_some_stuff(a, b)
if __name__ == "__main__":
import sys
mainfunc(sys.argv[1], sys.argv[2]) Then you can call mainfunc(a, b) in the Python window once you've loaded it in. The interactive console's environment is slightly different than running a standalone script, just like in any other Python prompt (Pythonwin, Idle, etc).
... View more
08-11-2010
11:28 AM
|
0
|
0
|
3044
|
|
POST
|
Functionally they are the same, just getattr and setattr will work on any Python object, not just row objects.
... View more
08-10-2010
05:49 PM
|
0
|
0
|
770
|
|
POST
|
It can be done in Python, for the time being, with ReportLab (a third-party PDF authoring library). There's a demo script of this on the resource center: link.
... View more
08-10-2010
09:16 AM
|
0
|
0
|
1939
|
|
POST
|
Use the getattr builtin: InAge = gp.GetParameterAsText(0)
rows = gp.UpdateCursor("c:\temp\test.dbf")
row = rows.Next()
while row:
if getattr(row, InAge) == 25:
row.Range = "Mid"
... View more
08-09-2010
02:51 PM
|
0
|
0
|
770
|
|
POST
|
Set the Domain attribute on the Parameter object as a GPCodedValueDomain populated to your values.
... View more
06-07-2010
03:49 PM
|
0
|
0
|
378
|
|
POST
|
How about this: import arcpy, sys
mxd = arcpy.mapping.MapDocument("base.mxd")
prjList = "q:/python/prj/"
# Read in the coordinate system definition
prj = arcpy.SpatialReference(prjList+sys.argv[1]+".prj")
df = arcpy.mapping.ListDataFrames(mxd)[0]
df.spatialRefence = prj
mxd.save()
del mxd
... View more
05-26-2010
10:56 AM
|
0
|
0
|
1588
|
|
POST
|
In 10, you can add Geoprocessing tools to your toolbars from the Customize window. Any tool that has no parameters will execute immediately when you click its button, giving you a way to get command buttons more-or-less for free with your script tools. You can then code a wxPython or PyQT or TkIinter UI in the geoprocessing script.
... View more
05-09-2010
12:13 PM
|
0
|
0
|
1627
|
|
POST
|
Unfortunately, this is quite difficult to accomplish in 9.3.1, but in 10.0 you can use the __file__ global in script tools to determine the folder a script is running in. The same __file__ global can be used in script tools in 9.3.1, but only if the script is marked to run out of process (in the properties dialog). The recipe you'd use is: os.path.join(os.path.dirname(__file__), "my_sde.sde")
... View more
05-04-2010
09:17 PM
|
0
|
0
|
1894
|
|
POST
|
I second the use of the Python logging module for any large/long-running tool. It's fairly trivial to add logging handlers that post to gp.addMessage and gp.addError when the severity level of a logging message is high enough, and you can log less important messages to log files for later inspection, etc.
... View more
04-29-2010
08:45 AM
|
0
|
0
|
732
|
|
POST
|
So something like this: import arcpy
import os
arcpy.env.workspace = r"c:\data\file.gdb"
my_mxd = arcpy.mapping.MapDocument(r"c:\path\to\my.mxd")
data_frame = arcpy.mapping.ListDataFrames(my_mxd)[0]
# Switch to data view
my_mxd.activeView = data_frame.name
# Load standard layer with symbology, append to TOC in first data frame
my_layer = arcpy.mapping.Layer(r"c:\path\to\some.lyr")
arcpy.mapping.AddLayer(data_frame, my_layer, 'TOP')
# Loop through rasters in workspace, swap out layer's source with raster's
for fcname in arcpy.ListRasters():
# Full path to raster
new_raster = os.path.join(arcpy.env.workspace, fcname)
# Set layer's source
my_layer.dataSource = new_raster
# Zoom to extent
df.extent = arcpy.Describe(new_raster).extent
# Save to disk
my_mxd.saveACopy("c:\\output\\out_%s.mxd" % fcname)
... View more
04-28-2010
03:24 PM
|
0
|
0
|
3699
|
|
POST
|
%installdir%\bin Alternately, add os.environ["PATH"] += r";c:\program files\arcgis\desktop10.0\bin" to the very top of your Python script so it adds the ArcGIS install's bin to the DLL import path. You might want to make it more robust by looking for the correct install path with _winreg.
... View more
04-08-2010
01:10 PM
|
0
|
0
|
798
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-26-2012 02:46 AM | |
| 2 | 01-06-2011 08:22 AM | |
| 1 | 03-25-2014 12:18 PM | |
| 1 | 08-12-2014 09:36 AM | |
| 1 | 03-31-2010 08:56 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:22 AM
|