{"id":3397,"date":"2021-10-20T12:26:56","date_gmt":"2021-10-19T23:26:56","guid":{"rendered":"http:\/\/blogs.lincoln.ac.nz\/gis\/?p=3397"},"modified":"2023-05-07T02:50:45","modified_gmt":"2023-05-07T02:50:45","slug":"master-of-your-domain","status":"publish","type":"post","link":"https:\/\/blogs.lincoln.ac.nz\/gis\/master-of-your-domain\/","title":{"rendered":"Master of Your Domain"},"content":{"rendered":"<p><em>We look at how to use attribute domains to enforce some data integrity.<\/em><\/p>\n<p>Who&#8217;s a good consistent typist?\u00a0 I&#8217;m <del>ceratinly<\/del> certainly not.\u00a0 Let&#8217;s say you had to add a bunch of data into a spreadsheet, maybe names of students and their degrees.\u00a0 If you&#8217;re anything like me, it&#8217;s hard enough to get names correctly typed every time, but then think about if for each student you also had to correctly type in their full degree name, like &#8220;Bachelor of Environment and Society&#8221;.\u00a0 From a database point of view, this might be treated as different from &#8220;bachelor of environment and society&#8221; (all lowercase) even if all\u00a0the spelling was correct.\u00a0 And &#8220;Bach<span style=\"text-decoration: underline\">le<\/span>or of Enviro<span style=\"text-decoration: underline\">mn<\/span>ent and Society&#8221; is clearly different.\u00a0 As humans, we might recognise that &#8220;BES&#8221; represents the same thing, but not so with most databases &#8211; they are a lot more pedantic and far less forgiving.\u00a0 With only a few records, you might be able to pull this off doing it manually, but as the numbers rise, it becomes more and more challenging.\u00a0 At stake here is data integrity.<\/p>\n<p>GIS is no different.\u00a0 In a <a href=\"http:\/\/blogs.lincoln.ac.nz\/gis\/care-and-feeding-of-polygons\/\" target=\"_blank\" rel=\"noopener noreferrer\">recent post<\/a> we looked at digitising land cover polygons and part of the process there was to assign an attribute value.\u00a0 In that post I flippantly showed a\u00a0drop down\u00a0list of options that could be chosen from in the table to make this easier:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3399\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Domain-1.jpg\" alt=\"\" width=\"517\" height=\"345\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Domain-1.jpg 517w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Domain-1-300x200.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Domain-1-330x220.jpg 330w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><\/p>\n<p>We use <a href=\"https:\/\/pro.arcgis.com\/en\/pro-app\/latest\/help\/data\/geodatabases\/overview\/an-overview-of-attribute-domains.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Attribute Domains <\/a>to set these up and here I&#8217;ll show you how that&#8217;s done.<\/p>\n<p>First important thing to know is that there are two types: range domains and coded domains.<\/p>\n<p>Range domains are used with numerical attributes to ensure that any entered values are within a preset range.\u00a0 For instance, you might have a pipe network where diameter is an attribute.\u00a0 But all pipe diameters have to be within a specific range.\u00a0 Once a range domain is set, if you try to add in a value <em>outside<\/em> this range, you get a warning to stop you doing so.<\/p>\n<p>Coded domains can used on different attribute types including text, numbers and dates.\u00a0 As the name suggests, there&#8217;s a coded value and a text description for each entry.\u00a0 We have seen this before when setting up an app to collect <a href=\"http:\/\/blogs.lincoln.ac.nz\/gis\/dont-let-that-dragonfly-get-away-offline-mapping-in-vanuatu\/\" target=\"_blank\" rel=\"noopener noreferrer\">dragonfly observations<\/a>\u00a0where species names would be impossible to type correctly\u00a0every time.\u00a0 I challenge you to type &#8220;<a href=\"https:\/\/www.indianodonata.org\/sp\/395\/Pseudagrion-microcephalum\" target=\"_blank\" rel=\"noopener noreferrer\"><em>Pseudagrion microcephalum<\/em><\/a>&#8221; 10 times, using your phone keyboard, in the tropical heat, while hanging from a banyan tree over a tepid pool and get it right every time.\u00a0 I tend to use coded domains a lot more than range domains.\u00a0\u00a0In the Mt Grand case, this ends up as a\u00a0the pre-selected list of land cover classes that users select from as we saw above.<\/p>\n<p>Another important thing to note is that domains belong to a geodatabase, not a particular layer.\u00a0 We set up the domain at the level of the geodatabase and then any feature class within that geodatabase can use it.<\/p>\n<p>Here&#8217;s some detail on the Mt Grand land cover domain.\u00a0 This started as a list of entries that were needed.\u00a0 If I look at my project geodatabase in the <span style=\"color: #3366ff\">Catalog<\/span> pane and then right-click on it, <span style=\"color: #3366ff\">Domains<\/span> is one of my options.\u00a0 When chosen, the <span style=\"color: #3366ff\">Domains<\/span> window opens up:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3400\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/DomainsTab.jpg\" alt=\"\" width=\"1298\" height=\"348\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/DomainsTab.jpg 1298w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/DomainsTab-300x80.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/DomainsTab-1024x275.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/DomainsTab-768x206.jpg 768w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/p>\n<p>To the left are details about this particular domain: it&#8217;s a coded value domain on a text field.\u00a0 The Split and Merge policies relate to what happen with naming when we&#8217;re editing features with different codes (big topic&#8230;I&#8217;ll kick it to touch, but <a href=\"https:\/\/pro.arcgis.com\/en\/pro-app\/latest\/help\/data\/geodatabases\/overview\/an-overview-of-attribute-domains.htm\" target=\"_blank\" rel=\"noopener noreferrer\">see here<\/a> if you&#8217;re keen).\u00a0On the right\u00a0you can see the Code and the Description for each.\u00a0 Again, this belongs to the geodatabase but is available to any feature class within it.\u00a0 Let&#8217;s say I&#8217;ve got a polygon layer that I&#8217;ll use to create my different land covers called NewLandCover.\u00a0 I&#8217;ve added a text field called LandCover with a length of 25 characters to hold these data.\u00a0 In its current form, the attribute is free text, meaning I can type whatever I want in each cell:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3403\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewLandCover.jpg\" alt=\"\" width=\"1291\" height=\"138\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewLandCover.jpg 1291w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewLandCover-300x32.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewLandCover-1024x109.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewLandCover-768x82.jpg 768w\" sizes=\"auto, (max-width: 1291px) 100vw, 1291px\" \/><\/p>\n<p>At the feature class level, the domain can be assigned to appropriate attributes.\u00a0 Do this by opening the <span style=\"color: #3366ff\">Fields View<\/span> for a layer&#8217;s attribute table (with a table open, click the three horizontal lines at upper right,\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3401\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/Options.jpg\" alt=\"\" width=\"29\" height=\"26\" \/>, and pick <span style=\"color: #3366ff\">Fields View<\/span>.\u00a0 This opens up a new window focused on the attributes:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3404\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/ViewTable.jpg\" alt=\"\" width=\"860\" height=\"259\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/ViewTable.jpg 860w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/ViewTable-300x90.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/ViewTable-768x231.jpg 768w\" sizes=\"auto, (max-width: 860px) 100vw, 860px\" \/><\/p>\n<p>This is where we can add or delete new attributes and set their properties (but not the only place I can do this).\u00a0 Notice the &#8220;<span style=\"color: #3366ff\">Domain<\/span>&#8221; column.\u00a0 None of these layers has a domain set up but the LandCover text attribute could use it as it&#8217;s text.\u00a0 To enable it, click in that attribute&#8217;s Domain cell and you&#8217;ll see a drop down menu with any available domains on the geodatabase :<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3405\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/pick.jpg\" alt=\"\" width=\"923\" height=\"111\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/pick.jpg 923w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/pick-300x36.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/pick-768x92.jpg 768w\" sizes=\"auto, (max-width: 923px) 100vw, 923px\" \/><\/p>\n<p>Once these changes have been saved, the drop down list of choices will display whenever I click on this attribute:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3406\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/PickInLayer.jpg\" alt=\"\" width=\"518\" height=\"378\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/PickInLayer.jpg 518w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/PickInLayer-300x219.jpg 300w\" sizes=\"auto, (max-width: 518px) 100vw, 518px\" \/><\/p>\n<p>In fact, I can&#8217;t even type directly into this fields &#8211; my only option is to pick from the list.\u00a0 This allows me to enforce some data integrity and make sure whoever is working with this layer will add in acceptable values consistently every time.<\/p>\n<p>So how do we set up a new domain?\u00a0 It&#8217;s pretty straightforward.<\/p>\n<p>Back in the <span style=\"color: #3366ff\">Catalog pane<\/span>, find your geodatabase, right-click it and choose <span style=\"color: #3366ff\">Domains.<\/span><\/p>\n<p><span style=\"color: #000000\">Click <span style=\"color: #3366ff\">New Domain<\/span>:\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3410\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewDomain.jpg\" alt=\"\" width=\"54\" height=\"72\" \/><\/span><\/p>\n<p>Give it a name and a useful description and chose the field type and domain type from the drop down menu:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3412\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewDomain2.jpg\" alt=\"\" width=\"592\" height=\"81\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewDomain2.jpg 592w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewDomain2-300x41.jpg 300w\" sizes=\"auto, (max-width: 592px) 100vw, 592px\" \/><\/p>\n<p>Add the codes and descriptions:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3413\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/codes.jpg\" alt=\"\" width=\"334\" height=\"163\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/codes.jpg 334w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/codes-300x146.jpg 300w\" sizes=\"auto, (max-width: 334px) 100vw, 334px\" \/><\/p>\n<p>And now it&#8217;s available in the <span style=\"color: #3366ff\">Fields View<\/span>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3414\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewThings.jpg\" alt=\"\" width=\"935\" height=\"363\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewThings.jpg 935w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewThings-300x116.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/NewThings-768x298.jpg 768w\" sizes=\"auto, (max-width: 935px) 100vw, 935px\" \/><\/p>\n<p>Nice. Only one question remains:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3408\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/download.png\" alt=\"\" width=\"540\" height=\"304\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/download.png 540w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2021\/10\/download-300x169.png 300w\" sizes=\"auto, (max-width: 540px) 100vw, 540px\" \/><\/p>\n<p>C<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We look at how to use attribute domains to enforce some data integrity. Who&#8217;s a good consistent typist?\u00a0 I&#8217;m ceratinly certainly not.\u00a0 Let&#8217;s say you had to add a bunch of data into a spreadsheet, maybe names of students and their degrees.\u00a0 If you&#8217;re anything like me, it&#8217;s hard enough to get names correctly typed [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3397","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/3397","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/comments?post=3397"}],"version-history":[{"count":1,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/3397\/revisions"}],"predecessor-version":[{"id":4065,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/3397\/revisions\/4065"}],"wp:attachment":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/media?parent=3397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/categories?post=3397"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/tags?post=3397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}