<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Michalis Avraam &#187; describe</title>
	<atom:link href="http://michalisavraam.org/tag/describe/feed/" rel="self" type="application/rss+xml" />
	<link>http://michalisavraam.org</link>
	<description>intersecting space and time through gis endeavors</description>
	<lastBuildDate>Wed, 08 Sep 2010 20:03:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Understanding the Geoprocessor Programming Model part 3</title>
		<link>http://michalisavraam.org/2010/02/understanding-the-geoprocessor-programming-model-part-3/</link>
		<comments>http://michalisavraam.org/2010/02/understanding-the-geoprocessor-programming-model-part-3/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 01:47:02 +0000</pubDate>
		<dc:creator>Michalis Avraam</dc:creator>
				<category><![CDATA[GIS* Points]]></category>
		<category><![CDATA[Python Geoprocessing]]></category>
		<category><![CDATA[Python Points]]></category>
		<category><![CDATA[arcgisscripting]]></category>
		<category><![CDATA[describe]]></category>
		<category><![CDATA[ESRI]]></category>
		<category><![CDATA[geoprocessing]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://michalisavraam.org/?p=229</guid>
		<description><![CDATA[After a long delay, it is time for the third installment of understanding the Geoprocessor Programming Model that will deal with the Describe object. If you missed the last two parts, feel free to look at them first (Part 1: understanding what the geoprocessor is, and Part 2: accessing data with the geoprocessor). As always, <a href='http://michalisavraam.org/2010/02/understanding-the-geoprocessor-programming-model-part-3/'>[...]</a>


Related posts:<ol><li><a href='http://michalisavraam.org/2009/02/accessing-geometries-using-the-geoprocessor-updated/' rel='bookmark' title='Permanent Link: Accessing Geometries using the Geoprocessor (Updated)'>Accessing Geometries using the Geoprocessor (Updated)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>After a long delay, it is time for the third installment of understanding the Geoprocessor Programming Model that will deal with the Describe object. If you missed the last two parts, feel free to look at them first (<a href="http://michalisavraam.org/2009/10/understanding-the-geoprocessor-programming-model-part/">Part 1: understanding what the geoprocessor is</a>, and <a href="http://michalisavraam.org/2009/10/understanding-the-geoprocessor-programming-model-part-2/">Part 2: accessing data with the geoprocessor</a>). As always, comments are welcomed and encouraged.<span id="more-229"></span></p>
<div id="attachment_234" class="wp-caption alignright" style="width: 510px"><a href="http://michalisavraam.org/wp-content/uploads/2009/11/describe.png"><img class="size-full wp-image-234" title="The Describe Object" src="http://michalisavraam.org/wp-content/uploads/2009/11/describe.png" alt="The Describe Object" width="500" height="540" /></a><p class="wp-caption-text">The Describe Realm</p></div>
<p>As mentioned earlier, the geoprocessor gives us the ability to access or create data to perform various operations. These operation vary in type and content, but more often than not are performed on data we are not intimately familiar with. This can become a problem quite quickly, as we need to know the names of fields in the datasets, as well as other characteristics (the type of data we are dealing with, spatial references, geographical extent and other). The solution to this lack of knowledge comes through the <em>describe</em> object which provides users with methods to identify all unknown information beforehand. In the most basic form of usage, one uses the <em>describe</em> object on a dataset, accessing the bottom left box in the diagram, the <em>Describe Object Properties</em>. The Python code to achieve this follows:</p>
<pre class="brush: python; title: ;">
import arcgisscripting
# Import the module provided by ESRI

gp = arcgisscripting.create(9.3)
# Create the geoprocessor object

dataset = r&quot;c:\data\testData.shp&quot;
# The location of the data. This is usually
#   not hardcoded but discovered with List methods

dsc = gp.Describe(dataset)
# Create a describe object for the dataset

print dsc.DataType
# Print the data type of our dataset

print dsc.CatalogPath
# Print the path to the dataset
</pre>
<p>With the above simple example, we managed to read the Data Type and Catalog Path of a dataset. While this seems simple, it can become a very powerful tool, when on considers the possible return values (listed below).</p>
<table border="1" cellspacing="0" cellpadding="2" align="center">
<tbody>
<tr style="background-color: #dcdcdc;">
<td align="left"><strong>Return Value</strong></td>
<td align="left"><strong>Data Type</strong></td>
</tr>
<tr>
<td align="left">FeatureDataset</td>
<td align="left">Containers for data that include spatial reference and extent of contents.</td>
</tr>
<tr>
<td align="left">FeatureClass</td>
<td align="left">Feature class in a geodatabase, a shapefile if standalone.</td>
</tr>
<tr>
<td align="left">Table</td>
<td align="left">A geodatabase or standalone table.</td>
</tr>
<tr>
<td align="left">RelationshipClass</td>
<td align="left">A geodatabase class storing relationships.</td>
</tr>
<tr>
<td align="left">RasterDataset</td>
<td align="left">A raster dataset type.</td>
</tr>
<tr>
<td align="left">RasterBand</td>
<td align="left">A raster band.</td>
</tr>
<tr>
<td align="left">RasterCatalog</td>
<td align="left">A raster catalog.</td>
</tr>
<tr>
<td align="left">Workspace</td>
<td align="left">A workspace as defined by ESRI (directory or database).</td>
</tr>
</tbody>
</table>
<p>As you can see, the return values as listed above correspond to different objects in our diagram (the boxes in the first image above). This means that it would be trivial for us to move between the first access we have into the <em>Describe</em> realm (through the Describe object) and move to any other box of our choice when we are not familiar with what possible data we have.</p>
<h2>Retrieving Information about data: Feature Classes</h2>
<div id="attachment_236" class="wp-caption alignleft" style="width: 210px"><a href="http://michalisavraam.org/wp-content/uploads/2009/11/featureClass.png"><img class="size-full wp-image-236" title="FeatureClass Object Properties" src="http://michalisavraam.org/wp-content/uploads/2009/11/featureClass.png" alt="FeatureClass Object Properties" width="200" height="209" /></a><p class="wp-caption-text">FeatureClass Object Properties</p></div>
<p>The most commonly used types of data in GIS now seems to be feature classes, either standalone (in the form of shapefiles) or in a geodatabase. As such, we will use the example of a feature class to retrieve information about out data. This is of course not the only type of data one can use, so please refer to the image on the top for more information.</p>
<p>As you can see from the diagram on the left, feature classes have specific information associated with them, including what feature type they are of, their shape type, and the shape field name we used in part two of this series. We will dive right into it by trying to identify what shape type our feature class has, and what type of feature it is.</p>
<pre class="brush: python; title: ;">
import arcgisscripting
# Import the module provided by ESRI

gp = arcgisscripting.create(9.3)
# Create the geoprocessor object

dataset = r&quot;c:\data\testData.shp&quot;
# The location of the data. This is usually
#   not hardcoded but discovered with List methods

dsc = gp.Describe(dataset)
# Create a describe object for the dataset
# As we know the dataset is of type FeatureClass,
#   all the properties of the FeatureClass object
#   are available to us now.

print dsc.ShapeType
# Print what type of shape we have
#   (point, polygon, polyline, etc)

print dsc.FeatureType
# Print what type of features are stored
#   (simple, annotation, dimension, etc)
</pre>
<p>With the above code we can identify what type of shape we have and the type of feature stored. For possible values to these properties, please <a href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=FeatureClass_properties">check this help file</a>.</p>
<div id="attachment_237" class="wp-caption alignright" style="width: 210px"><a href="http://michalisavraam.org/wp-content/uploads/2009/11/table.png"><img class="size-full wp-image-237" title="Table Properties" src="http://michalisavraam.org/wp-content/uploads/2009/11/table.png" alt="Table Properties" width="200" height="108" /></a><p class="wp-caption-text">Table Properties</p></div>
<p>In the FeatureClass Properties object image above, on the bottom, you can see that there are also <em>Table Properties</em> and<em> Dataset Properties</em> listed. This means that when you have a feature class, you automatically gain access to those properties as well (as a feature class has them embedded). Therefore, we can use this to our advantage to further retrieve information about our feature class, like the name of all fields within the feature class. The example below shows you how to achieve this.</p>
<pre class="brush: python; title: ;">
import arcgisscripting
# Import the module provided by ESRI

gp = arcgisscripting.create(9.3)
# Create the geoprocessor object

data = r&quot;c:\data\testData.shp&quot;
# The location of the data. This is usually
#   not hardcoded but discovered with List methods

dsc = gp.Describe(data)
# Create a describe object for the data
# As we know the dataset is of type FeatureClass,
#   all the properties of the FeatureClass object
#   and inherited objects are available to us now.

dataFlds = dsc.Fields
# Retrieve a list of fields in the table of the
#   feature class as a Python list. Note the fields
#   are of Field Object type.

for fld in dataFields:
    print fld.Name
</pre>
<div id="attachment_235" class="wp-caption alignright" style="width: 210px"><a href="http://michalisavraam.org/wp-content/uploads/2009/11/dataset.png"><img class="size-full wp-image-235" title="Dataset Properties" src="http://michalisavraam.org/wp-content/uploads/2009/11/dataset.png" alt="Dataset Properties" width="200" height="118" /></a><p class="wp-caption-text">Dataset Properties</p></div>
<p>What he have done on the above example is run the ListFields() method mentioned in an older article (<a href="http://michalisavraam.org/2009/08/using-the-geoprocessors-list-methods/">Using the Geoprocessor&#8217;s List Methods</a>). Similarly, one can follow the Dataset Properties object (shown on your right) to access information like the extent of the data, or the spatial reference system. Don&#8217;t forget, both of those return an object, which has a corresponding box in the geoprocessor programming model diagram, so you need to treat them as such.</p>
<p>In this installment, I have shown you how one can use the <em>Describe</em> object the geoprocessor makes available to us to retrieve information about our data. While I did not provide complete examples of every single possible option available, hopefully by reading this post you are able to navigate your options better to achieve your goals.</p>
<p>As always, comments are encouraged and I am willing to answer any questions you may have.</p>
Note: There is a rating embedded within this post, please visit this post to rate it.


<p>Related posts:<ol><li><a href='http://michalisavraam.org/2009/02/accessing-geometries-using-the-geoprocessor-updated/' rel='bookmark' title='Permanent Link: Accessing Geometries using the Geoprocessor (Updated)'>Accessing Geometries using the Geoprocessor (Updated)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://michalisavraam.org/2010/02/understanding-the-geoprocessor-programming-model-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

