I want to connect an existing .lyr file to a variable defined as lyr2.
lyr2 = arcpy.mapping.Layer(r"C:/Iso100Red.lyr")
Although it is a .lyr file, I get this Error code:
Runtime error <type 'exceptions.ValueError'>: Object: CreateObject Layer invalid data source
What could be the problem here?
Layer invalid data source
. This means the layer data is not valid. That means that when attempting to open the.lyr
file ArcGIS was either unable to access the file or the data within was not valid Layer information. – Jason Scheirer Aug 7 '13 at 22:56r
use backslash paths:r"C:\Iso100Red.lyr"
, withoutr
use foreslash:"C:/Iso100Red.lyr"
. r stands for "raw". – matt wilkie Sep 26 '19 at 17:18