|
POST
|
import arcpy, sys
workspace = sys.argv[1]
featureclass = sys.argv[2]
try:
arcpy.env.workspace = workspace
fields = arcpy.ListFields(featureclass)
for fld in fields:
print fld
except:
print arcpy.GetMessages()
The error I am getting is : >>> Traceback (most recent call last): File "C:\ArcpyBook\Appendix1\ListFields.py", line 3, in <module> workspace = sys.argv[1] IndexError: list index out of range >>>
... View more
03-08-2015
03:15 PM
|
0
|
5
|
5461
|
|
POST
|
Hi friend, Have you consider using Mosaic Dataset ? I'd start working with two first and then add two more to give you an idea. More information can be found here :ArcGIS Help 10.1 I just worked on this with NAIP I am working on for the whole state of New Mexico 2009, 2011,2012, and 2014.
... View more
03-07-2015
08:41 AM
|
0
|
7
|
1334
|
|
POST
|
Thanks. It is still not working though I do believe the Delete management had to do with it. What I did was drag around a boundary and nothing comes out..so I modifty to see what happens and this only works... so I put number sign next to 04 and 05 . See here: def onRectangle(self, rectangle_geometry):
extent = rectangle_geometry
arcpy.env.workspace = r"c:\ArcpyBook\Ch11"
#if arcpy.Exists('randompts.shp'):
#arcpy.Delete_management('randompts.shp')
randompts = arcpy.CreateRandomPoints_management(arcpy.env.workspace,'randompts.shp',"",rectangle_geometry)
arcpy.RefreshActiveView()
#return randompts
pass This was from the book I have on page 231 from Programming ArcGIS 10.1 with Python cookbook. I know probably it has change since then. The book was published in 2013.
... View more
03-01-2015
08:55 AM
|
0
|
2
|
1602
|
|
POST
|
You mean I just deleted was because of the same name ? I am still struggled with it and trying to do many different method even I looked at the CreateRandomPoints help on arcgis 10.1.
... View more
02-28-2015
08:35 PM
|
0
|
0
|
1602
|
|
POST
|
import arcpy
import pythonaddins
class ToolClassRandom(object):
"""Implementation for GenerateRandomPoints_addin.tool (Tool)"""
def __init__(self):
self.enabled = True
self.cursor = 3
self.shape = 'Rectangle' # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.
def onMouseDown(self, x, y, button, shift):
pass
def onMouseDownMap(self, x, y, button, shift):
pass
def onMouseUp(self, x, y, button, shift):
pass
def onMouseUpMap(self, x, y, button, shift):
pass
def onMouseMove(self, x, y, button, shift):
pass
def onMouseMoveMap(self, x, y, button, shift):
pass
def onDblClick(self):
pass
def onKeyDown(self, keycode, shift):
pass
def onKeyUp(self, keycode, shift):
pass
def deactivate(self):
pass
def onCircle(self, circle_geometry):
pass
def onLine(self, line_geometry):
pass
def onRectangle(self, rectangle_geometry):
extent = rectangle_geometry
arcpy.env.workspace = "c:\ArcpyBook\Ch11"
if arcpy.Exists("randompts.shp"):
arcpy.Delete_management("randompts.shp")
randompts = arcpy.CreateRandomPoints_management(arcpy.env.workspace,"randompts","randompts.shp","POINT",rectangle_geometry)
arcpy.RefreshActiveView()
return randompts Been trying to run this code to create an addin for the Generate Random Points. It gave me the error that says: Traceback (most recent call last): File "C:\Users\Pollock\AppData\Local\ESRI\Desktop10.1\AssemblyCache\{A6309427-3034-2E61-07C7-2A592C101F22}\GenerateRandomPoints_addin.py", line 41, in onRectangle return randompts UnboundLocalError: local variable 'randompts' referenced before assignment
... View more
02-28-2015
03:38 PM
|
0
|
6
|
5246
|
|
POST
|
So when I write this code df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0] print df.extent In return the numbers showed me 238135.744094489 3606562.79790026 494041.255905512 3787829.20209974 NaN NaN NaN NaN What does NaN NaN NaN NaN mean ? Is it laughing at me ?? No, I know ! what does it mean, BTW ! Thanks
... View more
02-27-2015
11:17 AM
|
0
|
3
|
4464
|
|
POST
|
When you add the python add in wizard, should it be saved under \USERS|your name|\Desktop\folder name ? Can I save it anywhere in C hard drive ? Thanks
... View more
02-27-2015
07:48 AM
|
0
|
1
|
1249
|
|
POST
|
My question IS how can we know if Pyscripter and ArcMap can communicate to each other BUT what if I want just run like a debug first before the actully work in ArcMap ? For example, you write the code and test it and shows it work and then you can run it either in Python Window or Pyscripter to get the results done ?
... View more
02-26-2015
01:07 PM
|
0
|
0
|
2097
|
|
POST
|
The imagery are set to NAD 1983 UTM Zone 13 N and the code I wrote are done in Pyscripter
... View more
02-26-2015
09:19 AM
|
0
|
1
|
1539
|
|
POST
|
Jake Skinner I tried to set the extent numbers in UTM but it would not allow me to... even I set the df as well... #Set the df to refresh the "Set Extent" df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] arcpy.env.extent ="MAXOF" newExtent = df.extent newExtent.XMin, newExtent.YMin = 210000,360000 newExtent.XMax, newExtent.YMax = 550000,400000 df.extent = newExtent
... View more
02-26-2015
08:28 AM
|
0
|
1
|
1539
|
|
POST
|
Hi evreyone, I am working on this exercise I am not sure of...but I believe there is an error in it. This is from the Programming ArcGIS 10.1 with Python cookbook on page 222 that says: import arcpy
import pythonaddins
class ButtonClassImportWildfires(object):
"""Implementation for WildfireAddIn_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
pass Does it seem correct to you ? Then it says: Remove the pass statement from the onClick event. In Chapter 7, you created a custom script tool that loads wildfire data from a text file to a feature class. Inside the onClick event, call this Load Wildfires from Text custom script tool so that it displays the user interface for selecting the text file, template, and feature class to write to. def onClick(self): LoadWildfires_wildfire() Save the file. When I open that addin to my ArcMap and I can only see this :
... View more
02-25-2015
11:52 AM
|
0
|
4
|
4860
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-01-2022 03:43 PM | |
| 1 | 09-28-2020 09:34 AM | |
| 2 | 09-24-2025 09:48 AM | |
| 1 | 09-22-2025 08:29 AM | |
| 1 | 09-17-2025 12:58 PM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|