<?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 UTM Conversion in Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/utm-conversion-in-python/m-p/382912#M30158</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was wondering if anyone could give me any ideas/thoughts/links to get myself familiar UTM Conversion from lat long. I am using a lot of DEM data (i.e. SRTM or AGDEM) who provide the data in tif format with the name representing the lat long in WGS84 (center?). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i.e. ASTMGTM2_N37W110 = North037 and W-110 degrees that according to &lt;/SPAN&gt;&lt;A href="http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html"&gt;http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp; conversion tool would be in UTM zone 12. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I could apply an automated process similar to that conversion tool on the downloaded datasets (using the name in lat/long)then I would simply need to apply the standard project raster tool in ArcGIS to apply the actual projection of the data. I realize that one could define the projection in the project raster manually and then use a batch process but I was wondering if a fully automated solution in python is possible?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sincerely,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bjorn&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Nov 2011 13:13:37 GMT</pubDate>
    <dc:creator>JohanL</dc:creator>
    <dc:date>2011-11-11T13:13:37Z</dc:date>
    <item>
      <title>UTM Conversion in Python</title>
      <link>https://community.esri.com/t5/python-questions/utm-conversion-in-python/m-p/382912#M30158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was wondering if anyone could give me any ideas/thoughts/links to get myself familiar UTM Conversion from lat long. I am using a lot of DEM data (i.e. SRTM or AGDEM) who provide the data in tif format with the name representing the lat long in WGS84 (center?). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i.e. ASTMGTM2_N37W110 = North037 and W-110 degrees that according to &lt;/SPAN&gt;&lt;A href="http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html"&gt;http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp; conversion tool would be in UTM zone 12. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I could apply an automated process similar to that conversion tool on the downloaded datasets (using the name in lat/long)then I would simply need to apply the standard project raster tool in ArcGIS to apply the actual projection of the data. I realize that one could define the projection in the project raster manually and then use a batch process but I was wondering if a fully automated solution in python is possible?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sincerely,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bjorn&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Nov 2011 13:13:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/utm-conversion-in-python/m-p/382912#M30158</guid>
      <dc:creator>JohanL</dc:creator>
      <dc:date>2011-11-11T13:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: UTM Conversion in Python</title>
      <link>https://community.esri.com/t5/python-questions/utm-conversion-in-python/m-p/382913#M30159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Bjorn,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could automate the procedure of finding which zone each raster falls in.&amp;nbsp; Each install of ArcGIS includes reference data in the directory 'C:\Program Files (x86)\ArcGIS\Desktop10.0\Reference Systems'.&amp;nbsp; There is a UTM.shp located here and you can use this to determine each zone for each TIFF.&amp;nbsp; Here is an example on how to do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
env.overwriteOutput = True
prjFile = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj"
spatRef = arcpy.SpatialReference(prjFile)

# list each raster and extract coordinates
env.workspace = r"C:\temp\python\rasters"
lstRasters = arcpy.ListRasters("*", "TIF")
for ras in lstRasters:
&amp;nbsp;&amp;nbsp;&amp;nbsp; rasName = ras.split('.')[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; lat_lon = rasName.split('_')[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; if 'N' in lat_lon:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lat = int(lat_lon[1:3])
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lat = int(lat_lon[1:3]) * -1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if 'W' in lat_lon:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lon = int(lat_lon[4:]) * -1
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lon = int(lat_lon[4:])
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create a point based on the coordinate values
&amp;nbsp;&amp;nbsp;&amp;nbsp; point = arcpy.Point(lon, lat)

&amp;nbsp;&amp;nbsp;&amp;nbsp; UTMfc = r"C:\TEMP\Python\UTM.shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # create an empty point feature class with a field called 'Name'
&amp;nbsp;&amp;nbsp;&amp;nbsp; env.workspace = r"C:\temp\python\test.gdb"&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateFeatureclass_management(env.workspace, "LatLon", "POINT", "", "", "", spatRef)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management("LatLon", "Name", "TEXT")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Populate the feature class with the coordinate value and the raster name
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.InsertCursor("LatLon")
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.newRow()
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Name = rasName
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Shape = point
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.insertRow(row)

&amp;nbsp;&amp;nbsp;&amp;nbsp; del row, rows

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Perform an intersect to find which zone the raster falls in
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Intersect_analysis(["LatLon", UTMfc], "Intersect", "", "", "POINT")
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor("Intersect")
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print str(row.Name) + " is in zone UTM" + str(row.Zone)

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("LatLon")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("Intersect")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could probably append some additional code onto this to project the raster based on the zone it falls within.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:38:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/utm-conversion-in-python/m-p/382913#M30159</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T17:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: UTM Conversion in Python</title>
      <link>https://community.esri.com/t5/python-questions/utm-conversion-in-python/m-p/382914#M30160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello colleagues,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for this code, it's partly what I was looking for too. Large amounts of ASTER to project to an appropriate UTM zone. I can get the zone using your sample code above, but that is not all, it seems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To create the out_coordinate_system for use in arcpy.ProjectRaster_management , a huge string with the coordinate system's properties needs to be made. Is there a way to do that, based on the now-known zone?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 16:59:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/utm-conversion-in-python/m-p/382914#M30160</guid>
      <dc:creator>ArnaudTemme</dc:creator>
      <dc:date>2012-08-08T16:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: UTM Conversion in Python</title>
      <link>https://community.esri.com/t5/python-questions/utm-conversion-in-python/m-p/382915#M30161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, don't bother with the string. Create a SpatialReference object and set the Factory Code or the Name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
sr = arcpy.SpatialReference()
sr.factoryCode = 32759 # case sensitive
sr.create() # essential step that is non-intuitive!
print sr.name # to check

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At 10.1 the library of strings for standard projections has disappeared! They are now built in to ArcGIS.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The factorycode is the most reliable but hardest to find, look up the projected_coordinate_systems.PDF in the root ArcGIS documentation directory. I can never remember what name property is required to be set to make it work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:38:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/utm-conversion-in-python/m-p/382915#M30161</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2021-12-11T17:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: UTM Conversion in Python</title>
      <link>https://community.esri.com/t5/python-questions/utm-conversion-in-python/m-p/382916#M30162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks a lot, this is brilliant! I will be able to make it work now.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Aug 2012 21:34:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/utm-conversion-in-python/m-p/382916#M30162</guid>
      <dc:creator>ArnaudTemme</dc:creator>
      <dc:date>2012-08-14T21:34:53Z</dc:date>
    </item>
  </channel>
</rss>

