Can not display netCDF using ArcGIS pro jupyter notebook

491
1
10-02-2019 07:51 AM
LeiZhou2
New Contributor

I read netCDF file using ArcGIS pro Jupyter notebook. But I can not display it on ESRI basemap. Who can help me to solve this problem? The code is as follows:

from arcgis.gis import GIS
arcgis_online = GIS()
subset_map = arcgis_online.map("USA")
subset_map

import arcpy
arcpy.env.workspace = "C:/Users/leizhou-admin/Downloads/Hist"
in_netcdf = "**/tasmax_day_ACCESS1-0_historical_r1i1p1_20050101-20051231.LOCA_2016-04-02.16th.nc"

variable = "tasmax"
XDimension = "lon"
YDimension = "lat"
outRasterLayer = "tmax28.lyr"
bandDimmension = "time"
dimensionValue = "5/19/2005 12:00:00 PM"
valueSelectionMethod = "BY_VALUE"
cellRegistration = ""


# Execute MakeNetCDFRasterLayer
tmax_layer = arcpy.MakeNetCDFRasterLayer_md(in_netcdf, variable, XDimension, YDimension,
outRasterLayer, bandDimmension, dimensionValue,
valueSelectionMethod, cellRegistration)
arcpy.SaveToLayerFile_management(outRasterLayer, "tamx.lyr", "ABSOLUTE")
subset_map.add_layer("tamx.lyr")
subset_map

The error information is :

---------------------------------------------------------------------------RuntimeError                              Traceback (most recent call last)<ipython-input-10-e90e6e86e606> in <module>     14                                valueSelectionMethod, cellRegistration)     15 arcpy.SaveToLayerFile_management(outRasterLayer, "tamx.lyr", "ABSOLUTE")---> 16 subset_map.add_layer("tamx.lyr")     17 subset_map C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\widgets\_mapview.py in add_layer(self, item, options)    722         if options is None:    723             options = {}--> 724         self._add_layer_to_widget(item, options)    725     726     def _add_layer_to_webmap(self, item, options):C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\widgets\_mapview.py in _add_layer_to_widget(self, item, options)    779                     self._add_layer_to_widget(item_, options)    780         else:--> 781             raise RuntimeError("Cannot infer layer: will not be added to map")    782     783     def _add_notype_layer(self, item, lyr_json):RuntimeError: Cannot infer layer: will not be added to map
0 Kudos
1 Reply
LeiZhou2
New Contributor

Does anyone face this problem?

0 Kudos