<?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>GIS Tips &#38; Tricks &#187; keyword</title>
	<atom:link href="http://www.aubreyrhea.net/gis/index.php/tag/keyword/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aubreyrhea.net/gis</link>
	<description>for ESRI&#039;s ArcGIS suite</description>
	<lastBuildDate>Fri, 01 Apr 2011 18:52:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Creating a list of keywords from the attribute table: New &amp; Improved Version</title>
		<link>http://www.aubreyrhea.net/gis/index.php/2010/08/creating-a-list-of-keywords-from-the-attribute-table-new-improved-version/</link>
		<comments>http://www.aubreyrhea.net/gis/index.php/2010/08/creating-a-list-of-keywords-from-the-attribute-table-new-improved-version/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 11:04:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[attribute table]]></category>
		<category><![CDATA[keyword]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[text file]]></category>

		<guid isPermaLink="false">http://www.aubreyrhea.net/gis/?p=435</guid>
		<description><![CDATA[Problem: You need a better way to summarize the contents of a dataset without wasting time typing a long list. Back in March, I posted about creating a list of keywords from the attribute table. I knew that: The solution I have come up with is not perfect. I keep thinking there must be a [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem: You need <em>a better way</em> to summarize the contents of a dataset without wasting time typing a long list.</strong></p>
<p>Back in March, I posted about <a href="http://www.aubreyrhea.net/gis/index.php/2010/03/creating-a-list-of-keywords-from-the-attribute-table/"> creating a list of keywords from the attribute table</a>. I knew that:</p>
<blockquote><p>The solution I have come up with is not perfect. I keep thinking there must be a better way.</p></blockquote>
<p>I had explained how to make a list of the administrative area types in the <a href="http://www.naturalearthdata.com/">Natural Earth</a> Admin 1 shapefile, using ArcMap&#8217;s &#8220;Summarize&#8221; tool. The end result was a text file that had extra quotation marks, commas, and other characters to remove.</p>
<p>There <em>is</em> a better way &#8212; with Python! I now have the power to structure the text file the way I want it from the start. Here&#8217;s the entire code:</p>
<p><big>
<pre>import arcgisscripting
gp = arcgisscripting.create(9.3)</pre>
<p></big></p>
<p><big>
<pre>report = file(r"<span style="color: #ff0000;">C:\gis\AdminTypes.txt</span>", "w")
shape = r"<span style="color: #ff0000;">C:\gis\10m-admin-1-states-provinces-shp.shp</span>"</pre>
<p></big><br />
<img style="margin-left: 0px; margin-right: 15px;" src="http://www.aubreyrhea.net/gis/images/toc.PNG" alt="" align="left" /><br />
<big>
<pre>cur = gp.SearchCursor(shape)
row = cur.Next()
adminList = []</pre>
<p></big></p>
<p><big>
<pre>while row &lt;&gt; None:
     adminList.append(row.<span style="color: #ff0000;">ENGTYPE_1</span>)
     row = cur.Next()</pre>
<p></big></p>
<p><big>
<pre>adminList = list(set(adminList))
adminList.sort()</pre>
<p></big></p>
<p><big>
<pre>for admin in adminList:
     report.write(admin + "\n")
report.close()</pre>
<p></big></p>
<p><big>
<pre>print "Finished"</pre>
<p></big></p>
<p>Change only the portions marked in red to make this work with any data layer. They represent, in order from top to bottom:</p>
<ol>
<li>The output text file</li>
<li>The input data layer</li>
<li>The name of the attribute table field to summarize</li>
</ol>
<p>The text file generated by this code is a list of each unique entry in the ENGTYPE_1 field (all duplicates removed) &#8212; one per line, in alphabetical order. It&#8217;s the exact same thing you would see in the table of contents if you symbolized by category on that field. Only now it&#8217;s in a form you can copy and paste into other places, like a metadata record.</p>
<p>Python makes everything better.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aubreyrhea.net/gis/index.php/2010/08/creating-a-list-of-keywords-from-the-attribute-table-new-improved-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a list of keywords from the attribute table</title>
		<link>http://www.aubreyrhea.net/gis/index.php/2010/03/creating-a-list-of-keywords-from-the-attribute-table/</link>
		<comments>http://www.aubreyrhea.net/gis/index.php/2010/03/creating-a-list-of-keywords-from-the-attribute-table/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 12:01:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Attributes]]></category>
		<category><![CDATA[attribute table]]></category>
		<category><![CDATA[keyword]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[summarize]]></category>
		<category><![CDATA[text file]]></category>

		<guid isPermaLink="false">http://www.aubreyrhea.net/gis/?p=308</guid>
		<description><![CDATA[Problem: You need to summarize the contents of a dataset without wasting time typing a long list. Natural Earth is a crisp basemap dataset available for the world at 1:10m, 1:50m, and 1:110m scales. I downloaded one of their most detailed layers, the 1:10m Admin 1 &#8211; States, Provinces shapefile for use as my example. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem: You need to summarize the contents of a dataset without wasting time typing a long list.</strong></p>
<p><img style="margin-left: 0px; margin-right: 15px;" src="http://www.aubreyrhea.net/gis/images/toc.PNG" alt="" align="left" /><a href="http://www.naturalearthdata.com/">Natural Earth</a> is a crisp basemap dataset available for the world at 1:10m, 1:50m, and 1:110m scales. I downloaded one of their most detailed layers, the 1:10m Admin 1 &#8211; States, Provinces shapefile for use as my example.</p>
<p>If you were asked to write a metadata record or some other type of report about this dataset, you would want your description to be as complete as possible. You might find it necessary to generate a long list of place or topic keywords. Often, the attribute table already includes this information. You just need a good way to extract it.</p>
<p>For instance, if I symbolize by category on the ENGTYPE_1 field of my natural earth layer, I get a long list of administrative area types. There&#8217;s way more than just states and provinces here! If only I could select this list and paste it somewhere else to have in a usable format. Unfortunately, it&#8217;s not that easy.</p>
<p>The solution I have come up with is not perfect. I keep thinking there must be a better way. If any of my readers know of one, I would love the feedback. For now, this method certainly beats having to type the entire list:</p>
<p>First, open attribute table and right click on the field you want to turn in to a keyword list. Then, select Summarize&#8230;</p>
<p><img src="http://www.aubreyrhea.net/gis/images/summarize.PNG" alt="" /></p>
<p>Chose one summary statistic field. It doesn&#8217;t matter which, but works a little better if you chose something that&#8217;s always going to be the same. I chose &#8220;CheckMe&#8221; because that&#8217;s basically a flag (yes or no) field. It doesn&#8217;t matter which summary statistic (minimum, maximum, first, last etc.) you pick either. You won&#8217;t be using any of this information&#8211;it&#8217;s just a way to get ArcMap to make a list for you that includes each category one time.</p>
<p><img src="http://www.aubreyrhea.net/gis/images/summarize_box.PNG" alt="" /></p>
<p>Hit the browse button in the Specify output table section. Then, change Save as type to Text File.</p>
<p><img src="http://www.aubreyrhea.net/gis/images/textfile.PNG" alt="" /></p>
<p>Open up your text file in Notepad and remove the first line (the field names). Then, do Edit &#8212; &gt; Replace and replace all commas, quotation marks, numerals 1-9 and whatever text phrase was in your summary statistic field with nothing.</p>
<p><img src="http://www.aubreyrhea.net/gis/images/replace.PNG" alt="" /></p>
<p><img style="margin-left: 0px; margin-right: 15px;" src="http://www.aubreyrhea.net/gis/images/listresult.PNG" alt="" align="left" />When you are done, you end up with this. If you want to add commas and move these all into one row, it&#8217;s pretty easy from here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aubreyrhea.net/gis/index.php/2010/03/creating-a-list-of-keywords-from-the-attribute-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

