|
POST
|
Seems to me you could do this in ModelBuilder with the standard tools -- using the Calculate Value tool to run a little python script to calc the percentiles using an update cursor. Any takers?
... View more
09-27-2011
10:18 PM
|
0
|
0
|
6505
|
|
POST
|
For example upload a shapefile, parse the content, send string back to client, so web map can plot it. Or there is better way to do it. Thanks. Steve Python has standard modules to access data via ftp or http. (urllib comes to mind) - gp/arcpy would only be needed you were trying to access data from a GIS or SDE server.
... View more
09-27-2011
10:07 PM
|
0
|
0
|
720
|
|
POST
|
Instead of doing multiple replaces of any character you may get, I suggest using the ValidateTableName arcpy method. This requires that you write a little python script in the code block, but it is likely to be more effective. Note only grids have the 10-character limitation. Here I'm using the python os module instead of the Parse Path tool in modelbuilder to take the path apart and put it together. I am convinced a good understanding of Calculate Value and a little python is necessary to leverage the full power of ModelBuilder. Calculate Value tool Expression: ValidatePath(r"%Output Raster%") (The "r" and quotes are required -- so the path is read correctly.) Code block: def ValidatePath(ds):
import arcpy
import os
# extract pathname
dspath = os.path.dirname(ds)
dsname = os.path.basename(ds)
# fix weird characters in dataset name
dsname = arcpy.ValidateTableName(dsname,dspath)
# for grids, truncate to 10 characters
dsname = dsname[:10]
return os.path.join(dspath,dsname)
... View more
09-27-2011
09:49 PM
|
0
|
0
|
2185
|
|
POST
|
This has been a major problem for me in the past and I posted the problem with personal geodatabases some time ago. The issue was supposed to be fixed with file geodatabases, but I've experienced problems. Schema locks are not "going away" because they are critically needed to prevent destruction of geodatabase data. Personal geodatabase locks were a pain because a lock applied to the entire geodatabase (.mdb file). File geodatabase locks still exist, but they only applied to one feature class or table at a time. The help has been updated with some very useful details on this topic: '>Schema locking File geodatabases and locking
... View more
09-23-2011
12:20 PM
|
0
|
0
|
956
|
|
POST
|
The field list can be gotten by describing the feature class or table view you created the cursor from. (And of course, you can control which fields are included in the cursor by specifying them when creating the cursor.) FieldObjects = arcpy.Describe(tbl).Fields
FieldNames = [f.Name for f in FieldObjects] # field name strings in a list
Rows = arcpy.UpdateCursor(tbl)
for Row in Rows:
for f in FieldNames:
print f, str(Row.GetValue(f))
print
... View more
09-21-2011
07:32 PM
|
0
|
0
|
997
|
|
POST
|
Have you tried deleting the feature layer you created with arcpy.Delete_management? The way I usually do it is this: lyrPoly = "lyrPoly"
arcpy.MakeFeatureClass(fc,lyrPoly)
...
arcpy.Delete_management(lyrPoly)
... View more
09-21-2011
07:23 PM
|
0
|
0
|
956
|
|
POST
|
Nancititla;135527 wrote: # Se valida los datos de entrada seleccionados por el usuario
dem = arcpy.GetParameterAsText(1) # Modelo Digital de Elevación
usosuelo = arcpy.GetParameterAsText(2) # Uso de suelo y vegetación
precipitacion = arcpy.GetParameterAsText(3) # Precipitación
geologia = arcpy.GetParameterAsText(2) # Geología Have you noticed that you are assigning precip and geology to the same input argument??
... View more
09-21-2011
07:15 PM
|
0
|
0
|
1154
|
|
POST
|
I personally like to use string substitution. This has the added benefit of being easier to read. sqlExpr = "\"Wall_num\" = %s" % row.getValue(field.name)
arcpy.SelectLayerByAttribute_management ("wall_select", "NEW_SELECTION",strExpr) For string fields you can put the single quotes in like this: sqlExpr = "\Wall_num\" = \'%s\'" % row.getValue(field.name)
... View more
09-19-2011
10:37 AM
|
0
|
0
|
898
|
|
POST
|
Just a little note - you can strip whitepace at the right side of a string using the built-in rstrip() function: >>> "a\n".rstrip()
'a'
... View more
09-19-2011
10:28 AM
|
0
|
0
|
7940
|
|
POST
|
I also couldn't get the fieldInfo() methods to work In your code example you are trying to modify a read-only describe object, not the layer the describe object was created from. I think the most straighforward way would be to create a new layer with MakeFeatureLayer, setting the field properties in the arguments. A less straightforward way would be to dive into arcpy.mapping's layer object. (Suggestions from arcpy.mapping mavens to this thread are welcome!)
... View more
09-19-2011
09:14 AM
|
0
|
0
|
3803
|
|
POST
|
Is there a data type that allows me to list row data from a specific field right within a script's UI? This can be done using script tool validation. Customizing script tool behavior (Arc 10.0 help)
... View more
09-19-2011
07:55 AM
|
0
|
0
|
725
|
|
POST
|
You need to give the output tables a unique name using a model variable, ie: out_table%n%.dbf When you're done you can run the Merge tool to put them together. If you want to automate this process, you need to nest models and in the "outside" model, use the Collect tool to pipe that in to the Merge tool. Hope this makes some sense. At least it's better than trying to iterate in 9.3!
... View more
09-15-2011
11:34 AM
|
1
|
0
|
1642
|
|
POST
|
@Daniel - This is just a lot of iterations and will take quite a while. I doubt if wrapping the Python script inside modelbuilder will buy you any speed, as long as you've checked the box to run the python script "in process". One approach to consider is grouping your input polys into some non-overlapping groups so you can them in parallel with a single run of zonal statistics. I have a script tool that makes an attempt but it's not good enough for me to feel okay putting it here. If interested in helping me with that project by testing it, contact me off line.
... View more
09-15-2011
11:31 AM
|
0
|
0
|
2433
|
|
POST
|
Many thanks to Jason Pardy for posting a helpful script tool template on the GP blog. Someone in the comments suggested the approach used by the Statistics Toolbox mavens using a function at the top of the tool to put the arguments up to for easy access, see: \Desktop10.0\ArcToolbox\Scripts\LocalMoran.py. What's really neat about both Jason's and the stats team's approach is that you can either (a) call it as a script tool or from the windows cmd line, passing it arguments though arcpy (if __name__ == "__main__":\) or (b) import it and run it as LocalMoran.localI(args) from another script, bypassing the toolbox interface altogether (which in my experience can be darn slow, especially in arc 10 when you need to run arcpy.ImportToolbox() first.) Any thoughts on this? """
Tool Name: Cluster/Outlier Analysis (Anselin Local Morans I)
Source Name: LocalMoran.py
Version: ArcGIS 10.0
Author: ESRI
...
import arcpy as ARCPY
import ...
...
def setupLocalI():
"""Retrieves the parameters from the User Interface and executes the
appropriate commands."""
inputFC = ARCPY.GetParameterAsText(0)
varName = ARCPY.GetParameterAsText(1).upper()
...
li = LocalI(inputFC, varName, outputFC, wType,
weightsFile = weightsFile,
rowStandard = rowStandard)
...
def ...
def ...
class localI(object) # actually does the work
...
if __name__ == "__main__":
setupLocalI()
... View more
09-13-2011
02:09 PM
|
1
|
3
|
4633
|
|
POST
|
I got an error at first that I had no FID field, my zonal feature had ObjectID instead of FID fields,... In Jamie's defense, this was kind of a once-off deal working with shapefiles. The more fancy way to do this (to support tables with different object ID field names) is: instead of hardcoding: strFID = '"FID" ='
...
arcpy.SelectLayerByAttribute_management(zone, newSelection, strFID + str(inRow.FID))
get the tables object id field name: strFID = arcpy.Describe(inputFeatureZone).OIDFieldName
...
strQry = '"%s" = %s' % (strFID, inRow.GetValue(strFID))
arcpy.SelectLayerByAttribute_management(zone, newSelection, strQry)
... View more
09-12-2011
08:23 AM
|
0
|
0
|
2433
|
| 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
|