Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I would like to get the search the field value

'SURFACE LOCATION%' in column 'RefName' in layer '*.dwg Annotation'

This is what I have so far...

# Find the Dataframe
df = arcpy.mapping.ListDataFrames(mxd, "Project Area")[0]

#Find the table named "*.dwg Annotation"
Table = arcpy.mapping.ListLayers(mxd, "*.dwg Annotation", df)[0]

whereClause = """RefName" LIKE 'SURFACE LOCATION%'""" % RefName

Anno = arcpy.SelectLayerByAttribute_management(AnnoTable, "NEW_SELECTION", whereClause)

Right now "Table" outputs the group layer name and the layer name.

However The link below shows that the the file path of the layer to work with SelectByAttribute.

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000071000000

Thoughts on how to get the file path of the layer?

and many thanks.

share|improve this question
    
I'm not clear on what you mean by "the string contained within a layer" - can you perhaps re-phrase your question to make what you are after more obvious, please? –  PolyGeo May 22 '12 at 23:42

1 Answer 1

up vote 0 down vote accepted

ListLayers returns a list of Layer objects. You can use the names of layers as input to geoprocessing tools just as easily as paths to layers, so long as they exist in the current process.

So using either Layer.name (returns the layer name) or Layer.dataSource (returns the full path to the layer) should work.

Additionally you might want to use AddFieldDelimiters to make your query expression workspace-agnostic.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.