Home > ArcGIS, Data Model, GIS, Python > The Main, De Main, Duh Main, Doh Main, Domain

The Main, De Main, Duh Main, Doh Main, Domain

In many of the workflows we automate much of the effort is around development of a good data model that encapsulates the workflow inputs and outputs and provides a level of consistency that (usually) is not already in place.  Domains within a geodatabase are awesome for ensuring consistency within data models and for easing the effort (and improving consistency) for data management and maintenance.  No shortage of good merits for domains both coded and range alike.

When you work with domains often enough through Python you quickly come across some limitations on usability, or perhaps better stated, you come across the ways that you want to use it that aren’t readily exposed to Python.  Here are some simple use cases we run into all the time.

    >>> from pygp.dataelement.extended import GeodatabaseWorkspace
    >>> # Open up a geodatabase in a case insensitive state
    >>> gdb = GeodatabaseWorkspace(GDB_PATH_NAME, nocase=True)
    >>> # Use case #1: Check if a domain exists in a geodatabase
    >>> domain_name = 'test_domain_name'
    >>> domain_name in gdb.domains
    True
    >>> # Use case #2: Get a domain from a field in a table
    >>> field = table.fields['MY_FIELD_NAME']
    >>> domain = field.domain
    >>> # Use Case #3: What type of domain is this?
    >>> # Only two types of domains, coded and range
    >>> domain.is_range
    True
    >>> # Use Case #4: Is the value ok for the Domain?
    >>> 1000 in domain
    False
    >>> 5 in domain
    True

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.