Skip to main content
Solved

Update metadata for Geodatabase

  • March 27, 2024
  • 5 replies
  • 171 views

nathand2
Contributor
Forum|alt.badge.img+5

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

Best answer by joepk

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.

View original
Did this help you find an answer to your question?

5 replies

joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • Best Answer
  • March 27, 2024

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.


nathand2
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • April 2, 2024
joepk wrote:

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 :)


nathand2
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • April 3, 2024

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.


joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • April 3, 2024
nathand2 wrote:

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


rosst
Forum|alt.badge.img
  • January 14, 2025
nathand2 wrote:

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.

Hello Nathan,

I am currently rmeeting a similar challange and am very happy to see, that with joepks advice, you already succeded in this.

However, I am quite new to fme and even more to python, so I’ll have a hard time putting all the peaces together. Would it be possible for you to share your workbench?. It would be much easier for me to apply this solution to my particular task, if I could benefit from a hands-on-example.

I’d be very thankful :)


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings