<?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 Not able to correctly infer GPS points from geotiff in Javascript in ArcGIS Image Server Questions</title>
    <link>https://community.esri.com/t5/arcgis-image-server-questions/not-able-to-correctly-infer-gps-points-from/m-p/1367101#M1698</link>
    <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;I am trying to create a list of &amp;lt;lat, long, elevation&amp;gt; for each pixel in a geotiff.&lt;/P&gt;&lt;P&gt;The script below seems to be getting values, but when I check the lat/longs on the same geotiff imported into Arcgis Pro I get different values.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;import&lt;/SPAN&gt; { fromFile } &lt;SPAN class=""&gt;from&lt;/SPAN&gt; &lt;SPAN class=""&gt;'geotiff'&lt;/SPAN&gt;;

&lt;SPAN class=""&gt;//Script assumes EPSG:4326&lt;/SPAN&gt;

&lt;SPAN class=""&gt;async&lt;/SPAN&gt; &lt;SPAN class=""&gt;function&lt;/SPAN&gt; &lt;SPAN class=""&gt;readDemToXyz&lt;/SPAN&gt;(&lt;SPAN class=""&gt;filename&lt;/SPAN&gt;) {
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; tiff = &lt;SPAN class=""&gt;await&lt;/SPAN&gt; &lt;SPAN class=""&gt;fromFile&lt;/SPAN&gt;(filename);
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; image = &lt;SPAN class=""&gt;await&lt;/SPAN&gt; tiff.&lt;SPAN class=""&gt;getImage&lt;/SPAN&gt;();
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; width = image.&lt;SPAN class=""&gt;getWidth&lt;/SPAN&gt;();
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; height = image.&lt;SPAN class=""&gt;getHeight&lt;/SPAN&gt;();
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; bbox = image.&lt;SPAN class=""&gt;getBoundingBox&lt;/SPAN&gt;();
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; elevationData = &lt;SPAN class=""&gt;await&lt;/SPAN&gt; image.&lt;SPAN class=""&gt;readRasters&lt;/SPAN&gt;({ &lt;SPAN class=""&gt;interleave&lt;/SPAN&gt;: &lt;SPAN class=""&gt;true&lt;/SPAN&gt; });

  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; deltaX = (bbox[&lt;SPAN class=""&gt;2&lt;/SPAN&gt;] - bbox[&lt;SPAN class=""&gt;0&lt;/SPAN&gt;]) / width;
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; deltaY = (bbox[&lt;SPAN class=""&gt;3&lt;/SPAN&gt;] - bbox[&lt;SPAN class=""&gt;1&lt;/SPAN&gt;]) / height;

  &lt;SPAN class=""&gt;let&lt;/SPAN&gt; xyzData = [];

  &lt;SPAN class=""&gt;for&lt;/SPAN&gt; (&lt;SPAN class=""&gt;let&lt;/SPAN&gt; i = &lt;SPAN class=""&gt;0&lt;/SPAN&gt;; i &amp;lt; height; i++) {
    &lt;SPAN class=""&gt;for&lt;/SPAN&gt; (&lt;SPAN class=""&gt;let&lt;/SPAN&gt; j = &lt;SPAN class=""&gt;0&lt;/SPAN&gt;; j &amp;lt; width; j++) {
      &lt;SPAN class=""&gt;const&lt;/SPAN&gt; x = bbox[&lt;SPAN class=""&gt;0&lt;/SPAN&gt;] + j * deltaX;
      &lt;SPAN class=""&gt;const&lt;/SPAN&gt; y = bbox[&lt;SPAN class=""&gt;1&lt;/SPAN&gt;] + i * deltaY;
      &lt;SPAN class=""&gt;const&lt;/SPAN&gt; z = elevationData[i * width + j];
      &lt;SPAN class=""&gt;console&lt;/SPAN&gt;.&lt;SPAN class=""&gt;log&lt;/SPAN&gt;(&lt;SPAN class=""&gt;`Coordinates: (&lt;SPAN class=""&gt;${x.toFixed(&lt;SPAN class=""&gt;9&lt;/SPAN&gt;)}&lt;/SPAN&gt;, &lt;SPAN class=""&gt;${y.toFixed(&lt;SPAN class=""&gt;9&lt;/SPAN&gt;)}&lt;/SPAN&gt;), Elevation: &lt;SPAN class=""&gt;${z}&lt;/SPAN&gt;`&lt;/SPAN&gt;);

      xyzData.&lt;SPAN class=""&gt;push&lt;/SPAN&gt;([x, y, z]);
    }
  }

  &lt;SPAN class=""&gt;return&lt;/SPAN&gt; xyzData;
}

