|
POST
|
I have enjoyed using the Geoprocessing Commands Quick Reference Guide to help me overcome the complexity (and richness) of ArcGIS 9.3 in the past. Is their a similar Reference Guide available to help the novice ArcGIS modeller to select relevent python modules/tools/functions/classes? thanx Tom Hi Tom, Its not exactly like the tool reference guide, but have a look at pydoc in Python. You can open that from Python with these 2 lines. import pydoc
pydoc.gui() From the small pydoc dialog, click open browser, and click on arcpy (package). The first page will give you a list of arcpy functions, and you can navigate with a click to other modules (like the mapping module) with an additional click.
... View more
08-16-2010
11:50 AM
|
0
|
0
|
1171
|
|
POST
|
I've always used the text contained in the .prj file. That way you don't have to rely on having a valid path to the What I normally do to make my own code adaptable for location of the installed .prj files (or for that matter any of the installed files), is to use GetInstallInfo like below: prjFile = os.path.join(arcpy.GetInstallInfo()['InstallDir'],
"Coordinate Systems/Geographic Coordinate Systems/World/WGS 1984.prj")
sr = arcpy.SpatialReference(prjFile) -Dave
... View more
08-11-2010
02:40 PM
|
0
|
0
|
1563
|
|
POST
|
As a workaround, I was able to get much better precision if I applied a SpatialReference object to the class' 2nd parameter. Not ideal of course, but better than the alternative. I've had some offline discussions recently about the best way to create a SpatialReference object for these circumstances; specifically regarding IsLowPrecision, IsHighPrecision. If you're describing data, most data is now high precision (unless you're working with an earlier version personal geodatabase or SDE geodatabase). So if describing a 9.1 personal geodatabase feature class, and using it's spatialreference property, and you would get a low precision geometry. You could try and manipulate the SpatialReference object, but adjusting a single property on a SpatialReference is fraught with perils (and likewise manipulating the string equivalent of the SpatialReference). Its not as easy as just modifying a property, as many properties of the SpatialReference are interconnected. A better way of ensuring HighPrecision would be creating a spatial reference not via data source, but a .prj file. sr = arcpy.SpatialReference(r"C:\Program Files\ArcGIS\Desktop10.0\Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj") -Dave
... View more
08-11-2010
01:57 PM
|
0
|
0
|
1563
|
|
POST
|
Yes, I think Charles has a way of running that script 'as is'. Although for the original case, the arguments will be coming in as strings, so if the inputs are 1 and 2, the answer will be 12 (adding "1" to "2") vs 3--which could be accomplished by something like x = int(sys.argv[1]) Correct me if I am wrong, but it seems like the Python window is basically just an interactive window (not a full blown IDE), and not really geared for running a full script in (just one line at a time). It's all about how you organize your code. The more 'pythonic' way would be to organize the code into function(s), which is very easy to just call, and without having to run the script as a file. -Dave
... View more
08-11-2010
01:37 PM
|
0
|
0
|
1365
|
|
POST
|
and what is the syntax for calling a .py script ? I can't just type the name of the python file into the command line. I have used methods like os.execl, etc. (see more on http://docs.python.org/library/os.html) to call a file directly (including .py's) with varying levels of success. But that's not going to run in process or anything, and passing in arguments like a layer in your current map isn't going to work. Jason's approach will be the cleanest way to do it. -Dave
... View more
08-11-2010
12:28 PM
|
0
|
0
|
2885
|
|
POST
|
I will update this thread shortly when I have a proper Nimbus ID to track on. I'm marking this issue as candidate for 10.0 sp1. The Nimbus ID is NIM059845
... View more
08-09-2010
04:57 PM
|
0
|
0
|
1563
|
|
POST
|
Hi Dan, I appreciate your concern, and thanks for bringing light to the problem. Looks like the geometry is essentially low-precision when created in this way. As a workaround, I was able to get much better precision if I applied a SpatialReference object to the class' 2nd parameter. Not ideal of course, but better than the alternative. # sr being a SpatialReference
poly = arcpy.Polyline(array, sr) I will update this thread shortly when I have a proper Nimbus ID to track on. I'm marking this issue as candidate for 10.0 sp1. -Dave
... View more
08-09-2010
04:43 PM
|
0
|
0
|
3388
|
|
POST
|
Hi, I believe this is what you would want: Expression: convertDate(!DATE_LCL!) Code block: def convertDate(sdate):
yyyy = sdate[-4:]
dd = sdate[4:6]
if sdate[6:9] == 'Jan':
mm = "01"
elif sdate[6:9] == 'Feb':
mm = "02"
else:
mm = "99"
return yyyy + dd + mm Basically, you need to create a Python function in the code block (this is the def), and call that function from the expression. The use of ! for delimiters is something that you use only in the expression--it is just a way of passing a field value down to the function. In the function, you assign the incoming value a variable name, in this case sdate. It easy to test these directly in Python. If you created a new Python script, add this function above in the top, and add an additional line, something like... newdate = convertDate("Thu 15Jul2010")
print newdate ... this will give you a very quick idea if your code is working (and if not, will be easy to debug). -Dave
... View more
08-06-2010
08:09 AM
|
0
|
0
|
455
|
|
POST
|
huffmanp;30014 wrote: Now the script throws an error "ImportError: No module named WService" when I run on the field office server, although back at my office it found WService Class just fine in line within the script. What could be the difference between these scripting environments? QUOTE] I'm not familiar with WService (I presume you're working with something like this: http://code.activestate.com/recipes/115875-controlling-windows-services/ ? In any case, I would compare sys.path between the two machines, and see what the differences are. Perhaps, it's just a matter of updating PYTHONPATH or one of your .pth files, etc. to see the location of WService. -Dave
... View more
08-04-2010
03:56 PM
|
0
|
0
|
2498
|
|
POST
|
ERROR 999999: Error executing function. A locator with this name does not exist. Failed to execute (Warp). Does anybody know what the "locator" refers to ? Almost anytime you see the A locator with this name does not exist error, treat it as a red herring--something that is just going to distract you from finding the real cause of the problem. Speaking generally, this error results from a geoprocessing tool not seeing the input as valid, but that could also just mean that we are handling something incorrectly and an error has ensued. The very, very last check that happens in some of these cases, has to do with locators, which really means nothing most of the time. Unfortunately, that gives you little to go by. I see any error like this as a situation that needs to be resolved on our end. If you are unable to sort out a solution, please, engage Support to help have the issue resolved. -Dave
... View more
08-04-2010
01:07 PM
|
0
|
0
|
377
|
|
POST
|
Hi Paul, Another option, is to install PythonWin (not installed with ArcGIS, but is included on the installation media) which would also give you access to win32api (plus win32ui, win32com, etc.). -Dave
... View more
08-04-2010
11:57 AM
|
0
|
0
|
2498
|
|
POST
|
I have a model which, in theory, runs the watershed tool, converts the raster to polygon, adds "WS_Area" field and calculates it, uses "make feature layer" to select polygons less than 10000 square meters and "eliminate"s them. Before the model even runs I get a message box with the following errors: [indent]"Field WS_Area does not exist within table Input must be polygon Input features: value is required output layer: value is required"[/indent] Yes, it looks like the output data elements are not getting the shape type correct in one of the steps. I was able to reproduce here using a similiar scenario. On my end, I was able to work around this by running just the RasterToPolygon tool in the model, and then re-validating the model. -Dave
... View more
08-03-2010
04:41 PM
|
0
|
0
|
952
|
|
POST
|
Hi. I couldn't find any solution to the below described problem in the forum. Please let me know if there is a such thread or if you know how to solve it. I have checked the "Overwrite the output of geoprocessing operations" in the Tools->Options->General window in ArcMAP 9.3.1. But when I am runing the same model second time, I am getting an error message: ERROR 000210: Cannot create output... If I am manually removing the output files generated from the first run, the model works fine. But again for the next run it gives the same error. It seems that the "Overwrite the output of geoprocessing operations" parameter is not haveing any influence. Please let me know if you have any idea what is wrong here. Thanks in advance. What tools are you working with in your model? Also, does this page help?: http://help.arcgis.com/EN/ArcGISDesktop/10.0/help/index.html#//00vp0000000n000210.htm -Dave
... View more
08-03-2010
04:29 PM
|
0
|
0
|
1617
|
|
POST
|
Thats awesome. If you have two two features, each in a separate feature class, aFeature and bFeature, could this method of checking polygon intersection be used to see if aFeature intersects aFeature and if so write an attribute of bFeature to a field in aFeature? Hi clm42, Yes, and no. You could definitely use this general approach, but geometry objects don't hold attribute information. So instead of using the approach of getting geometry as output from geoprocessing tools (as most of the code in this thread shows), you'd have to open some cursors. The cursor will then give you both the geometry and attribute information for a feature. -Dave
... View more
08-03-2010
03:11 PM
|
1
|
0
|
3471
|
|
POST
|
Try this code (modify as you need). It creates a new sub folder name 'projected', and creates new copies of the geodatabases and populates them with projected versions of the datasets and featureclasses from the originals. I've hard-coded a couple things, including the starting workspace, and change the coordinate system and transformation as needed. For the coordinate system, I'm pointing to a .prj file on disk. import arcgisscripting, os
gp = arcgisscripting.create(9.3)
gp.overwriteOutput = True
gp.workspace = "c:/temp/base"
outputCS = gp.CreateObject("SpatialReference")
outputCS.createFromFile(os.path.join(gp.getinstallinfo()['InstallDir'],
"Geographic Coordinate Systems/North America/NAD 1927.prj"))
transformation = ""
outFolder = os.path.join(gp.workspace, "projected")
gp.CreateFolder_management(*os.path.split(outFolder))
for gdb in gp.ListWorkspaces("", "ACCESS"): # Get all personal geodatabases
gp.workspace = gdb
gdb = os.path.basename(gdb)
toProject = gp.ListFeatureClasses() + gp.ListDatasets()
gp.CreatePersonalGDB_management(outFolder, gdb)
gp.BatchProject_management(toProject,
os.path.join(outFolder, gdb),
outputCS,
"",
transformation)
... View more
08-03-2010
02:25 PM
|
0
|
0
|
519
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-06-2024 11:22 AM | |
| 2 | 01-31-2024 06:09 PM | |
| 1 | 01-11-2024 02:10 PM | |
| 1 | 05-31-2016 02:41 PM | |
| 2 | 01-05-2015 10:34 AM |
| Online Status |
Offline
|
| Date Last Visited |
05-23-2025
11:14 AM
|