1

I have to first load a vector layer (in .shp format) in arcmap and then it should select to specific attribute (the name of attribute is taken as input from user which i have done). and only selected attribute layer should be visible.

All this should be done using python.

So how can I do this? I have done this code snippet

import arcgisscripting
import arcpy
gp = arcgisscripting.create(9.3)
gp.workspace = "E:\boundary"
sFile = "E:\boundary\sample.shp"
lyr = "layer"
gp.makefeatureLayer_management(sFile, lyr)
gp.toolbox = "management"
gp.SelectLayerByAttribute_management("layer", "NEW_SELECTION", " 'DNAME' = 'NAME' ")

#now zoom to selected feature
mxd = arcpy.mapping.MapDocument('CURRENT')
df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]
df.zoomToSelectedFeatures()
arcpy.RefreshActiveView()

but it is throwing an error Runtime error Traceback (most recent call last): File "", line 7, in ExecuteError: ERROR 000732: Input Features: Dataset E:oundary\sample.shp does not exist or is not supported.

1

In your code you have not specified the pathname to your shapefile correctly.

Instead of:

sFile = "E:\boundary\sample.shp" 

try:

sFile = r"E:\boundary\sample.shp"

This should make the 000732 error disappear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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