AnsweredAssumed Answered

Add OPeNDAP raster layer to mapframe in arcpy

Question asked by jsamson88 on Sep 12, 2019

I am trying to add a opendap raster to an existing .aprx project using arcpy but am unable to do so:

Creating the layer is achieved successfully but I seem unable to add to the map frame...


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...


import arcpy

aprx ="pathto\TestTemplate.aprx")

mapFrames = aprx.listMaps()

url = ''

m = mapFrames[0]
vari = 'tg_mean_p50'
opendap =, vari, "lon", "lat", f"{vari}_Layer",
                                                 "-140.958333335 41.041666665 -52.041670225 83.458331635",
                                                 "time '0' '12'", "BY_INDEX",cell_registration='CENTER')
m.addLayer(opendap) #f"{vari}_Layer")


Gives error:


Traceback (most recent call last):
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\IPython\core\", line 3296, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-79cc189255aa>", line 14, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\", line 191, in fn_
return fn(*args, **kw)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\", line 1403, in addLayer
return convertArcObjectToPythonObject(self._arc_object.addLayer(*gp_fixargs((add_layer_or_layerfile, add_position), True)))
ValueError: tg_mean_p50_Layer