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.

Branco
3,2393 gold badges20 silver badges37 bronze badges
asked Jul 2, 2015 at 10:32
0

1 Answer 1

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.

answered Jul 2, 2015 at 21:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.