|
POST
|
The preferred syntax for describe should be .baseName You should have spaces around your where clause operators. None of those issues should give you that kind of error though. I am a little confused by your description of your problem. Did it create the output or not? Is "H:\CIV\Customization_Exercise\LabExercise_1\File_Geodatabase.gdb\fd\watershed" the path to your input or output feature class?
... View more
05-29-2012
01:05 PM
|
0
|
0
|
4828
|
|
POST
|
Even an empty mxd should have a dataframe. The line as you show it runs for me without crashing. Are you sure something else isn't going on? A layer index reference maybe?
... View more
05-29-2012
11:14 AM
|
0
|
0
|
2748
|
|
POST
|
Related to this post: http://forums.arcgis.com/threads/58348-Large-Dictionary-Compression, I am having troubles when the dictionaries get too big! Although it's slower, especially for multiple fields, I am finding the ole' "Join and Calc" method is much more memory efficient. Yes, I can imagine when you get into storing multiple million tuple datasets to memory on a 32-bit process, you're going to have a bad time. When I implemented mine it was only ~50 rows to reference to the main table, which worked out quite well. I have another process with a 1:1 relationship on the 900k row dataset that I use a join and export process to run calculations on. I hope Esri bites the bullet this decade and converts desktop to a 64-bit application. It's not like datasets or file complexity are shrinking. Maybe as a quick fix develop some more easy to use interfaces between desktop and server to submit large geoprocessing jobs to server post 10.1 which utilizes 64-bit python. http://forums.arcgis.com/threads/54612-arcpy-is-using-32bit-Python-installation-how-about-64bit
... View more
05-29-2012
11:06 AM
|
0
|
0
|
4116
|
|
POST
|
The simple way would be to use the create features from text file. http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=F25C5576-1422-2418-A060-04188EBD33A9 Otherwise you can recreate that functionality using array polygon constructions. The code sample at the bottom should get you going in the right direction. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Polygon/000v000000n1000000/
... View more
05-29-2012
08:11 AM
|
0
|
0
|
954
|
|
POST
|
From my limited exposure to KML, I have not seen any hard vertex limit in Google Earth exactly. There is most likely a point where it takes the application too long to draw all the vertices in a particular feature on screen and times out, continuing to the next feature. This would explain how a user can still select the "invisible" features that are not displayed, as the bounding area will still be honoured. Google Maps has a hard vertex limit as that information is stored and rendered on the Google servers, so they need to cap it.
... View more
05-28-2012
12:00 PM
|
0
|
0
|
14398
|
|
POST
|
I got what changes I wanted to work. A few little problems left. If both the maxline and close line or id field options are set, how to handle closing/ending each line segment. This works fine for simple point to line construction using a maxline variable though, which is all I need for now. Hopefully someone else can get some use out of it too.
... View more
05-28-2012
11:46 AM
|
0
|
0
|
497
|
|
POST
|
I'm not sure I follow what you are doing exactly. I wouldn't use multiple cursors on the same dataset, I can't imagine that would ever work. I would use your search cursor to build a dictionary or list of the values you want to compute with your update cursor.
... View more
05-28-2012
08:12 AM
|
0
|
0
|
774
|
|
POST
|
Does your symbology vary between different features? Are they complex line or fill graphics? Have you tried with simple symbology? Dashed lines, hatching, picture marker fills, etc. don't seem to be handled very well by google earth. They should just switch to a default simple lines/fills though.
... View more
05-28-2012
07:36 AM
|
0
|
0
|
14398
|
|
POST
|
I have run this exact procedure before. Except it was between two FGDB. Hopefully it translates for you. import arcpy, os
sde1 = r"D:\sde_transit\sde1.gdb"
output = r"D:\sde_transit\sdeCSRS.gdb"
arcpy.env.workspace = sde1
sdeList = arcpy.ListFeatureClasses()
for fc in sdeList:
result = arcpy.GetCount_management(fc)
count1 = result.getOutput(0)
fc2 = os.path.join(output,fc)
if arcpy.Exists(fc2):
result = arcpy.GetCount_management(fc2)
count2 = result.getOutput(0)
if count1 == count2:
print fc+" OK"
else:
print "Problem with "+fc
print count1
print count2
else:
print fc2+" not found"
pass
# Clean up
sdeList = None
del arcpy.env.workspace
del arcpy
... View more
05-24-2012
06:51 AM
|
0
|
0
|
668
|
|
POST
|
WARNING: I saved and closed the map document that worked with Mathew's sample. Now, whenever I attempt to re-open that particular map document, it crashes 😞 That is fairly odd. I haven't seen that behaviour in my tests. Did you try running an MXD doctor on it? Was it a fairly complicated MXD before you tried to tool or a new one? Have you tried creating a new MXD with just one simple layer with a few features, save that, run the tool, save and close the MXD then see if you can reopen it? I made a few modifications to the script, mainly to accept tool parameters and any data type.
# Author: Jennifer (esri_id: jenn775)
# Created: July 20, 2010
# Edits: Mathew Coyle, May 24, 2012
from Tkinter import *
import arcpy
# SelectPopup.py sample Python script using Tkinter for a user interface
# User selects feature from list, code selects and zooms to feature
# Use in ArcMap by attaching script to a button for best results
# In ArcGIS 10, you can add scripts and models to buttons in the UI without using VBA.
# Create a Python script tool using this script and then
# see "Adding a custom tool to a menu or toolbar" in this help topic:
# http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002400000005000000.htm
Layer = arcpy.GetParameterAsText(0) # Layer
SelField = arcpy.GetParameterAsText(1) # Field to Select
Title = arcpy.GetParameterAsText(2) # Title (optional)
# Troubleshooting messages
#arcpy.AddMessage("Layer is "+repr(Layer))
#arcpy.AddMessage("Selection field is "+repr(SelField))
#arcpy.AddMessage("Title is " + repr(Title))
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.grid()
self.createWidgets(master)
def createWidgets(self, master):
self.yScroll = Scrollbar ( self, orient=VERTICAL )
self.yScroll.grid ( row=0, column=1, sticky=N+S )
self.stList = Listbox (self, yscrollcommand=self.yScroll.set)
self.stList.grid( row=0, column=0 )
self.yScroll["command"] = self.stList.yview
# populate list with choices, sorted ascending
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name == Layer:
break
# for large datasets where the selection field contains many blanks or
# non-unique values, you can create a summary table and set SelTable
# equal to it for faster creation of the selection dialog
SelTable = lyr.dataSource
rows = arcpy.SearchCursor(SelTable, "", "", SelField, SelField + " A")
oldVal = ""
for row in rows:
newVal = row.getValue(SelField)
#only add value to Listbox if it is not a duplicate
if newVal <> oldVal:
self.stList.insert( END, row.getValue(SelField) )
oldVal = newVal
#add selection and quit button
self.selButton = Button (self, text='Select', command=self.selectFeat)
self.selButton.grid( row=0, column=2 )
self.quitButton = Button ( self, text='Quit', command=master.destroy )
self.quitButton.grid( row=1, column=2 )
def selectFeat(self):
sel = self.stList.curselection()
myFeature = self.stList.get(sel[0])
def BuildQuery(table, field, operator, value=None):
"""Generate a valid ArcGIS query expression
arguments
table - input feature class or table view
field - field name (string)
operator - SQL operators ("=","<>", etc)
"IS NULL" and "IS NOT NULL" are supported
value - query value (optional)
"""
# Adds field delimiters
qfield=arcpy.AddFieldDelimiters(table,field)
# tweak value delimeter for different data types
if type(value) == str:
# add single quotes around string values
qvalue = "'" + value + "'"
elif value == None:
# drop value when not specified (used for IS NULL, etc)
qvalue = ""
else:
# numeric values are fine unmodified
qvalue = value
sql = "{0} {1} {2}".format(qfield,operator,qvalue)
#print repr(sql)
return sql.strip()
where = BuildQuery(Layer, SelField, "=", myFeature)
arcpy.AddMessage(where)
arcpy.SelectLayerByAttribute_management(Layer, "NEW_SELECTION", where)
mxd = arcpy.mapping.MapDocument("CURRENT")
for df in arcpy.mapping.ListDataFrames(mxd):
if df.name == mxd.activeView:
df.zoomToSelectedFeatures()
arcpy.RefreshActiveView()
root = Tk()
app = Application(master=root)
app.master.title(Title)
app.mainloop()
... View more
05-24-2012
06:23 AM
|
0
|
0
|
5814
|
|
POST
|
I am attempting to add some functionality to the basic points to line tools script that will allow for a new optional parameter that will limit the maximum distance between points to draw a line. I took the code and converted it to arcpy v10.0 just so everything is on the same page, and that worked fine. I am just having a bit of trouble figuring out the best way to go about the next step. Would it be best to check if each point is a certain euclidean distance from the previous point, or after the lines have all been drawn, to simply split the feature at line lengths above the threshold. Any input would be appreciated, I've pasted the code below as well as attached it with the script tool parameters. import arcpy
import os
#import types
def convertPoints():
arcpy.env.overwriteOutput = True
# Input point FC
# Output FC
# Feature Field
# Sort Field
# Close Line or Leave Open
# Max line length to join
inPts = arcpy.GetParameterAsText(0)
outFeatures = arcpy.GetParameterAsText(1)
IDField = arcpy.GetParameterAsText(2)
sortField = arcpy.GetParameterAsText(3)
closeLine = arcpy.GetParameterAsText(4)
maxLine = arcpy.GetParameterAsText(5)
if IDField in ["", "#"]: IDField = None
if sortField in ["", "#"]:
cursorSort = IDField
else:
if IDField:
cursorSort = IDField + ";" + sortField
else:
cursorSort = sortField
#if types.TypeType(closeLine) != types.BooleanType:
if type(closeLine) != bool:
if closeLine.lower() == "false":
close = False
else:
close = True
if maxLine in ["", "#"]:
maxLine = None
else:
if type(maxLine) == float:
maxLine = float(maxLine)
elif type(maxLine) == int:
maxLine = int(maxLine)
convertPointsToLine(arcpy, inPts, outFeatures, IDField, cursorSort, close, maxLine)
def enableParam(hasMZ):
if hasMZ:
return "ENABLED"
else:
return "DISABLED"
def convertPointsToLine(arcpy, inPts, outFeatures, IDField, cursorSort, close, maxLine):
try:
# Assign empty values to cursor and row objects
iCur, sRow, sCur, feat = None, None, None, None
desc = arcpy.Describe(inPts)
shapeName = desc.ShapeFieldName
# Create the output feature class
#
outPath, outFC = os.path.split(outFeatures)
arcpy.CreateFeatureclass_management(outPath, outFC, "POLYLINE", "",
enableParam(desc.hasM),
enableParam(desc.hasZ),
inPts)
# If there is an IDField, add the equivalent to the output
#
if IDField:
f = arcpy.ListFields(inPts, IDField)[0]
tMap = {'Integer': 'LONG', 'String': 'TEXT', 'SmallInteger': 'SHORT'}
fType = f.type
if tMap.has_key(fType):
fType = tMap[fType]
fName = arcpy.ValidateFieldName(f.name, outPath)
arcpy.AddField_management(outFeatures, fName, fType, f.precision, f.scale, f.length,
f.aliasName, f.isNullable, f.required, f.domain)
# Open an insert cursor for the new feature class
#
iCur = arcpy.InsertCursor(outFeatures)
sCur = arcpy.SearchCursor(inPts, "", None, cursorSort, cursorSort)
#sRow = sCur.Next()
# Create an array and point object needed to create features
#
array = arcpy.CreateObject("Array")
pt = arcpy.CreateObject("Point")
# Initialize a variable for keeping track of a feature's ID.
#
ID = -1
for sRow in sCur:
pt = sRow.getValue(shapeName).getPart(0)
if IDField:
currentValue = sRow.getValue(IDField)
else:
currentValue = None
if ID == -1:
ID = currentValue
if ID <> currentValue:
if array.count >= 2:
# To close, add first point to the end
#
if close:
array.add(array.getObject(0))
feat = iCur.newRow()
if IDField:
if ID: #in case the value is None/Null
feat.setValue(IDField, ID)
feat.setValue(shapeName, array)
iCur.insertRow(feat)
else:
arcpy.AddIDMessage("WARNING", 1059, str(ID))
array.removeAll()
array.add(pt)
ID = currentValue
# Add the last feature
#
if array.count > 1:
# To close, add first point to the end
#
if close:
array.add(array.getObject(0))
feat = iCur.newRow()
if IDField:
if ID: #in case the value is None/Null
feat.setValue(IDField, currentValue)
feat.setValue(shapeName, array)
iCur.insertRow(feat)
else:
arcpy.AddIDMessage("WARNING", 1059, str(ID))
array.removeAll()
except Exception as err:
arcpy.AddError(err.message)
finally:
if iCur:
del iCur
if sRow:
del sRow
if sCur:
del sCur
if feat:
del feat
if __name__ == '__main__':
convertPoints()
... View more
05-23-2012
01:33 PM
|
0
|
1
|
676
|
|
POST
|
Definitely 2.7.x, which version of 2.7 will be final I don't know. http://training.esri.com/gateway/index.cfm?fa=catalog.courseDetail&CourseID=50127508_10.x Edit: 2.7.2 from David above, straight from the horses mouth, so to speak. Edit: Question. Why wouldn't it ship with the latest version of Python (2.7.3), since ArcGIS hasn't been officially released yet? Were the differences too minor?
... View more
05-23-2012
10:52 AM
|
0
|
0
|
2575
|
|
POST
|
It is definitely not how the tool works in 10.0. I'd suspect some kind of bug.
... View more
05-23-2012
10:39 AM
|
0
|
0
|
1812
|
|
POST
|
I was just trying to work from the ground up to see what the issue might be. It is difficult to troubleshoot without the actual code you are executing. Have you tried creating a feature layer of your input feature class and running the select tool on that layer instead? Also, what version of ArcGIS are you using?
... View more
05-23-2012
10:11 AM
|
0
|
0
|
1812
|
|
POST
|
You have a few issues, not sure if they are related to the problem you are having or some mistake in copying your code. Your where_clause has a syntax error and your in_features variable should be raw stringed or you should be setting your workspace to the FGDB. Something like this import arcpy
# Set local variables
arcpy.env.workspace = ws = r"..\working.gdb"
in_features = "linefile"
out_feature_class = "C:/output/linefile_zeros.shp"
query_field = "Shape_Length"
field_delim = arcpy.AddFieldDelimiters(ws,query_field)
where_clause = "{0} = 0".format(field_delim)
# Execute Select
arcpy.Select_analysis(in_features, out_feature_class, where_clause)
... View more
05-23-2012
09:46 AM
|
0
|
0
|
1812
|
| 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
|