<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Model Builder - Write calculated output to shapefile field in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709676#M23496</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: dmhoneycutt&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Seems to me that you could avoid all the iteration and just use the &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Spatial_Join/00080000000q000000/"&gt;Spatial Join&lt;/A&gt;&lt;SPAN&gt; tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;target_features = The sections&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;join_features = tracts&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;join_operation = JOIN_ONE_TO_MANY&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;match_option = HAVE_THEIR_CENTER_IN&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The field map is where you define whether you want the Sum / Mean / Min / Max of a particular field.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Aug 2013 02:35:07 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2013-08-27T02:35:07Z</dc:date>
    <item>
      <title>Model Builder - Write calculated output to shapefile field</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709675#M23495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: blingenfelder&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am somewhat new to creating models and have run into a problem with the one that I am currently working on.&amp;nbsp; My goal is to Iterate rows of one shapefile, "sections", and perform a select by location to find the "tracts" that have their centroid in each section.&amp;nbsp; Then, I would like to summarize a field for these selected tracts within each section.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have successfully done this and output the values to a table, although the table will only keep one record at a time, overwriting the table each time instead of adding a new row.&amp;nbsp; Even so, I am trying to figure out a way to add this calculated value to a field of the current record in the iteration of my "sections" shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have explored the option of trying to do a table join, but I don't think that this will work because of the many to one (tracts to section) relationship and that there is no unique key between the two.&amp;nbsp; I will attach my script and graphic.&amp;nbsp; Any advice would help, thanks in advance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]26997[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Test.py
# Created on: 2013-08-26 15:08:04.00000
#&amp;nbsp;&amp;nbsp; (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("Model Functions")


# Local variables:
LPMGIS_LEASE_ACTIVE_TRACT = "Core Layers\\LPMGIS.LEASE.ACTIVE_TRACT"
Sections_Result = "Sections_Result"
Sections = "Sections"
I_Sections = "I_Sections_FID"
LPMGIS_LEASE_ACTIVE_TRACT__3_ = "Core Layers\\LPMGIS.LEASE.ACTIVE_TRACT"
grs_acre_sum = "U:\\SectionAcreageTest\\grs_acre_sum"

# Process: Iterate Row Selection
arcpy.IterateRowSelection_mb(Sections, "", "false")

# Process: Select Layer By Location
arcpy.SelectLayerByLocation_management(LPMGIS_LEASE_ACTIVE_TRACT, "HAVE_THEIR_CENTER_IN", I_Sections, "", "NEW_SELECTION")

# Process: Summary Statistics
arcpy.Statistics_analysis(LPMGIS_LEASE_ACTIVE_TRACT__3_, grs_acre_sum, "T_GRS_AREA SUM", "")