&lt;SPAN class=""&gt;// Usage&lt;/SPAN&gt;
&lt;SPAN class=""&gt;const&lt;/SPAN&gt; filename = &lt;SPAN class=""&gt;'example.tif'&lt;/SPAN&gt;;
&lt;SPAN class=""&gt;readDemToXyz&lt;/SPAN&gt;(filename).&lt;SPAN class=""&gt;then&lt;/SPAN&gt;(&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;xyzData&lt;/SPAN&gt; =&amp;gt;&lt;/SPAN&gt; {
  &lt;SPAN class=""&gt;//console.log(xyzData.slice(0, 100));  // Print the first 100 [x, y, MSL] values&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;//console.log("Printing all values")&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;//console.log(xyzData)&lt;/SPAN&gt;
});

&lt;/PRE&gt;&lt;P&gt;example console.log Coordinates: (-83.298493884, 34.970485560), Elevation: 1079.0888671875&lt;/P&gt;&lt;P&gt;example lat/long being checking Arcgis Pro&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.png" style="width: 980px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/90755i220233EB27B049E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.png" alt="3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;image showing that the map crs&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4.png" style="width: 937px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/90756i3E09E2B202212879/image-size/large?v=v2&amp;amp;px=999" role="button" title="4.png" alt="4.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;image showing export of dem geotiff crs&lt;/P&gt;&lt;P&gt;I was expecting that &amp;lt;lat, long, elevation&amp;gt; values would be the same in the console.log as they were in Arcgis Pro on the same Geotiff.&lt;/P&gt;&lt;P&gt;Instead they are different and I'm not sure why.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Sat, 06 Jan 2024 11:24:52 GMT</pubDate>
    <dc:creator>Kimmart</dc:creator>
    <dc:date>2024-01-06T11:24:52Z</dc:date>
    <item>
      <title>Not able to correctly infer GPS points from geotiff in Javascript</title>
      <link>https://community.esri.com/t5/arcgis-image-server-questions/not-able-to-correctly-infer-gps-points-from/m-p/1367101#M1698</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;I am trying to create a list of &amp;lt;lat, long, elevation&amp;gt; for each pixel in a geotiff.&lt;/P&gt;&lt;P&gt;The script below seems to be getting values, but when I check the lat/longs on the same geotiff imported into Arcgis Pro I get different values.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;import&lt;/SPAN&gt; { fromFile } &lt;SPAN class=""&gt;from&lt;/SPAN&gt; &lt;SPAN class=""&gt;'geotiff'&lt;/SPAN&gt;;

&lt;SPAN class=""&gt;//Script assumes EPSG:4326&lt;/SPAN&gt;

&lt;SPAN class=""&gt;async&lt;/SPAN&gt; &lt;SPAN class=""&gt;function&lt;/SPAN&gt; &lt;SPAN class=""&gt;readDemToXyz&lt;/SPAN&gt;(&lt;SPAN class=""&gt;filename&lt;/SPAN&gt;) {
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; tiff = &lt;SPAN class=""&gt;await&lt;/SPAN&gt; &lt;SPAN class=""&gt;fromFile&lt;/SPAN&gt;(filename);
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; image = &lt;SPAN class=""&gt;await&lt;/SPAN&gt; tiff.&lt;SPAN class=""&gt;getImage&lt;/SPAN&gt;();
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; width = image.&lt;SPAN class=""&gt;getWidth&lt;/SPAN&gt;();
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; height = image.&lt;SPAN class=""&gt;getHeight&lt;/SPAN&gt;();
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; bbox = image.&lt;SPAN class=""&gt;getBoundingBox&lt;/SPAN&gt;();
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; elevationData = &lt;SPAN class=""&gt;await&lt;/SPAN&gt; image.&lt;SPAN class=""&gt;readRasters&lt;/SPAN&gt;({ &lt;SPAN class=""&gt;interleave&lt;/SPAN&gt;: &lt;SPAN class=""&gt;true&lt;/SPAN&gt; });

  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; deltaX = (bbox[&lt;SPAN class=""&gt;2&lt;/SPAN&gt;] - bbox[&lt;SPAN class=""&gt;0&lt;/SPAN&gt;]) / width;
  &lt;SPAN class=""&gt;const&lt;/SPAN&gt; deltaY = (bbox[&lt;SPAN class=""&gt;3&lt;/SPAN&gt;] - bbox[&lt;SPAN class=""&gt;1&lt;/SPAN&gt;]) / height;

  &lt;SPAN class=""&gt;let&lt;/SPAN&gt; xyzData = [];

  &lt;SPAN class=""&gt;for&lt;/SPAN&gt; (&lt;SPAN class=""&gt;let&lt;/SPAN&gt; i = &lt;SPAN class=""&gt;0&lt;/SPAN&gt;; i &amp;lt; height; i++) {
    &lt;SPAN class=""&gt;for&lt;/SPAN&gt; (&lt;SPAN class=""&gt;let&lt;/SPAN&gt; j = &lt;SPAN class=""&gt;0&lt;/SPAN&gt;; j &amp;lt; width; j++) {
      &lt;SPAN class=""&gt;const&lt;/SPAN&gt; x = bbox[&lt;SPAN class=""&gt;0&lt;/SPAN&gt;] + j * deltaX;
      &lt;SPAN class=""&gt;const&lt;/SPAN&gt; y = bbox[&lt;SPAN class=""&gt;1&lt;/SPAN&gt;] + i * deltaY;
      &lt;SPAN class=""&gt;const&lt;/SPAN&gt; z = elevationData[i * width + j];
      &lt;SPAN class=""&gt;console&lt;/SPAN&gt;.&lt;SPAN class=""&gt;log&lt;/SPAN&gt;(&lt;SPAN class=""&gt;`Coordinates: (&lt;SPAN class=""&gt;${x.toFixed(&lt;SPAN class=""&gt;9&lt;/SPAN&gt;)}&lt;/SPAN&gt;, &lt;SPAN class=""&gt;${y.toFixed(&lt;SPAN class=""&gt;9&lt;/SPAN&gt;)}&lt;/SPAN&gt;), Elevation: &lt;SPAN class=""&gt;${z}&lt;/SPAN&gt;`&lt;/SPAN&gt;);

      xyzData.&lt;SPAN class=""&gt;push&lt;/SPAN&gt;([x, y, z]);
    }
  }

  &lt;SPAN class=""&gt;return&lt;/SPAN&gt; xyzData;
}

