<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 29 Oct 2018, at 19:11, Robb Main &lt;<a href="mailto:rmain.mws@gmail.com" class="">rmain.mws@gmail.com</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">One final question, and I'll stop beating this to death:
<div class="">From my naive viewpoint, I want to supply a lat &amp; long coordinate, and receive a UTM coordinate (i.e, zone, easting, northing).</div>
<div class="">Obviously, determining a zone is the first step required in the process, but it would seem to be something that cs2cs could (/should?) handle.</div>
</div>
</div>
</blockquote>
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="">The zone IS determined from the longitude (even if it is supplied on the command line).</div>
</div>
</div>
</blockquote>
</div>
<div>
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class=""><br class="">
</div>
<div class="">Is there some philosophical reason PROJ tools don't currently do this?</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div><br class="">
</div>
<div>Theoretically PROJ could do that, but I don’t think that it should. The zone is set up before any coordinates are passed to the projection, so given the current architecture PROJ wouldn’t know what to base the zone choice on. This could of course be changed
 so that for every coordinate passed to the projection an “optimal zone” could be determined from the input and the projection parameters adjusted accordingly. Let’s have a look at what that would mean in a real world implementation. Say you have two coordinates
 with the same latitude and the longitude spaced exactly six degrees. For instance somewhere in Germany, 51N 6E and 51N 12E. Using a dynamically assigned UTM zone the first coordinate would end up in zone 31 and the second in zone 32. Let’s look at the UTM
 coordinates for both points:</div>
<div><br class="">
</div>
<div>
<div>$ echo 6 51 | proj &#43;proj=utm &#43;zone=31</div>
<div>710488.86 &nbsp; &nbsp; &nbsp; 5654109.18</div>
<div><br class="">
</div>
<div>
<div>$ echo 12 51 | proj &#43;proj=utm &#43;zone=32</div>
<div>710488.86 &nbsp; &nbsp; &nbsp; 5654109.18</div>
<div><br class="">
</div>
<div>They are exactly the same. Now image converting a dataset of the German borders with a UTM projection that dynamically assigns the zone. That is going to be a very big mess when plotted in a map. Additionally, you have eliminated the possibility to convert
 the data back to geodetic coordinates - which one of the 60 possible ways do you choose?</div>
</div>
</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="">Would there be any point in me coding up a patch to support this &amp; submitting a pull request?</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>No.</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="">(I guess that's really two questions...).</div>
<div class="">Thanks again,</div>
<div class="">Robb.</div>
<div class=""><br class="">
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Mon, Oct 29, 2018 at 1:55 PM Kristian Evers &lt;<a href="mailto:kreve@sdfe.dk" class="">kreve@sdfe.dk</a>&gt; wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;line-break:after-white-space" class="">Robb,<br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 29 Oct 2018, at 18:34, Robb Main &lt;<a href="mailto:rmain.mws@gmail.com" target="_blank" class="">rmain.mws@gmail.com</a>&gt; wrote:</div>
<br class="m_1530492544232109511Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Thanks for the link, Kristian.
<div class=""><br class="">
</div>
<div class="">
<div class="">It seemed to me that the source code (specifically proj_etmerc.c:338 - 354) looked like it would calculate the zone if one wasn't supplied (although it also doesn't handle the 'exception' cases mentioned in your link), though I was surprised when
 I could not find a way to request conversion without specifying a zone.</div>
<div class=""><br class="">
</div>
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">In that part of the code it tries to determine the zone from the central meridian set with &#43;lon_0. If neither &#43;zone or &#43;lon_0 is set PROJ defaults to zone 30 (based on the default value of &#43;lon_0 which is 0 when not specified).</div>
<div class=""><br class="">
</div>
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div class="">As I understand your statement though, there is no way to do this with the current implementation of PROJ tools.&nbsp;</div>
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Correct.&nbsp;</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div class="">On the subject of 'correctness', doesn't using a 'clever shell script' like you suggest amount to doing what I was requesting, just doing it outside the PROJ framework?</div>
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
Yes. I am not saying that it is a smart thing to do, but if you really want to, there’s a way to do it.</div>
<div class=""><br class="">
</div>
<div class="">/Kristian<br class="">
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div class="">
<div class="">Regards,</div>
</div>
<div class="">Robb.</div>
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Mon, Oct 29, 2018 at 1:07 PM Kristian Evers &lt;<a href="mailto:kreve@sdfe.dk" target="_blank" class="">kreve@sdfe.dk</a>&gt; wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;line-break:after-white-space" class="">Robb,
<div class=""><br class="">
</div>
<div class="">/Kristian<br class="">
<div class=""><br class="">
</div>
<div class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On 29 Oct 2018, at 17:30, Robb Main &lt;<a href="mailto:rmain.mws@gmail.com" target="_blank" class="">rmain.mws@gmail.com</a>&gt; wrote:</div>
<br class="m_1530492544232109511m_6088843805229460402Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">When converting many lat,long coordinates to UTM, is there some way to setup cs2cs to calculate the UTM zone based on the longitude of the source cordinate system, rather than having to specify the zone on the command line?</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
No. You can probably do something clever in a shell script if you want, but it is not possible with any PROJ tool. See [0] for an overview of how to determine the nearest UTM zone of a coordinate.</div>
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class=""><br class="">
</div>
<div class="">What I'm looking for is something like: instead of this:</div>
<div class="">&nbsp; cs2cs&nbsp;&#43;proj=latlong&nbsp;&#43;data=NAD83&nbsp;&#43;to &#43;proj=utm&nbsp;&#43;zone=10&nbsp;&#43;datum=NAD27 ./input.data</div>
<div class="">you could instead specify:</div>
<div class="">
<div class="">&nbsp; cs2cs&nbsp;&#43;proj=latlong&nbsp;&#43;data=NAD83&nbsp;&#43;to &#43;proj=utm&nbsp;&#43;zone=auto &#43;datum=NAD27 ./input.data</div>
where 'zone=auto' might tell the algorithm to figure the zone out based on longitude of the input coordinate. This would ensure the output data would be correct, even if the input data file contains coordinates that span multiple UTM zones.</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">
<div class="">What you call correct, I regard as potentially incompatible coordinates. What you are proposing here is fundamentally breaking the promise that you are given by the cs2cs application: cs2cs transform coordinates from one coordinate reference system
 to another. With your proposed auto-zoned UTM the output crs would not be properly defined and your output coordinates would be incompatible in the case that they span several UTM zones. You are much better of just sticking to one zone - cs2cs will deliver
 numerically stable coordinates several thousands of kilometers outside the chosen zone.</div>
<div class=""><br class="">
</div>
<div class="">/Kristian</div>
<div class=""><br class="">
</div>
<div class="">[0]&nbsp;<a href="https://stackoverflow.com/questions/9186496/determining-utm-zone-to-convert-from-longitude-latitude" target="_blank" class="">https://stackoverflow.com/questions/9186496/determining-utm-zone-to-convert-from-longitude-latitude</a>&nbsp;</div>
</div>
<br class="">
<blockquote type="cite" class="">
<div class="">_______________________________________________<br class="">
Proj mailing list<br class="">
<a href="mailto:Proj@lists.maptools.org" target="_blank" class="">Proj@lists.maptools.org</a><br class="">
<a href="http://lists.maptools.org/mailman/listinfo/proj" target="_blank" class="">http://lists.maptools.org/mailman/listinfo/proj</a></div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
_______________________________________________<br class="">
Proj mailing list<br class="">
<a href="mailto:Proj@lists.maptools.org" target="_blank" class="">Proj@lists.maptools.org</a><br class="">
<a href="http://lists.maptools.org/mailman/listinfo/proj" rel="noreferrer" target="_blank" class="">http://lists.maptools.org/mailman/listinfo/proj</a></blockquote>
</div>
_______________________________________________<br class="">
Proj mailing list<br class="">
<a href="mailto:Proj@lists.maptools.org" target="_blank" class="">Proj@lists.maptools.org</a><br class="">
<a href="http://lists.maptools.org/mailman/listinfo/proj" target="_blank" class="">http://lists.maptools.org/mailman/listinfo/proj</a></div>
</blockquote>
</div>
<br class="">
</div>
_______________________________________________<br class="">
Proj mailing list<br class="">
<a href="mailto:Proj@lists.maptools.org" target="_blank" class="">Proj@lists.maptools.org</a><br class="">
<a href="http://lists.maptools.org/mailman/listinfo/proj" rel="noreferrer" target="_blank" class="">http://lists.maptools.org/mailman/listinfo/proj</a></blockquote>
</div>
_______________________________________________<br class="">
Proj mailing list<br class="">
<a href="mailto:Proj@lists.maptools.org" class="">Proj@lists.maptools.org</a><br class="">
http://lists.maptools.org/mailman/listinfo/proj</div>
</blockquote>
</div>
<br class="">
</body>
</html>