POST
|
Hi Kim, thanks for your response. In other contexts, the terms vertex and point are used interchangeably, so it helps to know that the Esri documentation on this tool only uses the term 'vertices' to refer to line segment/polygon edge endpoints. What I'm really trying to find out is if this tool ever gives anything other than an empty table. I'm looking for a sample broken dataset to see the Check Geometry in action. I have tried to create some 'errors' (e.g., bow-tie polygons), but I can seem to get any response from this tool. Have any of you come across a dataset that gives more than an empty table? Do any of you have on hand a sample dataset (that you could share) that gives more than an empty table? Thank you!
... View more
06-10-2014
05:33 AM
|
0
|
0
|
470
|
POST
|
Hi Matthew, I think you need to use another zip, since you want to loop through both tuples of attributes at once. Something like this:
assetRows = arcpy.da.SearchCursor( fc1 , fields )
centerRows = arcpy.da.UpdateCursor( fc2 , fields )
for assetRow, centerRow in zip(assetRows, centerRows):
for assetAttr, centerAttr in zip(assetRow, centerRow):
centerAttr = assetAttr
centerRows.updateRow(centerRow)
... View more
06-06-2014
08:51 AM
|
0
|
0
|
867
|
POST
|
If you're using ArcGIS 10.1 or higher, you could use the newer style Data Access cursors. Then you could loop through the tuple of attribute values. Here's an example:
import arcpy
fc = 'C:/data.shp'
fields = [ 'Event', 'Comments', 'Diameter' ]
cursor = arcpy.da.SearchCursor( fc , fields )
for row in cursor:
for attr in row:
print attr
... View more
06-05-2014
09:30 AM
|
0
|
0
|
867
|
POST
|
This tool doesn't seem to work any more. I have tried it on faulty geometry in both 10.1 and 10.2. I get an empty table. I have attached a sample file which has 5 instances of the point (1,1) According to the documentation, this should be part of the check geometry output, correct? I have also tried it on bow-tie polygons (that overlap themselves). Thank you
... View more
06-05-2014
07:09 AM
|
0
|
2
|
2427
|
POST
|
Hi Matthew, assetFeatureClass is a string not a row object. That's why you're getting the error message when you try to do this: assetFeatureClass.Ditch_ID What you really mean is row.Ditch_ID but you're using the variable named 'row' twice. That's where the confusion probably arises. You should avoid using the same variable name ('row') on the inside loop that you're trying to use from the outside loop--For example, you could change the inner loop to for rowC in rows: That said, I don't think you really want a nested loop here. I believe you could use the Python zip function to loop through both at once. Here's an example of the zip function: >>> listA = ['FID', 'Shape', 'COVER', 'RECNO'] >>> listB = ['OID', 'Geometry', 'String'] >>> for a, b in zip( listA, listB): ... print "a: ", a ," b: ", b ... a: FID b: OID a: Shape b: Geometry a: COVER b: String So your code would be something like: assetRows = arcpy.UpdateCursor(assetFeatureClass,"[Processed] <> 'Y'","","","") centerRows = arcpy.UpdateCursor(centerline) for assetrow, rowCenter in zip(assetRows, centerRows): centerRow.Ditch_ID = assetRow.Ditch_ID #etc...
... View more
06-05-2014
06:56 AM
|
0
|
0
|
867
|
POST
|
Oops-- I got rid of the error by switching to NAD_1983_StatePlane_Colorado_Central_FIPS_0502 instead of NAD_1983_HARN_StatePlane_Colorado_Central_FIPS_0502 So you can ignore question #4. However my first three questions still remain. Thanks again.
... View more
05-24-2014
09:43 AM
|
0
|
0
|
327
|
POST
|
Hi All, I'm trying to find the area of my Denver, Colorado polygons in kilometers (km) and I think my data is in Decimal Degrees, so I need to project it before using calculate field to calculate the area. My data properties say the following: Data Type: Shapefile Feature Class Shapefile: C:\foo.shp Geometry Type: Polygon Coordinates have Z values: No Coordinates have measures: No Geographic Coordinate System: GCS_WGS_1984 Datum: D_WGS_1984 Prime Meridian: Greenwich Angular Unit: Degree My specific questions are: I think this means my data is in decimal degrees and I need to project it to get an accurate area measure in km. Does this sound correct? I believe an appropriate coordinate system would be: NAD_1983_HARN_StatePlane_Colorado_Central_FIPS_0502_Feet My source of coordinate system selection is from here: http://www.denvergov.org/?TabId=426422 http://www.spatialreference.org/ref/?search=Colorado Does this sound correct? The project tool requires a coordinate system transformation and I selected NAD_1983_To_WGS_1984_5. Does this sound correct? I based this selection on this source: http://blogs.esri.com/esri/arcgis/2009/05/06/about-geographic-transformations-and-how-to-choose-the-right-one/ which says: HowTo: Determine which NAD_1983_To_WGS_1984 transformation to use-- NAD_1983_To_WGS_1984_1 �?? for the entire North American continent. NAD_1983_To_WGS_1984_2 �?? for the Aleutian islands. NAD_1983_To_WGS_1984_3 �?? for Hawai�??i. NAD_1983_To_WGS_1984_4 �?? superseded by _5; this transformation method should no longer be used! NAD_1983_To_WGS_1984_5 �?? for the 48 contiguous United States. NAD_1983_To_WGS_1984_6 �?? for the Canadian province of Quebec. NAD_1983_To_WGS_1984_7 �?? for the Canadian province of Saskatchewan. NAD_1983_To_WGS_1984_8 �?? for the Canadian province of Alberta. I get an error when I run the Project (Data Management) tool. Here's a picture of how I filled in the Project GUI: http://screencast.com/t/ARKUS3wQdf This is the error I get: ERROR 000151: The geotransformation(s) is not valid. Failed to execute (Project). Any ideas why this may be happening? Thank you for your help!
... View more
05-24-2014
09:33 AM
|
0
|
1
|
2794
|
POST
|
Have you tried using the Python round function? >>> x = 35.00000000000001 >>> y = round(x,1) >>> y 35.0 >>>
... View more
05-13-2014
05:51 PM
|
0
|
0
|
283
|
POST
|
Does anyone else have any insights? Is this a bug or am I missing some setting?
... View more
05-11-2014
06:38 AM
|
0
|
0
|
255
|
POST
|
This documentation seems to apply to Python toolbox code, but not to script tools. .value.value seems to be necessary within Python toolbox tools in some cases, but not in others. Here's an example where the CalculateField tool would not work until I used value.value: def execute(self, parameters, messages):
# From combineFields.py
# Purpose: Create a new field that is the sum of two existing fields.
dataset = parameters[0].value.value
field1 = parameters[1].value
field2 = parameters[2].value
newfield = parameters[3].value
arcpy.AddField_management(dataset, newfield)
expression = '!{0}!+!{1}!'.format(field1, field2)
arcpy.CalculateField_management(dataset, newfield, expression, 'PYTHON')
arcpy.SetParameterAsText( 4,dataset)
And another example (like the documentation) where os.path.dirname won't work without the double 'value' (though the linear distance works fine as a value object passed into the buffer tool): fileToBuffer = parameters[0].value.value
distance = parameters[1].value
arcpy.env.workspace = os.path.dirname(fileToBuffer)
outputFile = os.path.splitext(fileToBuffer)[0] + 'Buff'
arcpy.Buffer_analysis(fileToBuffer, outputFile, distance)
... View more
05-11-2014
06:36 AM
|
0
|
0
|
186
|
POST
|
Hi Tim, thanks for the response, but that is not the problem. I have tested that, as well as checking 'save all customizations to the document' inside customize mode > options. Does anyone know a solution? This makes the button entirely useless for sharing unless you're able to set it up on the other person's machine for them.
... View more
05-01-2014
01:05 PM
|
0
|
0
|
255
|
POST
|
One more suggestion... In your script tool, try setting up an input parameter that you set to your existing table view name. Then for the derived output table view, set the 'Obtained From' property to the input table view parameter.
... View more
04-27-2014
03:45 AM
|
0
|
0
|
1602
|
POST
|
Hi Folks, As you may know, you can create a handy button on an ArcMap toolbar to launch a script tool, use the following steps: Select 'Customize' > 'Customize mode???' Select the 'Commands' tab Under 'Categories', scroll down to select '[Geoprocessing tool]' Select 'Add Tools???' Browse to the custom toolbox > Select the script tool in toolbox > Select 'Add'. The script tool appears under 'Commands'. Click on the script tool under 'Commands' and, holding the left mouse key down, drag the script tool between any existing buttons on any ArcMap toolbar. A black vertical bar appears when you're in between buttons in a position where the new button can be placed. Release the mouse button to drop it into position. Before closing the 'Customize' dialog, right-click on the tool in the toolbar to display text and image menu and modify these as desired. Click 'Close' on the 'Customize' dialog to save changes. But the problem is, it does work if you move the map document (and toolbox and Python script to still maintain the relative location of the toolbox and Python script). My question is, is there a way to set it up for portability? I.e., have the button use a relative path to the script tool? Thanks for your help.
... View more
04-27-2014
03:35 AM
|
0
|
3
|
572
|
POST
|
Hi All, the ToolValidator documentation says: As a Value object does not support string manipulation, use the Value object's value property whenever a string is to be manipulated or parsed. The code sample uses the os.path.dirname method to return the directory from a dataset.
if self.params[0].value:
workspace = os.path.dirname(self.params[0].value.value) However, the following works fine: workspace = os.path.dirname(self.params[0].value) My question are, 1. Has anyone encountered a situation where they DID have to use self.params[0].value.value and self.params[0].value wouldn't work? 2. Is this working because I'm running 10.2? Does it work for those of you that have 9.3, 10.0, and 10.1? I have a dummy script tool with 1 param. The code below is for debugging outside the script tool. It also works inside the script tool (I set a second param to that value to check it in the script tool). Here's a complete script to test this: import arcpy, os
arcpy.ImportToolbox(r"C:\temp\sandbox.tbx")
params = arcpy.GetParameterInfo("myScriptTool")
params[0].value = "C:/Temp/data.shp"
class ToolValidator:
def __init__(self):
import arcpy
self.params = arcpy.GetParameterInfo()
def initializeParameters(self):
# (initializeParameters code here)
return
def updateParameters(self):
# (updateParameters code here)
print os.path.dirname(self.params[0].value)
return
def updateMessages(self):
# (updateMessages code here)
return
# Call routine(s) to debug
#
validator = ToolValidator()
validator.updateParameters()
validator.updateMessages() It runs successfully and prints: C:/Temp The documentation is about midway through the following page: http://resources.arcgis.com/en/help/main/10.2/index.html#/Programming_a_ToolValidator_class/00150000000v000000/
... View more
04-25-2014
06:28 AM
|
0
|
1
|
1911
|
POST
|
Okay here's some more puzzling behavior inside the ToolValidator class. If I select a valid workspace for params[0] that has no rasters in it, ListRasters returns an empty list [] BUT self.params[1].value is set to 'fee'!
def updateParameters(self):
arcpy.env.workspace = self.params[0].value
rasts = arcpy.ListRasters()
if rasts:
self.params[1].value = 'fee'
else:
self.params[1].value = 'foo'
return
In Python, an empty list is false.
>>> arcpy.env.workspace = 'C:\noRastersDir'
>>> rasts = arcpy.ListRasters()
>>> rasts
[]
>>> if rasts:
... print 'a'
... else:
... print 'b'
...
b But yet, it's evaluated as True inside the ToolValidator. Why? And more ominously, what other Python code isn't going to work as expected!!?
... View more
04-13-2014
08:34 AM
|
0
|
0
|
423
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|