<?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: outStatistics in a query deletes geometry data in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/outstatistics-in-a-query-deletes-geometry-data/m-p/233371#M21769</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I think I understand now. As soon as you populate the outStatistics of the query, we assume you only want to get statistics. What you could do, is run the query first to get your features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can do the statistics query against the layerview, this will run the query on the data already available on the client rather than go back to the server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have a number of samples for this kind of pattern.&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/latest/sample-code/?search=statistics" title="https://developers.arcgis.com/javascript/latest/sample-code/?search=statistics"&gt;Sample Code | ArcGIS API for JavaScript 4.13&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you would need to perform two queries, but you don't have to go back to the server twice if you don't want to.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Dec 2019 19:28:44 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2019-12-03T19:28:44Z</dc:date>
    <item>
      <title>outStatistics in a query deletes geometry data</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/outstatistics-in-a-query-deletes-geometry-data/m-p/233368#M21766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="text-align: left;"&gt;So i have a working query that returns a&amp;nbsp; featureSet that is made&amp;nbsp;into a layer.&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;&amp;nbsp;I want to add some stats about the query&amp;nbsp;and add them to a&amp;nbsp;feature.&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;i added a simple statistic query that works but when its time to create a new layer after the query is returned i get :&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;name: "feature-layer:missing-property", message: "geometryType not set and couldn't be inferred from the provided features"&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;this error is automaticly fixed when i cross the query.outStatistics&amp;nbsp; line from my query.&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;do i really need to create two identical querys for stats and for visual display?&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;heres a pen with the &lt;SPAN&gt;query.outStatistics&lt;/SPAN&gt; crossed out:&amp;nbsp;&lt;A class="" href="https://codepen.io/segev-salman/pen/OJPJGxX" title="https://codepen.io/segev-salman/pen/OJPJGxX"&gt;https://codepen.io/segev-salman/pen/OJPJGxX&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Dec 2019 08:44:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/outstatistics-in-a-query-deletes-geometry-data/m-p/233368#M21766</guid>
      <dc:creator>deleted-user-wcpelUUf_XXx</dc:creator>
      <dc:date>2019-12-03T08:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: outStatistics in a query deletes geometry data</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/outstatistics-in-a-query-deletes-geometry-data/m-p/233369#M21767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;outStatistics does not return geometry, as the statistics are based on all the values that meet the where clause of your query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not quite clear on what you are trying to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; avgPricePerMeter &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  onStatisticField&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"OBJECTID"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;// service field for 2015 population&lt;/SPAN&gt;
  outStatisticFieldName&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"PricePerMeter_avg"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
  statisticType&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"avg"&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OBJECTID fields don't have any meaning beyond being unique identifiers. Do you intend to do something like this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; avgPricePerMeter &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  onStatisticField&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"PricePerMeter"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;// field that has price information?&lt;/SPAN&gt;
  outStatisticFieldName&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"PricePerMeter_avg"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
  statisticType&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"avg"&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will do SQL query similar to this against your data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;AVG&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;PricePerMeter&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;AS&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'PricePerMeter_avg'&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;FROM&lt;/SPAN&gt; service
&lt;SPAN class="keyword token"&gt;WHERE&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt;query&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;where&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which only returns a single result with your Average stat on that field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:48:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/outstatistics-in-a-query-deletes-geometry-data/m-p/233369#M21767</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-11T11:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: outStatistics in a query deletes geometry data</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/outstatistics-in-a-query-deletes-geometry-data/m-p/233370#M21768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="text-align: left;"&gt;This is exactly right, I should have clarified that the layer is just a filler.&lt;/P&gt;&lt;P style="text-align: left;"&gt;The real layer has building groups as id (the input) and i want the avg of their price.&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;I dont expect outStatistics to return geometry, and wrote the right query(using ObjectID just as a filler expecting to get the same result entered as avg) but in the same query i ask for geometry and outfields.&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;dont i get them all as part of the featureSet?&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;can it look like this?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;"&gt;var&lt;/SPAN&gt; avgPricePerMeter &lt;SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;"&gt;=&lt;/SPAN&gt; &lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;{&lt;/SPAN&gt;
&amp;nbsp; onStatisticField&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;:&lt;/SPAN&gt; &lt;SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;"&gt;"PricePerMeter"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;,&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;"&gt;// field that has price information?&lt;/SPAN&gt;
&amp;nbsp; outStatisticFieldName&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;:&lt;/SPAN&gt; &lt;SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;"&gt;"PricePerMeter_avg"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;,&lt;/SPAN&gt;
&amp;nbsp; statisticType&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;:&lt;/SPAN&gt; &lt;SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;"&gt;"avg"&lt;/SPAN&gt;
&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;}&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;;

 var query = pointService.createQuery(); 
 query.returnGeometry = true;
 query.outFields = ["*"];
 query.where = gushHelka + " = " + input
 query.outStatistics = [avgPricePerMeter]

&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;giving me the geometry stats and fields all of them essential to my popupTempalte at the same time&lt;/P&gt;&lt;P style="text-align: left;"&gt;I made this new pen :&amp;nbsp;&lt;A class="link-titled" href="https://codepen.io/segev-salman/pen/YzPPPNo" title="https://codepen.io/segev-salman/pen/YzPPPNo" rel="nofollow noopener noreferrer" target="_blank"&gt;https://codepen.io/segev-salman/pen/YzPPPNo&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;Assuming i cant get it all in the same query i made nquey just for the statistics and featureUpdate as a function that builds a new popuptemplate with the basic fields and the stats using only the featureSet from the nquery, problem was&lt;/P&gt;&lt;P style="text-align: left;"&gt;that i got the avg stat but not the name or objectid even tho i had the outfields inside nquery too.&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;I scraped it after timing issues getting the avg after the template was already made and thinking about making a promise that waits for the stats and then makes the layer.&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;This has got to be the wrong way to go about it right? I already have a query with the right results do i need to make the same one from 0 and wait for then again just to avg a field?&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;*sorry for the formatting im using a phone&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:48:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/outstatistics-in-a-query-deletes-geometry-data/m-p/233370#M21768</guid>
      <dc:creator>deleted-user-wcpelUUf_XXx</dc:creator>
      <dc:date>2021-12-11T11:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: outStatistics in a query deletes geometry data</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/outstatistics-in-a-query-deletes-geometry-data/m-p/233371#M21769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I think I understand now. As soon as you populate the outStatistics of the query, we assume you only want to get statistics. What you could do, is run the query first to get your features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can do the statistics query against the layerview, this will run the query on the data already available on the client rather than go back to the server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have a number of samples for this kind of pattern.&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/latest/sample-code/?search=statistics" title="https://developers.arcgis.com/javascript/latest/sample-code/?search=statistics"&gt;Sample Code | ArcGIS API for JavaScript 4.13&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you would need to perform two queries, but you don't have to go back to the server twice if you don't want to.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Dec 2019 19:28:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/outstatistics-in-a-query-deletes-geometry-data/m-p/233371#M21769</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2019-12-03T19:28:44Z</dc:date>
    </item>
  </channel>
</rss>

