Tuesday 22 December 2015

arcpy - Select By Atribute using python script on .Shp file getting error 000840 value is not raster layer


I have a script that calculating vertices angles on Polyline layer and the selecting features in that layer at a specified angle. at the end of the script i'm using select by attribute and getting error 000840 the value is not raster layer, the value is not mosaic layer


SelectLayerByAttribute_management(my_shp_name, 'NEW_SELECTION', myquery)

Answer



This is a common error that I have run across, and I am pretty sure it is related to attempting to run the selection against a raw featureclass/shapefile output, as opposed to the "layer" representation of the featureclass/shapefile.


For example: You cannot select features from a shapefile without using ArcMap, but once you load the shapefile into ArcMap (which makes it a "layer"), you can now select the features from the layer.


Try using the MakeFeatureLayer_management(my_shp_name, my_shp_layer) function between the previous function's output and the SelectLayerByAttribute_management(). I think you will find that this resolves your error.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...