<?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: Calculate mileage calculation in model builder: in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569327#M18783</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Richard, the field calculation for !SHAPE.LENGTH! / 5280 # does not work.&amp;nbsp; It produces a syntax error when ran on an empty field through field calculation.&amp;nbsp; Any thoughts?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What version of ArcGIS are you using and are you doing this in Desktop or with Model Builder.&amp;nbsp; This should work for ArcGIS 9.3 and up, although you may have to change the case of the words to mixed case for 10 when ESRI started to make Python case sensitive.&amp;nbsp; At 10 you can do:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;!Shape.Length@miles! # to get miles&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At 9.2 I think you can only use Python in Model Builder and the syntax might be !Shape!.Length or some other variant.&amp;nbsp; Check the help files, since there should be something on this for 9.2.&amp;nbsp; If you will not be exporting to a Python script and running it directly in Model Builder you can use VBA in an advanced calculation at 9.2, where the syntax would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Parser: VBA&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-Logic Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim dblLength as double&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pCurve as ICurve&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pCurve = [SHAPE]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dblLength = pCurve.Length / 5280&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression: dblLength&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Oct 2011 13:46:57 GMT</pubDate>
    <dc:creator>RichardFairhurst</dc:creator>
    <dc:date>2011-10-20T13:46:57Z</dc:date>
    <item>
      <title>Calculate mileage calculation in model builder:</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569321#M18777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am attempting to calculate linear mileage of stream data for three predefined fields in model builder.&amp;nbsp; The conceptual approach is to calculate all segments mileage in the first field (total_miles), then calculate a fraction of the records in another field (need_miles), and finally, calculate the percentage of the two in the final field (percentage).&amp;nbsp; I'll use frequency to agregate the segments to their respective HUC 12 areas.&amp;nbsp; The problem I am having, is how to calculate geometry (linear mileage) in model builder?&amp;nbsp; I can't seem to locate the tool that may be dragged to model builder.&amp;nbsp; Thanks so much in advance!!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 18:23:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569321#M18777</guid>
      <dc:creator>MarkEnglish</dc:creator>
      <dc:date>2011-10-19T18:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate mileage calculation in model builder:</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569322#M18778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hello:&lt;BR /&gt;I am attempting to calculate linear mileage of stream data for three predefined fields in model builder.&amp;nbsp; The conceptual approach is to calculate all segments mileage in the first field (total_miles), then calculate a fraction of the records in another field (need_miles), and finally, calculate the percentage of the two in the final field (percentage).&amp;nbsp; I'll use frequency to agregate the segments to their respective HUC 12 areas.&amp;nbsp; The problem I am having, is how to calculate geometry (linear mileage) in model builder?&amp;nbsp; I can't seem to locate the tool that may be dragged to model builder.&amp;nbsp; Thanks so much in advance!!!!&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;A few ways to do this.&amp;nbsp; Sum the Length value in the frequency in whatever units they are listed (assming this is a geodatabase and not a shapefile), then do the conversion to miles at the join and calculation stage.&amp;nbsp; If you are using a shapefile, first calculate a field called MILES using the Field Calculator tool.&amp;nbsp; The python calculation to get the length of a line and make the appropriate units conversion is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Parser:&amp;nbsp; Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-Logic Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def Output(Length):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return Length / 5280 # assumes that shape length is in Feet and is being converted to Miles.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output(!SHAPE.LENGTH!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;now sum the MILES field values in your frequency and you can get the all of the fields filled in that you need.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 22:26:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569322#M18778</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2011-10-19T22:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate mileage calculation in model builder:</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569323#M18779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for you quick reply, although am not certain I'm following your logic precisely.&amp;nbsp; And yes, I am using feature classes.&amp;nbsp; When calculating without model builder, I create the two fields to house mileage (total miles and need miles), use calculate geometry to populate the segmets mileage, and then perform frequency analysis to summarize the values of the HUC 12s.&amp;nbsp; Using model builder,&amp;nbsp; should I be using calculate field prior to utilizing frequency, and what calculation would work for empty fields? Thanks again!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2011 01:19:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569323#M18779</guid>
      <dc:creator>MarkEnglish</dc:creator>
      <dc:date>2011-10-20T01:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate mileage calculation in model builder:</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569324#M18780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks for you quick reply, although am not certain I'm following your logic precisely.&amp;nbsp; And yes, I am using feature classes.&amp;nbsp; When calculating without model builder, I create the two fields to house mileage (total miles and need miles), use calculate geometry to populate the segmets mileage, and then perform frequency analysis to summarize the values of the HUC 12s.&amp;nbsp; Using model builder,&amp;nbsp; should I be using calculate field prior to utilizing frequency, and what calculation would work for empty fields? Thanks again!&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I overcomplicated the calculation.&amp;nbsp; It can be done as a simple calculation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Parser:&amp;nbsp; Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression: !SHAPE.LENGTH! / 5280 # assumes base units is in feet and you want miles.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above calculation is done using the Field Calculator tool and does what the Calculate Geometry tool does in ArcMap, so you would use it the same way that you use the Calculate Geometry tool in your desktop process.&amp;nbsp; This Field Calculator expression is what you had to do in ArcMap versions that existed when you had no Calculate Geometry option.&amp;nbsp; With the Total_Miles and Need_Miles values calculated you would run the Frequency tool the same way you do now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should run a calculation on Need_Miles to populate it with 0 on all records that are Null and that you do not want to be in the subset that has Mileage calcuated into the Need_Miles field prior to running Frequency, unless you find that the Frequency tool does what you want when these values are Null.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2011 03:10:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569324#M18780</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2011-10-20T03:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate mileage calculation in model builder:</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569325#M18781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Richard!&amp;nbsp; You rock!&amp;nbsp; I'll give her a try...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2011 11:18:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569325#M18781</guid>
      <dc:creator>MarkEnglish</dc:creator>
      <dc:date>2011-10-20T11:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate mileage calculation in model builder:</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569326#M18782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Richard, the field calculation for !SHAPE.LENGTH! / 5280 # does not work.&amp;nbsp; It produces a syntax error when ran on an empty field through field calculation.&amp;nbsp; Any thoughts?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2011 12:52:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569326#M18782</guid>
      <dc:creator>MarkEnglish</dc:creator>
      <dc:date>2011-10-20T12:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate mileage calculation in model builder:</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569327#M18783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Richard, the field calculation for !SHAPE.LENGTH! / 5280 # does not work.&amp;nbsp; It produces a syntax error when ran on an empty field through field calculation.&amp;nbsp; Any thoughts?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What version of ArcGIS are you using and are you doing this in Desktop or with Model Builder.&amp;nbsp; This should work for ArcGIS 9.3 and up, although you may have to change the case of the words to mixed case for 10 when ESRI started to make Python case sensitive.&amp;nbsp; At 10 you can do:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;!Shape.Length@miles! # to get miles&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At 9.2 I think you can only use Python in Model Builder and the syntax might be !Shape!.Length or some other variant.&amp;nbsp; Check the help files, since there should be something on this for 9.2.&amp;nbsp; If you will not be exporting to a Python script and running it directly in Model Builder you can use VBA in an advanced calculation at 9.2, where the syntax would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Parser: VBA&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-Logic Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim dblLength as double&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pCurve as ICurve&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pCurve = [SHAPE]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dblLength = pCurve.Length / 5280&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression: dblLength&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2011 13:46:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-mileage-calculation-in-model-builder/m-p/569327#M18783</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2011-10-20T13:46:57Z</dc:date>
    </item>
  </channel>
</rss>