&lt;SPAN class=""&gt;// Usage&lt;/SPAN&gt;
&lt;SPAN class=""&gt;const&lt;/SPAN&gt; filename = &lt;SPAN class=""&gt;'example.tif'&lt;/SPAN&gt;;
&lt;SPAN class=""&gt;readDemToXyz&lt;/SPAN&gt;(filename).&lt;SPAN class=""&gt;then&lt;/SPAN&gt;(&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;xyzData&lt;/SPAN&gt; =&amp;gt;&lt;/SPAN&gt; {
  &lt;SPAN class=""&gt;//console.log(xyzData.slice(0, 100));  // Print the first 100 [x, y, MSL] values&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;//console.log("Printing all values")&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;//console.log(xyzData)&lt;/SPAN&gt;
});

&lt;/PRE&gt;&lt;P&gt;example console.log Coordinates: (-83.298493884, 34.970485560), Elevation: 1079.0888671875&lt;/P&gt;&lt;P&gt;example lat/long being checking Arcgis Pro&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.png" style="width: 980px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/90755i220233EB27B049E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.png" alt="3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;image showing that the map crs&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4.png" style="width: 937px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/90756i3E09E2B202212879/image-size/large?v=v2&amp;amp;px=999" role="button" title="4.png" alt="4.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;image showing export of dem geotiff crs&lt;/P&gt;&lt;P&gt;I was expecting that &amp;lt;lat, long, elevation&amp;gt; values would be the same in the console.log as they were in Arcgis Pro on the same Geotiff.&lt;/P&gt;&lt;P&gt;Instead they are different and I'm not sure why.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 06 Jan 2024 11:24:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-image-server-questions/not-able-to-correctly-infer-gps-points-from/m-p/1367101#M1698</guid>
      <dc:creator>Kimmart</dc:creator>
      <dc:date>2024-01-06T11:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to correctly infer GPS points from geotiff in Javascript</title>
      <link>https://community.esri.com/t5/arcgis-image-server-questions/not-able-to-correctly-infer-gps-points-from/m-p/1419692#M1710</link>
      <description>&lt;P&gt;i am not very sure about the geotiff lib that you used here. could there be a problem on the point of origin?&lt;/P&gt;&lt;P&gt;another suggestion: could you convert your geotiff into a cloud-optimized geotiff? in this way, you will be able to use arcgis javascript api and create an imagery tile layer out of it. imagery tile layer will support get pixel value at a specific location. you may use this workflow as cross check.&lt;/P&gt;&lt;P&gt;if i were to debug the problem, i would use arcgis pro as the baseline. it is the most reliable in most cases...&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 22:32:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-image-server-questions/not-able-to-correctly-infer-gps-points-from/m-p/1419692#M1710</guid>
      <dc:creator>Zikang</dc:creator>
      <dc:date>2024-05-06T22:32:25Z</dc:date>
    </item>
  </channel>
</rss>

