|
POST
|
In my script I create line data from GPS points, buffer the line then run the EliminatePolygonPart tool to remove small areas remaining after the buffer. This works on the geometry, but does weird things to the attribute data. Most times, when run in ArcMap it takes my string ID and converts it to the previous shape_length value. Sometimes in ArcMap and every time I use it in a script, it just removes any attribute fields completely. Has anyone else encountered this type of behaviour from this tool? I attached screen shots of the attribute table of the single part feature class with one feature I am using it on. Edit: The first picture is the attribute table after the eliminate. The second picture is the original attribute table from the buffer. Edit2: I should have put this as discussion instead of question since I solved my problem already by just calculating the field after the eliminate instead of before. It just seems like very strange behaviour and was wondering if anyone else had this issue before I opened a ticket with Esri.
... View more
04-04-2012
06:04 AM
|
0
|
0
|
1002
|
|
POST
|
You can use getcount to test if there is a selection. You can reverse if you have no selection more often than not, or if you only want to be doing something if there is no selection.
selectcount= int(arcpy.GetCount_management(layer).getOutput(0))
if selectcount != 0:
do something if a selection
else:
do something else if no selection
... View more
04-04-2012
05:07 AM
|
0
|
0
|
1850
|
|
POST
|
Instead of doing the double selections, try using a feature layer with a where clause. So replace this arcpy.SelectLayerByAttribute_management ("edge_lyr", "NEW_SELECTION", expr)
arcpy.SelectLayerByLocation_management('junc_lyr', 'intersect', 'edge_lyr') With something more like this. arcpy.MakeFeatureLayer_management(edgeSource, 'edge_lyr', expr)
arcpy.SelectLayerByLocation_management('junc_lyr', 'intersect', 'edge_lyr') Also, having nested cursors and GP tools inside a cursor are generally bad ideas. Is there no way you can avoid processing all this line by line?
... View more
04-03-2012
12:29 PM
|
0
|
0
|
746
|
|
POST
|
Not sure what else to suggest. It seems a very odd workflow to have source filenames that depend on the layer name as a process. I'm not sure why you are assigning the same month value for different year values, elif years == 48:
months = "313"
elif years == 76:
months = "313" but without seeing actual examples of filenames/paths etc I can't help much more.
... View more
04-03-2012
07:08 AM
|
0
|
0
|
2008
|
|
POST
|
Yes mine ran on multiple .asc files. Did the names of your files change when you moved them? You could do something like this filename = os.path.basename(lyr.dataSource)
... View more
04-03-2012
06:23 AM
|
0
|
0
|
2008
|
|
POST
|
Posting your full code may help, I suspect a problem with your file_name variable, as well as the specific errors you are receiving. The code you posted works fine for me, modified thusly. import arcpy
changedir = r"D:\GIS\ascii"
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("DATASOURCE"):
file_name = lyr.name
lyr.replaceDataSource(changedir, "NONE", file_name)
... View more
04-03-2012
05:06 AM
|
0
|
0
|
2008
|
|
POST
|
You could try using "TEXT_WORKSPACE" since .asc files are text. Also, did you try using an mxd.save() or mxd.saveACopy(...)?
... View more
04-02-2012
12:49 PM
|
0
|
0
|
2008
|
|
POST
|
You have to import arcpy before checking out license levels and available extensions. In regards to Dan's post, this was true prior to 10 I believe. You now need to set the license level before importing the GP Legacy: The product level should be set by importing the appropriate product module (arcinfo, arceditor, arcview, arcserver, arcenginegeodb, arcengine) prior to importing arcpy. The SetProduct function is a legacy function and cannot set the product once arcpy has been imported. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000000z000000
... View more
04-02-2012
10:26 AM
|
0
|
0
|
1877
|
|
POST
|
Ah yes, that's right if you are dealing with different levels of licenses it will. Arcpy requires an arcinfo level license for a lot of it's functionality above basic geoprocessing. Is it an option to have ArcMap default to an ArcInfo level license? If you go the other way you will have to make sure your script only requires tools from the license you are calling or below or else it will grab two regardless.
... View more
04-02-2012
10:22 AM
|
0
|
0
|
1877
|
|
POST
|
I would think this could be better accomplished outside of Arc. Using some backend SQL or tableviews that runs on a schedule. If you are tied to Arc tools, you can give Join Field a try. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000065000000
... View more
04-02-2012
06:36 AM
|
0
|
0
|
796
|
|
POST
|
Are you sure it isn't appending .TXT to the end of your output? You need to specify the extension if you don't want it to be text directly in the tool parameter.
... View more
04-02-2012
06:31 AM
|
0
|
0
|
2410
|
|
POST
|
You are using df.zoomToSelectedFeatures() But no where are you making a selection. And if you are starting with a selection in ArcMap it is getting cleared after the first iteration at this line. arcpy.SelectLayerByAttribute_management(fc, "CLEAR_SELECTION")
... View more
04-02-2012
05:49 AM
|
0
|
0
|
1751
|
|
POST
|
I was under the assumption that Arc products and arcpy tools would share the same license and not require additional licenses to be checked out. I don't believe I have observed behaviour in my environment where two licenses would be checked out simultaneously by the same machine.
... View more
04-02-2012
05:42 AM
|
0
|
0
|
1877
|
|
POST
|
Seems like that isn't possible when working in a stand alone script. The following worked for me. import arcpy, os
arcpy.env.worksace = workspace = r"C:\GIS\scratch"
arcpy.env.overwriteOutput = True
mxd_string = r"C:\GIS\MXDs\empty_test.mxd"
fc = r"C:\GIS\someshapefile.shp"
mxd = arcpy.mapping.MapDocument(mxd_string)
df = arcpy.mapping.ListDataFrames(mxd)[0]
outlayer = "TEST_LYR"
layerfile = os.path.join(workspace,"ADDED_LAYER.lyr")
arcpy.MakeFeatureLayer_management(fc, outlayer)
arcpy.SaveToLayerFile_management(outlayer, layerfile, "ABSOLUTE")
addlayer = arcpy.mapping.Layer(layerfile)
arcpy.mapping.AddLayer(df, addlayer)
mxd.save()
del mxd
print "done"
... View more
04-02-2012
05:31 AM
|
0
|
0
|
934
|
|
POST
|
You need to break up that line. arcpy.SelectLayerByLocation_management(lyr, "INTERSECT", "polygontest") rows = arcpy.SearchCursor(lyr)
... View more
03-29-2012
12:30 PM
|
0
|
0
|
1003
|
| 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
|