Solved

Update metadata for Geodatabase

  • 27 March 2024
  • 4 replies
  • 68 views

Badge +3

Dear community,

I want to automatically write all metadata for my geodatabase using FME. So I managed to set this up using XMLUpdater. But I only manage to do this for feature classes. I would also like to write metadata for the feature dataset, and even on the highest level, the geodatabase itself. How can I access the XML for these higher levels of gdb structure?

The XML that I find with FME for a feature class only contains metadata for that particular class and not for the higher levels.

Thanks in advance

Nathan

icon

Best answer by joepk 27 March 2024, 14:57

View original

4 replies

Userlevel 4
Badge +17

I haven't found native ways to read/write higher level metadata.

However, you can use the arcpy Metadata module in a PythonCaller to get higher level metadata, see this link: https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm

import fme
import fmeobjects
import arcpy

from arcpy import metadata as md

gdb_path = r'U:\Joep\fme_forum.gdb'
gdb_md = md.Metadata(gdb_path)

#you can add "\feature_dataset_name" to your gdb path if you need feature dataset metadata
#>>> gdb_path = r'U:\Joep\fme_forum.gdb\dataset_a"

class FeatureProcessor(object):
def __init__(self):
pass
def input(self, feature):
pass
def close(self):
metadata_feature = fmeobjects.FMEFeature()
metadata_feature.setAttribute('metadata_xml',gdb_md.xml)

self.pyoutput(metadata_feature)


I have not used arcpy to write the metadata, so no code example for this, but this is explained in the documentation above.

Badge +3

I haven't found native ways to read/write higher level metadata.

However, you can use the arcpy Metadata module in a PythonCaller to get higher level metadata, see this link: https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm

import fme
import fmeobjects
import arcpy

from arcpy import metadata as md

gdb_path = r'U:\Joep\fme_forum.gdb'
gdb_md = md.Metadata(gdb_path)

#you can add "\feature_dataset_name" to your gdb path if you need feature dataset metadata
#>>> gdb_path = r'U:\Joep\fme_forum.gdb\dataset_a"

class FeatureProcessor(object):
def __init__(self):
pass
def input(self, feature):
pass
def close(self):
metadata_feature = fmeobjects.FMEFeature()
metadata_feature.setAttribute('metadata_xml',gdb_md.xml)

self.pyoutput(metadata_feature)


I have not used arcpy to write the metadata, so no code example for this, but this is explained in the documentation above.

Thanks for your suggestion, I used a regular Python script for setting the metadata for the gdb and the datasets, since it is only high level meta. For the classes I still use the XMLUpdater. It’s a bit cumbersome, but works good for now. At least I don’t have to set the meta by hand :)

Badge +3

I made it work by using the PythonCaller as you suggested, thanks for pointing me in that direction. Now I have everything (meta for gdb, dataset and classes) in one workbench.

Userlevel 4
Badge +17

I made it work by using the PythonCaller as you suggested, thanks for pointing me in that direction. Now I have everything (meta for gdb, dataset and classes) in one workbench.

Very cool! 😎 Glad to be of help

Reply