<?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: Creating custom projected coordinate systems using ArcPy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726165#M56290</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for all of the useful comments, and my original script is getting quite long and complicated which is why I just cut out the bit relating to creating the SpatialReference. Now that I have had a go using&amp;nbsp;the String representation it looks like Melita is right that my definition was incomplete&amp;nbsp;and using the wrong properties for that projection, but in any case the string method&amp;nbsp;appears to be&amp;nbsp;the best way to go. I have successfully run my script by copying the string from a PRJ file of an Orthographic projection&amp;nbsp;saved from ArcMap, and now just need to turn it into the template suggested by Neil to read the centroid lat/long from my input polygons.&lt;/P&gt;&lt;P&gt;I think an example in the ArcGIS Help pages for creating custom projected coordinate systems in ArcPy&amp;nbsp;would still be really useful though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Jan 2017 12:54:30 GMT</pubDate>
    <dc:creator>PaulGosling1</dc:creator>
    <dc:date>2017-01-10T12:54:30Z</dc:date>
    <item>
      <title>Creating custom projected coordinate systems using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726160#M56285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to&amp;nbsp;write&amp;nbsp;an ArcPy script which&amp;nbsp;takes a user input feature class polygon and creates a custom version of a projected coordinate system based on the Orthographic projection (which has the WKID 43041) and the centroid of the polygon. All of the help pages are based on creating spatial references which are already defined Projected Coordinate Systems, but none which show how to create a new custom PCS.&lt;/P&gt;&lt;P&gt;I have tried various versions of creating an instance of the SpatialReference class, setting properties then using the create method, such as&amp;nbsp;the following snippet of my code&amp;nbsp;but I keep getting the 'Error executing function' message below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/298578_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Runtime error&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\arcobjects\arcobjects.py", line 1226, in create&lt;/P&gt;&lt;P&gt;return convertArcObjectToPythonObject(self._arc_object.Create(*gp_fixargs(args)))&lt;/P&gt;&lt;P&gt;RuntimeError: ERROR 999999: Error executing function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is something which I find straightforward using the Data Frame Coordinate Reference System properties&amp;nbsp;in ArcMap but is proving beyond me using ArcPy, so any assistance or examples of the correct code to define a custom projection gratefully received.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jan 2017 21:01:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726160#M56285</guid>
      <dc:creator>PaulGosling1</dc:creator>
      <dc:date>2017-01-09T21:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom projected coordinate systems using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726161#M56286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try also setting:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PCSName&lt;/P&gt;&lt;P&gt;GCS (perhaps by the GCSCode instead, 4326 for WGS84, 4269 for NAD83)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There also might be a problem with the parameters. Orthographic uses Lon/Lat of Center and parameters exposed here might not be converting to the correct ones internally. So if you do get a valid SR, make sure the results make sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Melita&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jan 2017 21:26:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726161#M56286</guid>
      <dc:creator>MelitaKennedy</dc:creator>
      <dc:date>2017-01-09T21:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom projected coordinate systems using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726162#M56287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;is there some code missing? like the import arcpy line and the line where you define the input_fc? &amp;nbsp;because the script fails at line 1, and doesn't have to do with anything else by all appearances. &amp;nbsp;If you have the rest of the code, please update your intial post with the full code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2017 03:16:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726162#M56287</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-01-10T03:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom projected coordinate systems using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726163#M56288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have done this in the past by using a "template" string. You can copy this from your known, existing projection.&lt;/P&gt;&lt;P&gt;Then use the string formatting in python to modify the parameters to what you want.&lt;/P&gt;&lt;P&gt;A bit like this :&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;prjTemplate &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'PROJCS["My_local_projection",GEOGCS["GCS_Cape",DATUM["D_Cape",SPHEROID["Clarke_1880_Arc",6378249.145,293.466307656]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Local"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Scale_Factor",{0}],PARAMETER["Azimuth",{1}],PARAMETER["Longitude_Of_Center",16.661764589799],PARAMETER["Latitude_Of_Center",-28.407083714978],UNIT["Meter",1.0]]'&lt;/SPAN&gt;

