|
POST
|
From the horses mouth, 2.7.x in all likelihood. http://forums.arcgis.com/threads/24523-Python-version-10.1?p=82222#post82222
... View more
06-15-2011
06:25 AM
|
0
|
0
|
2235
|
|
POST
|
A fairly broad question, but I thinking looping is what you are looking for. http://diveintopython.org/file_handling/for_loops.html If you are having trouble with the basics, my suggestion would be to start at the basics and take the arcpy processing portions out, they can complicate testing if you don't have a firm grip on what python is toiling on about. In place of whatever arcpy function you are calling, do a print statement on the variables that would have been passed into the tool so you see how variables are being passed/manipulated. That's how I learned python, anyway. The rest of the tutorials on the dive into python page are very good as well.
... View more
06-14-2011
07:12 AM
|
0
|
0
|
2235
|
|
POST
|
Have you tried just running this on your workspace to see what you get?
rsList = gp.ListRasters("*")
rsList.sort
for rs in rsList:
print rs
And I think the syntax for list sorting is .sort() I could be wrong though.
... View more
06-14-2011
06:58 AM
|
0
|
0
|
409
|
|
POST
|
FYI http://forums.arcgis.com/threads/26979-Deleting-Layout-Elements-with-arcpy.mapping Closest thing you can do is set height/width to zero.
... View more
06-09-2011
09:26 AM
|
0
|
0
|
762
|
|
POST
|
I'm not 100% sure what exactly it is you are trying to do, but this will fill in a "Rank" field based on another field of values sorted from lowest to highest.
print "Starting script"
import arcpy
arcpy.env.workspace = r"C:\GIS\Default.gdb"
Field = "<YOUR FIELD>"
currRank = 0
lastRank = 0
lastVal = None
rows = arcpy.UpdateCursor("<YOUR FC>", "", "", "<YOUR FIELD>,RANK", "<YOUR FIELD> A")
print "Starting loop"
for row in rows:
currVal = row.getValue(Field)
if currVal != lastVal:
currRank += 1
row.Rank = currRank
elif currVal == lastVal:
row.Rank = currRank
else:
print "Unexpected occurance"
lastVal = currVal
rows.updateRow(row)
del rows
print "Done"
... View more
06-09-2011
09:13 AM
|
0
|
0
|
1600
|
|
POST
|
Oh I think you might be right, I may have used field mappings before to set them.
... View more
06-02-2011
01:02 PM
|
0
|
0
|
848
|
|
POST
|
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v0000001p000000.htm has some good info on field properties This should get you started fields = arcpy.ListFields("layer")
for f in fields:
if f.name == "Something you want to change"
f.aliasName = "New Alias"
... View more
06-02-2011
12:40 PM
|
0
|
0
|
848
|
|
POST
|
Thanks for the help Dan. I ended up just projecting the dataset as a whole. I hadn't realized the project tool supported that.
... View more
05-26-2011
11:51 AM
|
0
|
0
|
456
|
|
POST
|
If arcpy is called from a server you have to have ArcGIS Server installed from what I recall.
... View more
05-25-2011
10:45 AM
|
0
|
0
|
1260
|
|
POST
|
Hi all, I am having some problems projecting data from a dataset into another dataset. The output always seems to go to the root output geodatabase location, instead of the defined dataset. I've tried making the output dataset the workspace and still it does not go there. Is this working as intended and I am just missing something? Here is the code below. I eventually hope to be able to loop through multiple datasets, but I have it hardcoded to just get it to do one for now. I am able to do other exports and I checked to make sure they have the same spatial reference. Any ideas?
sde = r"D:\sde_transit\sde1.gdb\\"
output = r"D:\sde_transit\sdeNAD83.gdb\\"
arcpy.env.workspace = sde
outCS = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Coordinate Systems\Projected Coordinate Systems\UTM\NAD 1983\NAD 1983 UTM Zone 12N.prj"
transformation = r"NAD_1927_To_NAD_1983_NTv2_Canada"
inCS = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Coordinate Systems\Projected Coordinate Systems\UTM\NAD 1927\NAD 1927 UTM Zone 12N.prj"
dsList = arcpy.ListDatasets("", "Feature")
fcList = arcpy.ListFeatureClasses("","",dsList[3])
for feature in fcList:
desc = arcpy.Describe(feature)
print desc.name
featout = output+dsList[3]+"\\"+desc.name
print featout
arcpy.Project_management(feature, featout, outCS, transformation, inCS)
... View more
05-25-2011
09:40 AM
|
0
|
2
|
674
|
|
POST
|
You might have some issues in your SQL formatting for your SelField between different data types. Differences between shapefile, personal or file GDB for example. See this for more info on it http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s500000033000000.htm Edit: But you don't really have any SQL in there so that probably isn't it. Does it only bomb out when you remove and readd the same layer? Under what other conditions does it not work? Have you tried running it as a stand-alone script with hard coded values and use a debugger to trace the problem?
... View more
05-24-2011
09:53 AM
|
0
|
0
|
3022
|
|
POST
|
http://docs.python.org/release/2.6.5/library/datetime.html Gives you all the info you need depending on how you want your date formatted.
... View more
05-18-2011
11:59 AM
|
0
|
0
|
742
|
|
POST
|
Hi all, I am trying to do a simple buffer on a point feature based on a calculated field in meters based on the area. However, the spatial reference is in WGS lat/long and will only take the field units as decimal degrees it seems. Is there a way to specify the field as a meter buffer in a lat/long feature? Or would I need to project it to something that will take meters? How I was doing it before was to select each feature as it goes through the cursor and buffer that to a separate feature then merging them together. Here is my code so far below. Tips, hints, suggestions? import arcpy, math
ws = r"C:\GIS\Fires"
arcpy.env.workspace = ws
fires_in = r"fires1.shp"
pi = math.pi
field_list = arcpy.ListFields(fires_in)
for field in field_list:
print field.name
rows = arcpy.UpdateCursor(fires_in)
for row in rows:
area = row.Burned
buffer_dist = math.sqrt((area*10000)/pi)
row.Buffer = buffer_dist
rows.updateRow(row)
#arcpy.Buffer_analysis(fires_in, "fire"+name+".shp", str(buffer_dist)+" Meters")
arcpy.Buffer_analysis(fires_in, "fire_buffer.shp", "Buffer")
del rows
del row
del field_list
del fires_in
... View more
05-17-2011
10:50 AM
|
0
|
2
|
747
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-17-2011 10:36 AM | |
| 1 | 08-16-2012 10:48 AM | |
| 1 | 10-31-2012 08:39 AM | |
| 1 | 07-16-2012 01:52 PM | |
| 1 | 03-15-2012 10:57 AM |
| Online Status |
Offline
|
| Date Last Visited |
08-22-2024
11:12 PM
|