I am new to GIS and pretty new to python, so sorry if this is ugly code.
I am creating a feature class in a postgres database if it does not already exist and the user wants it created.
That works fine, and adds a single layer to my table of contents in my current map.
I added the line to change the privileges of the layer, and now I get a second polyline feature class added to the table of contents. Named a little different, and it does not stored in the database (the first, correct polyline does get stored). Where is this layer coming from, and how can I make it not show up?
is_there = False
matched_layer = False
for fc in arcpy.ListFeatureClasses():
regex = re.compile("skld_geodata\..+\.A%s" % sectional_name)
if regex.match(fc):
matched_layer = fc
is_there = True
if is_there is False:
msg = 'No skld layer currently exists for this Arb. Would you like to create one?'
create_input = pythonaddins.MessageBox(msg, 'Missing Layer', 4)
# create a new geodatabase entry with the correct name if it does not already exist
if create_input == 'Yes':
arcpy.CreateFeatureclass_management(shp_path, arb_name, 'POLYLINE')
# change the privileges for everyone to work with
arcpy.ChangePrivileges_management(shp_path + "\\" + arb_name, "editor", "GRANT", "GRANT")
else:
geo_layer = arcpy.mapping.Layer(matched_layer)
arcpy.mapping.AddLayer(self.df, geo_layer, "TOP")
I can add images of the table of contents if that makes it easier to understand what I am asking.