<?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: set spatial reference for a newly created raster data inside the java code in Java Maps SDK Questions</title>
    <link>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498995#M1538</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adam, thank you very much . It worked!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Spatial reference of my original raster data was saving in the header of my image, so my aux.xml files didn't have spatial reference information, that's why I didn't know how an aux.xml file could contain the spatial reference as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Feb 2016 19:47:12 GMT</pubDate>
    <dc:creator>MohammdrezaFaraji</dc:creator>
    <dc:date>2016-02-10T19:47:12Z</dc:date>
    <item>
      <title>set spatial reference for a newly created raster data inside the java code</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498991#M1534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a random image and I manually created a world file for it. So the world file contains the correct scales and UTM coordinates for the top-left corner of the image.&lt;/P&gt;&lt;P&gt;I am trying to add this as a raster data (&lt;A href="https://developers.arcgis.com/java/guide/add-raster-data.htm" title="https://developers.arcgis.com/java/guide/add-raster-data.htm"&gt;Add raster data—ArcGIS Runtime SDK for Java | ArcGIS for Developers&lt;/A&gt; ) to the Bing map. The bing map's spatial reference is WGS_1984_Web_Mercator_Auxiliary_Sphere, but my UTM coordinates in the world file for the image are WGS_1984_UTM_Zone_12N. So I need to know how exactly I should assign the proper spatial reference in my java code to the image (imported as the raster data), so it gets displayed in the right location on the bing map.&lt;/P&gt;&lt;P&gt;I know how I can set a spatial reference for a raster data (that does not have one) inside the Arc Map, but I need to do this inside my Arc GIS Runtime java-based application.&lt;/P&gt;&lt;P&gt;Would you please help me on this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Feb 2016 04:38:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498991#M1534</guid>
      <dc:creator>MohammdrezaFaraji</dc:creator>
      <dc:date>2016-02-04T04:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: set spatial reference for a newly created raster data inside the java code</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498992#M1535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; try this code to save world file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;File writerWld = new File();
BufferedWriter writerWld = new BufferedWriter(new FileWriter(wld))) {
Integer mapheight = map.exportMapImage().getHeight();
Integer mapwidth = map.exportMapImage().getWidth();
Double coordHeight = (map.getExtent().getUpperLeft().getY() - map.getExtent().getLowerLeft().getY());
Double coordWidth = (map.getExtent().getUpperRight().getX() - map.getExtent().getUpperLeft().getX());
writerWld.write(String.valueOf(coordWidth / mapwidth));
writerWld.newLine();
writerWld.write("0.000000");
writerWld.newLine();
writerWld.write("0.000000");
writerWld.newLine();
writerWld.write("-" + String.valueOf(coordHeight / mapheight));
writerWld.newLine();
writerWld.write(String.valueOf((map.getExtent().getUpperLeft().getX())));
writerWld.newLine();
writerWld.write(String.valueOf(map.getExtent().getUpperLeft().getY()));&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suggest you create aux.xml file as well. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:55:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498992#M1535</guid>
      <dc:creator>nita14</dc:creator>
      <dc:date>2021-12-11T21:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: set spatial reference for a newly created raster data inside the java code</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498993#M1536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adam, thanks you for the answer.&lt;BR /&gt;However, I'm not sure if that's answering my question.&lt;BR /&gt;I know how to create the world file. The thing is, I have a BufferedImage which is created inside my java code, then I save/write this image on my computer. Meanwhile, Knowing the east/north scales of the image and easting/northing coordinates of its top-right corner, I create its world file by the below code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PrintWriter writer = new PrintWriter("D:\\imageName.tfw", "UTF-8");&lt;/P&gt;&lt;P&gt;writer.println(NorthScale);&lt;/P&gt;&lt;P&gt;writer.println(0.0);&lt;/P&gt;&lt;P&gt;writer.println(0.0);&lt;/P&gt;&lt;P&gt;writer.println(EastScale);&lt;/P&gt;&lt;P&gt;writer.println(Easting);&lt;/P&gt;&lt;P&gt;writer.println(Northing);&lt;/P&gt;&lt;P&gt;writer.close();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This correctly creates a world file in the same location/name as my saved image. Now, if I want to load this image as&amp;nbsp; raster data on the right location on my base map inside my java code, I need to add its spatial reference (e.x., "WGS_1984_UTM_Zone_8N") so it can be displayed in the right location.&lt;/P&gt;&lt;P&gt;In ArcMap, this could be done by right click on the image in the Catalog and then click on Properties and finally editing the Spatial Reference inside "Raster Dataset Properties" window. But I need to do this in java and using java code and my question is how I should do this inside my Arc GIS Runtime java code!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mohammad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Feb 2016 20:49:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498993#M1536</guid>
      <dc:creator>MohammdrezaFaraji</dc:creator>
      <dc:date>2016-02-09T20:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: set spatial reference for a newly created raster data inside the java code</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498994#M1537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Mohammad,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;that is why I suggested creation of aux.xml file associated with your tiff file. Inside xml file you will see definition of raster's coordinate system. This file is automatically saved by ArcMap, so you can examine it 's structure, by making a sample raster in your coordinate system.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Regarding reprojection on the fly, &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;According to the documentation it &lt;/SPAN&gt;is not done automatically in ArcGIS Runtime. You need to test it. If the raster location is wrong, then I would try to use &lt;EM&gt;project &lt;/EM&gt;method on RasterSource. See the sample; &lt;A href="https://developers.arcgis.com/java/guide/add-raster-data.htm" title="https://developers.arcgis.com/java/guide/add-raster-data.htm"&gt;Add raster data—ArcGIS Runtime SDK for Java | ArcGIS for Developers&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Adam&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Feb 2016 21:09:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498994#M1537</guid>
      <dc:creator>nita14</dc:creator>
      <dc:date>2016-02-09T21:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: set spatial reference for a newly created raster data inside the java code</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498995#M1538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adam, thank you very much . It worked!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Spatial reference of my original raster data was saving in the header of my image, so my aux.xml files didn't have spatial reference information, that's why I didn't know how an aux.xml file could contain the spatial reference as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2016 19:47:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498995#M1538</guid>
      <dc:creator>MohammdrezaFaraji</dc:creator>
      <dc:date>2016-02-10T19:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: set spatial reference for a newly created raster data inside the java code</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498996#M1539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am glad it works as expected. Unfortunately, GeoTIFF (without world file) is not yet supported as local raster source in ArcGIS Runtime. Hope this is going to change as Quartz will be released.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Feb 2016 06:09:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/set-spatial-reference-for-a-newly-created-raster/m-p/498996#M1539</guid>
      <dc:creator>nita14</dc:creator>
      <dc:date>2016-02-11T06:09:18Z</dc:date>
    </item>
  </channel>
</rss>