srLocalString &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; prjTemplate&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;40.0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# set new parameters here, see placeholders in prjTemplate&lt;/SPAN&gt;
srLocal &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SpatialReference&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
srLocal&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;loadFromString&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;srLocalString&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:03:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726163#M56288</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2021-12-12T07:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom projected coordinate systems using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726164#M56289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But I see this for wkid 43041&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; sr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SpatialReference&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;43041&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
Traceback &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;most recent call last&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp; File &lt;SPAN class="string token"&gt;"&amp;lt;interactive input&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt;module&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;
&amp;nbsp; File &lt;SPAN class="string token"&gt;"C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\arcobjects\mixins.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;962&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; __init__
&amp;nbsp;&amp;nbsp;&amp;nbsp; self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;_arc_object&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;createFromFile&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;item&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
RuntimeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; ERROR &lt;SPAN class="number token"&gt;999999&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; Error executing function&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
the input &lt;SPAN class="keyword token"&gt;is&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; a geographic &lt;SPAN class="operator token"&gt;or&lt;/SPAN&gt; projected coordinate system
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&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;/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;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So, what sort of Orthographic projection are we talking about here?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:03:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726164#M56289</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2021-12-12T07:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom projected coordinate systems using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726165#M56290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for all of the useful comments, and my original script is getting quite long and complicated which is why I just cut out the bit relating to creating the SpatialReference. Now that I have had a go using&amp;nbsp;the String representation it looks like Melita is right that my definition was incomplete&amp;nbsp;and using the wrong properties for that projection, but in any case the string method&amp;nbsp;appears to be&amp;nbsp;the best way to go. I have successfully run my script by copying the string from a PRJ file of an Orthographic projection&amp;nbsp;saved from ArcMap, and now just need to turn it into the template suggested by Neil to read the centroid lat/long from my input polygons.&lt;/P&gt;&lt;P&gt;I think an example in the ArcGIS Help pages for creating custom projected coordinate systems in ArcPy&amp;nbsp;would still be really useful though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2017 12:54:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726165#M56290</guid>
      <dc:creator>PaulGosling1</dc:creator>
      <dc:date>2017-01-10T12:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom projected coordinate systems using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726166#M56291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just to answer your question Neil, Orthographic is a Projection Name and not a Projected Coordinate System so this error is understandable. PCS are built using a specific projection&amp;nbsp;and the other parameters required to define its use&amp;nbsp;for a particular part of the world. For example, UTM grid zones are based on the Transverse Mercator projection, which is WKID 43006 but in that case you would use the WKID for the UTM zone you want in the SpatialReference class.&lt;/P&gt;&lt;P&gt;Orthographic is an azimuthal perspective projection which has the effect of viewing the Earth from an infinite distance in space thereby making the map appear as a globe, not dissimilar to the perspective projection&amp;nbsp;used by Google Earth but in that case you can obviously alter the viewing&amp;nbsp;distance. Like a number of map projections Orthographic does not form the basis for any PCS and therefore it requires a custom version with user-defined central latitude and longitude.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2017 20:55:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726166#M56291</guid>
      <dc:creator>PaulGosling1</dc:creator>
      <dc:date>2017-01-10T20:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom projected coordinate systems using ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726167#M56292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I realise that wkid 43041 is a projection type rather than a fully formed PCS.&lt;/P&gt;&lt;P&gt;So, you need to set one up perhaps centred on the middle of your project area. If you save it in favourites, you can find the prj in userbanme/appdata etc etc.&lt;/P&gt;&lt;P&gt;Open that up with a text editor, then copy it into your python script. Becareful to surround the entire string with single quotes (all the internal ones are double quotes).&lt;/P&gt;&lt;P&gt;Then edit the string to put the formatting placeholders "{}" at the places you require.&lt;/P&gt;&lt;P&gt;Then you're good to go.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2017 06:47:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-custom-projected-coordinate-systems-using/m-p/726167#M56292</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2017-01-11T06:47:18Z</dc:date>
    </item>
  </channel>
</rss>

