<?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 Add OPeNDAP raster layer to mapframe in arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/add-opendap-raster-layer-to-mapframe-in-arcpy/m-p/484636#M37827</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to add a opendap raster to an existing .aprx project using arcpy but am unable to do so:&lt;/P&gt;&lt;P&gt;Creating the layer is achieved successfully but I seem unable to add to the map frame...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running the code in the python console adds the layer successfully to the active map frame ... Eventually I will want to loop through a large number of combinations of opendap files to create an atlas of maps etc so I need to be able to do this in a standalone script ... any help would be appreciated...&lt;/P&gt;&lt;P&gt;`&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;arcpy

aprx = arcpy.mp.ArcGISProject(&lt;SPAN style="color: #008080; font-weight: bold;"&gt;r"pathto\TestTemplate.aprx"&lt;/SPAN&gt;)

mapFrames = aprx.listMaps()

url = &lt;SPAN style="color: #008080; font-weight: bold;"&gt;'https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/cccs_portal/indices/Final/BCCAQv2/tg_mean/YS/rcp85/ensemble_percentiles/30yAvg_BCCAQv2+ANUSPLIN300_ensemble-percentiles_historical+rcp85_1950-2100_tg_mean_YS.nc'
&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;
&lt;/SPAN&gt;m = mapFrames[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]
vari = &lt;SPAN style="color: #008080; font-weight: bold;"&gt;'tg_mean_p50'
&lt;/SPAN&gt;opendap = arcpy.md.MakeOPeNDAPRasterLayer(url, vari, &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"lon"&lt;/SPAN&gt;, &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"lat"&lt;/SPAN&gt;, &lt;SPAN style="color: #008080; font-weight: bold;"&gt;f"&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;{&lt;/SPAN&gt;vari&lt;SPAN style="color: #000080; font-weight: bold;"&gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;_Layer"&lt;/SPAN&gt;,
                                                 &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"-140.958333335 41.041666665 -52.041670225 83.458331635"&lt;/SPAN&gt;,
                                                 &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"time '0' '12'"&lt;/SPAN&gt;, &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"BY_INDEX"&lt;/SPAN&gt;,&lt;SPAN style="color: #660099;"&gt;cell_registration&lt;/SPAN&gt;=&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'CENTER'&lt;/SPAN&gt;)
m.addLayer(opendap) &lt;SPAN style="color: #808080;"&gt;#f"{vari}_Layer")&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;`&lt;/P&gt;&lt;P&gt;Gives error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\IPython\core\interactiveshell.py", line 3296, in run_code&lt;BR /&gt; exec(code_obj, self.user_global_ns, self.user_ns)&lt;BR /&gt; File "&amp;lt;ipython-input-4-79cc189255aa&amp;gt;", line 14, in &amp;lt;module&amp;gt;&lt;BR /&gt; m.addLayer(opendap)&lt;BR /&gt; File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py", line 191, in fn_&lt;BR /&gt; return fn(*args, **kw)&lt;BR /&gt; File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 1403, in addLayer&lt;BR /&gt; return convertArcObjectToPythonObject(self._arc_object.addLayer(*gp_fixargs((add_layer_or_layerfile, add_position), True)))&lt;BR /&gt;ValueError: tg_mean_p50_Layer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 21:22:07 GMT</pubDate>
    <dc:creator>TravisLogan1</dc:creator>
    <dc:date>2021-12-11T21:22:07Z</dc:date>
    <item>
      <title>Add OPeNDAP raster layer to mapframe in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/add-opendap-raster-layer-to-mapframe-in-arcpy/m-p/484636#M37827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to add a opendap raster to an existing .aprx project using arcpy but am unable to do so:&lt;/P&gt;&lt;P&gt;Creating the layer is achieved successfully but I seem unable to add to the map frame...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running the code in the python console adds the layer successfully to the active map frame ... Eventually I will want to loop through a large number of combinations of opendap files to create an atlas of maps etc so I need to be able to do this in a standalone script ... any help would be appreciated...&lt;/P&gt;&lt;P&gt;`&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;arcpy

aprx = arcpy.mp.ArcGISProject(&lt;SPAN style="color: #008080; font-weight: bold;"&gt;r"pathto\TestTemplate.aprx"&lt;/SPAN&gt;)

mapFrames = aprx.listMaps()

url = &lt;SPAN style="color: #008080; font-weight: bold;"&gt;'https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/cccs_portal/indices/Final/BCCAQv2/tg_mean/YS/rcp85/ensemble_percentiles/30yAvg_BCCAQv2+ANUSPLIN300_ensemble-percentiles_historical+rcp85_1950-2100_tg_mean_YS.nc'
&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;
&lt;/SPAN&gt;m = mapFrames[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]
vari = &lt;SPAN style="color: #008080; font-weight: bold;"&gt;'tg_mean_p50'
&lt;/SPAN&gt;opendap = arcpy.md.MakeOPeNDAPRasterLayer(url, vari, &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"lon"&lt;/SPAN&gt;, &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"lat"&lt;/SPAN&gt;, &lt;SPAN style="color: #008080; font-weight: bold;"&gt;f"&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;{&lt;/SPAN&gt;vari&lt;SPAN style="color: #000080; font-weight: bold;"&gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-weight: bold;"&gt;_Layer"&lt;/SPAN&gt;,
                                                 &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"-140.958333335 41.041666665 -52.041670225 83.458331635"&lt;/SPAN&gt;,
                                                 &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"time '0' '12'"&lt;/SPAN&gt;, &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"BY_INDEX"&lt;/SPAN&gt;,&lt;SPAN style="color: #660099;"&gt;cell_registration&lt;/SPAN&gt;=&lt;SPAN style="color: #008080; font-weight: bold;"&gt;'CENTER'&lt;/SPAN&gt;)
m.addLayer(opendap) &lt;SPAN style="color: #808080;"&gt;#f"{vari}_Layer")&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;`&lt;/P&gt;&lt;P&gt;Gives error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\IPython\core\interactiveshell.py", line 3296, in run_code&lt;BR /&gt; exec(code_obj, self.user_global_ns, self.user_ns)&lt;BR /&gt; File "&amp;lt;ipython-input-4-79cc189255aa&amp;gt;", line 14, in &amp;lt;module&amp;gt;&lt;BR /&gt; m.addLayer(opendap)&lt;BR /&gt; File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py", line 191, in fn_&lt;BR /&gt; return fn(*args, **kw)&lt;BR /&gt; File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 1403, in addLayer&lt;BR /&gt; return convertArcObjectToPythonObject(self._arc_object.addLayer(*gp_fixargs((add_layer_or_layerfile, add_position), True)))&lt;BR /&gt;ValueError: tg_mean_p50_Layer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:22:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-opendap-raster-layer-to-mapframe-in-arcpy/m-p/484636#M37827</guid>
      <dc:creator>TravisLogan1</dc:creator>
      <dc:date>2021-12-11T21:22:07Z</dc:date>
    </item>
  </channel>
</rss>