# Process: Get Field Value
arcpy.GetFieldValue_mb(grs_acre_sum, "SUM_T_GRS_AREA", "Double", "0")

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:25:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709675#M23495</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T06:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder - Write calculated output to shapefile field</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709676#M23496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: dmhoneycutt&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Seems to me that you could avoid all the iteration and just use the &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Spatial_Join/00080000000q000000/"&gt;Spatial Join&lt;/A&gt;&lt;SPAN&gt; tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;target_features = The sections&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;join_features = tracts&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;join_operation = JOIN_ONE_TO_MANY&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;match_option = HAVE_THEIR_CENTER_IN&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The field map is where you define whether you want the Sum / Mean / Min / Max of a particular field.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 02:35:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709676#M23496</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-08-27T02:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder - Write calculated output to shapefile field</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709677#M23497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: blingenfelder&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the response.. After trying out a few different methods with the spatial join, I thought I had it.&amp;nbsp; First, I had to make it a 1 to 1 in order to keep the correct number of records from sections.&amp;nbsp; This method does work, but only in some cases.&amp;nbsp; It seems that it sort of works backwards for my purpose.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Instead of selecting the Tracts that have their center within the Section, it goes by the center of the Section being within a Tract.&amp;nbsp; Therefore, if a Section contains Tracts, but none in its center, the resulting sum is 0, when it should be say 80.&amp;nbsp; If I were to switch the target and selecting features, it would instead output tract polys when I need section polys.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't think that I will be able to accomplish what I am trying to with a join, unless I had a common field.&amp;nbsp; But I basically have the correct answer as a value with the iterations and just need to populate a field of the currently selected row of Sections.&amp;nbsp; I am wondering if there is some way to say "[Sections.Field]" = "[Grs_acre_sum.Field]" where Grs_acre_sum is the table output by the summary statistics.&amp;nbsp; Is this possible?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 13:45:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709677#M23497</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-08-27T13:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder - Write calculated output to shapefile field</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709678#M23498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In your model, you could use the Calculate Field tool with &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/A_quick_tour_of_using_inline_variable_substitution/002w0000001t000000/"&gt;variable substitution&lt;/A&gt;&lt;SPAN&gt;.&amp;nbsp; The model variable "Value (2)" contains the value of Grs_acre_sum.&amp;nbsp; First, add a field to your sections named something like "GRS_acres".&amp;nbsp; Then, in your model, add the Calculate Field tool.&amp;nbsp; The input table is t_sections, the field is GRS_acres, and the value is %Value (2)%.&amp;nbsp; This should work in theory, but I haven't tested it for syntax - but I think you get the idea.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As an alternative, you could run the &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Feature_To_Point/00170000003m000000/"&gt;Feature To Point&lt;/A&gt;&lt;SPAN&gt; tool on your tracts. Be sure to check the "Inside" option.&amp;nbsp; This will create a point feature class of tract centroids with all the attributes of the tracts.&amp;nbsp; Now that you have centroid points, just about any overlay operation will get you what you want.&amp;nbsp; You could run Spatial Join with the target=sections, join=centroids, join one_to_many, with the INTERSECT option.&amp;nbsp; Or run Identity or Intersect followed by Summary Statistics.&amp;nbsp; But the easiest is probably Spatial Join.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After re-reading the doc, I discovered that the HAVE_THEIR_CENTER_IN option doesn't do what you'd like it to do (and what I thought it would do) -- it's the centroid of the target features that is used.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 17:41:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709678#M23498</guid>
      <dc:creator>DaleHoneycutt</dc:creator>
      <dc:date>2013-08-27T17:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder - Write calculated output to shapefile field</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709679#M23499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: rfairhur24&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks for the response.. After trying out a few different methods with the spatial join, I thought I had it.&amp;nbsp; First, I had to make it a 1 to 1 in order to keep the correct number of records from sections.&amp;nbsp; This method does work, but only in some cases.&amp;nbsp; It seems that it sort of works backwards for my purpose.&lt;BR /&gt;&lt;BR /&gt;Instead of selecting the Tracts that have their center within the Section, it goes by the center of the Section being within a Tract.&amp;nbsp; Therefore, if a Section contains Tracts, but none in its center, the resulting sum is 0, when it should be say 80.&amp;nbsp; If I were to switch the target and selecting features, it would instead output tract polys when I need section polys.&lt;BR /&gt;&lt;BR /&gt;I don't think that I will be able to accomplish what I am trying to with a join, unless I had a common field.&amp;nbsp; But I basically have the correct answer as a value with the iterations and just need to populate a field of the currently selected row of Sections.&amp;nbsp; I am wondering if there is some way to say "[Sections.Field]" = "[Grs_acre_sum.Field]" where Grs_acre_sum is the table output by the summary statistics.&amp;nbsp; Is this possible?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do the Spatial Join as an Intersect with the Tract Centroids by creating a Centroid point layer from the Tract first, then doing the spatial join.&amp;nbsp; If you have an Advanced license you can use the &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000003m000000"&gt;Feature to Point tool&lt;/A&gt;&lt;SPAN&gt; to extract the Centroid points of the tracts to a point layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you don't have an Advanced license you can still extract the Centroids of the tracts into a point feature layer.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.&amp;nbsp; First create two double fields in your tracts for the X and Y coordinates of the Centroid and use the Geometry Calculator to calculate those values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.&amp;nbsp; Then export the attributes of the tract features to a stand alone table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3.&amp;nbsp; Use the Make XY Events Layer with the exported table Centroid coordinates to make a point layer.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now you can use that XY Event layer with the Spatial Join as the Join features and apply the normal Intersect as the match option.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 17:59:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709679#M23499</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-08-27T17:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Model Builder - Write calculated output to shapefile field</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709680#M23500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: blingenfelder&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That's it!&amp;nbsp; the variable substitution worked great!&amp;nbsp; I had tried almost the same thing before, but did not know about variable substitution and did not include the '%' on either side of the value.&amp;nbsp; Thank you!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Brad&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 18:08:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/model-builder-write-calculated-output-to-shapefile/m-p/709680#M23500</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-08-27T18:08:24Z</dc:date>
    </item>
  </channel>
</rss>

