Select to view content in your preferred language

Store additional information/tags in .LYRX layer file properties

534
4
03-10-2023 10:14 AM
Status: Open
Labels (1)
Bud
by
Honored Contributor

I have multiple .LYRX layer files (created from Oracle EGDB query layers) that are stored in a network folder.

I want to store information in each file such as:

  1. DESCRIPTION: Check for out-of-date construction projects (STATUS=FORECAST, but DATE is in the past).
  2. MESSAGE: There are rows in the "Check for out-of-date construction projects" query. Please investigate.
  3. DISTRIBUTION_LIST: jdoe@domain.com, jsmith@domain.com, jbrown@domain.com
  4. EMAIL_SCHEDULE: Weekly
  5. COMMENTS: TBD


Use Case:

I want to build a mechanism that sends scheduled emailed notifications/reports. For example, a Python script on a server that loops through layer files in the network folder. If the layer file's definition query returns >0 rows, then email the list of recipients via SMTP, using the specified schedule.

In other words, I need to store DESCRIPTION, MESSAGE, DISTRIBUTION_LIST, EMAIL_SCHEDULE , AND COMMENTS information somewhere. While I could store that information in a separate table (Excel, CSV, etc.), I'd like to have the option of storing information like that in the layer file if needed.

 

Currently, I don't think there's a way to store extra information in layer files.

Could that functionality be added? Possibly in the General tab?

Bud_0-1678471526614.png

Thanks.

4 Comments
Bud
by

Note:

I'm aware that Notebook Server might be an option for this kind of thing.

Unfortunately, my organization isn't interested in getting Notebook Server; I asked and they declined. And even if they were interested, they wouldn't let non-IT users like me manage my own automations/reports -- so that's not a viable option for me. I want to manage my own server-based automations, hence why I want store layer files in a folder that I can manage myself, as needed.

TanuHoque

hi @Bud 

 

I assume you must have checked Metadata and you found that is not going to help you. I'm just throwing it out there; I'm no expert in metadata.

Another thing that I want to mention is a dataset type called Catalog Dataset that is new in ArcGIS Pro 3.1. Just in case you are not aware of this, as the name suggested it is about cataloging your datasets by ref. You can add additional field/attribute for each reference in that dataset.

See help on Catalog Layer here:
- https://pro.arcgis.com/en/pro-app/latest/get-started/whats-new-in-arcgis-pro.htm
- https://pro.arcgis.com/en/pro-app/3.1/help/mapping/layer-properties/catalog-layers.htm

I'm again throwing it out there just in case you find it helpful.

 

 

TanuHoque

@Bud 

Maybe this will work for you. Obviously I didn't find anything from UI, but you can do it programmatically from arcpy or .net SDK.

 

We have something called customProperties that you can use to add anything to a layer CIM definition.

Here is a sample arcpy code to write these values.

p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps()[0]
l = m.listLayers("Tornadoes")[0]

# layer's CIM definition
cimLyr = l.getDefinition('V3')

# creating a CIMStringMap to store a key/value pair
vp1 = arcpy.cim.CreateCIMObjectFromClassName("CIMStringMap", "v3")
vp1.key = "DESCRIPTION"
vp1.value = "Check for out-of-date construction projects (STATUS=FORECAST, but DATE is in the past)."
vp2 = arcpy.cim.CreateCIMObjectFromClassName("CIMStringMap", "v3")
vp2.key = "MESSAGE"
vp2.value = "There are rows in the "Check for out-of-date construction projects" query. Please investigate."

cimLyr.customProperties = [vp1, vp2]

# updating layer's CIM definition
l.setDefinition(cimLyr)

 
Here is the same thing but using .NET API

var cimBLyr = lyr.GetDefinition();
cimBLyr.CustomProperties = new CIMStringMap[]
  { 
    new CIMStringMap() {Key = "DESCRIPTION", Value = "Check for out-of-date construction projects (STATUS=FORECAST, but DATE is in the past)."},
    new CIMStringMap() {Key = "MESSAGE", Value = "There are rows in the "Check for out-of-date construction projects" query. Please investigate."}
  };

lyr.SetDefinition(cimBLyr);

 

Bud
by

@TanuHoque Thanks!