Using Netcdf format Files in Arcgis




Yüklə 22.53 Kb.
tarix28.02.2016
ölçüsü22.53 Kb.
Using NetCDF Format Files in ArcGIS
January 25, 2010

Bongghi Hong and Dennis Swaney


NetCDF (Network Common Data Form) is a very common format for storing and exchanging spatial and spatiotemporal datasets. More information can be found at the UNIDATA NetCDF website and the Wikipedia entry on NetCDF. This document describes how to import and open such datasets for analysis within ArcGIS. As an example, we will import a global N deposition map (Lamarque et al., in preparation) into ArcGIS and use it to estimate N deposition for the areas of our interest. Besides importing the NetCDF files into ArcGIS, some useful tips are described in the document, including:

First, we locate the NetCDF format file of our interest (“1990sndep.nc” stored in the “F:\Deposition\Global” folder in this example):



Exploring NetCDF files
The first thing we want to know is the list of variables and their units. There are a number of ways we can get this information. The simplest “quick-and-dirty” method is to open the file with any text editor. Most of its contents are unreadable, but the variable names and units can be found at the start of the file. Another way is to use scripts reading the header of the NetCDF file. One example of such a script is the MATLAB script “netcdf.m” (NetCDF Reader) that is available for download at http://www.mathworks.com/matlabcentral/fileexchange/15177:

To use this script, download the script “netcdf.m” to the same folder where the NetCDF file “1990sndep.nc” is stored (“F:\Deposition\Global” in this example), open the MATLAB, navigate to the folder, and type “S = netcdf (‘1990sndep.nc’,‘Var’,[]);” to read the header of the NetCDF file into the MATLAB variable “S” (a full description of the script can be found at the same website). After reading the header, type “S.VarArray.Str” to see the list of the variables contained in the NetCDF file:

The first two variables “NDEP_year” and “NDEP_AER_year” are the variables of our interest. Their descriptions can be found by typing “S.VarArray(1,1).AttArray(1,1)” (first variable) and “S.VarArray(1,2).AttArray(1,1)” (second variable). Their units can be found by typing “S.VarArray(1,1).AttArray(1,2)” (first variable) and “S.VarArray(1,2).AttArray(1,2)” (second variable):



Thus, we find that the first variable “NDEP_year” is the NOy deposition with the unit of “kg(N)/s” and the second variable “NDEP_AER_year” is the NHx deposition with the same unit. With this information, we will now import the NetCDF file into ArcGIS.

The ArcGIS Multidimension Tools
An element of the ArcGIS toolbox, the multidimension tool, can be used to import files in the NetCDF format. First, one needs to determine that it is on the list of available toolbox items. If not, it can be added as follows: Right click the ArcToolbox window -> select “Add Toolbox” -> navigate to “C:\Program Files\ArcGIS\ArcToolbox\Toolboxes” (or wherever the ArcGIS\ArcToolbox folder resides), then select "Multidimension Tools".

The multidimension tool “Make NetCDF Raster Layer” can be used to convert the “.nc” file to ArcGIS raster. Select this menu item.

Selecting the “Make NetCDF Raster Layer” brings up the popup menu. Go to “Input netCDF file” and navigate to the folder containing the desired “.nc” file (“F:\Deposition\Global” in this example).

When the file has been specified, X and Y dimensions as well as output raster layer and various other options can be chosen (if multivariate data are included, the first variable is chosen automatically).

When all desired options are selected, hit ok (in this example, the “Output Raster Layer” is specified as “NDEP_Layer” as shown above). Another popup appears while the procedure to create the raster file is executed. If it runs successfully, it reports “Completed”. Close the popup.

The raster map now appears along with the scale for the raster:

The rest of this document describes how we can use this map to estimate the N deposition of an area from a polygon shapefile of such an area. As an example, we estimate NOy and NHx depositions of several estuarine systems around the world:

Converting raster files to polygon shapefiles
As a first step, we will export the raster layer “NDEP_Layer” (imported from “.nc” file) as ArcGIS GRID format for further processing. Doubling-clicking the raster layer name “NDEP_Layer” will open its property window. Clicking on the “NetCDF” tab will show the current variable displayed as a map (“NDEP_year”, which is the NOy deposition as indicated by the MATLAB script described above):

Click “OK” to close the property window. Right-click “NDEP_Layer” and select “Data” and then “Export Data...” to open the “Export Raster Data” window. Specify the format as “GRID” and the output name as “noy_unp” (indicating the unprojected map of NOy deposition...a “unprojected” map has longitude and latitude values as X and Y dimensions, respectively):


The NOy deposition raster is now saved as ArcGIS GRID:

Now, create the NHx deposition map as ArcGIS GRID by: (1) opening the property window of “NDEP_Layer”, (2) Specifying the variable as “NDEP_AER_year”, and (3) opening the “Export Raster Data” window and saving the map as “nhx_unp”:

Now, we want to convert these raster maps into polygon shapefiles so that we can overlay them onto the map of our interest (estuarine shapefiles in this example) and calculate the area-weighted average of N deposition rates. Converting raster to polygon is problematic in ArcGIS unless the raster map contains integer values. The following approach is one way of making such a conversion (a simpler method may exist).



First, remove projections from the copies of the raster maps (e.g., “noy_nop” representing no projection) by opening the “Define Projection” tool from the ArcToolbox, and selecting “Unknown” as the coordinate system. (Removing projections makes the conversion process less prone to error. We will assign back the proper projection after the conversion):

Open the “Raster Calculator” from the Spatial Analyst and type the following: Int ( [noy_nop] * 0 + ($$RowMap Mod 3) * 3 + ($$ColMap Mod 3) )

This command will create a series of 3 by 3 “checker boards” that ensures that any neighboring cell will not have the same value (if there are neighboring cells with the same value, they will be combined into a single polygon, which is not desirable for our purpose). Hit “Evaluate”:

This integer raster (saved as “dep_grd”), with the same number and location of cells as the deposition grid, can be converted into the polygon. Select “Convert > Raster to Features...” from the Spatial Analyst and “Raster to Features” window will open. Make selections as shown below (uncheck “Generalize Lines”):

Hit “OK” and the output polygon grid will be created:

Of course, this grid does not contain the N deposition values, which need to be extracted from the NOy and NHx deposition raster maps. To do this, we first need to convert the polygon grid into the point shapefile. Open the “Feature to Point” tool from the ArcToolbox and specify as shown below:

Hit “OK” and a point will be created within each grid cell of the polygon shapefile:

Now, use the “Extract Values to Points” tool from the ArcToolbox to extract the NOy deposition (stored in “noy_nop” raster) to the point shapefile “dep_point_noy”:

Hit “OK” and the raster values are extracted to the “RASTERVALU” column:

In the same way, extract the NHx deposition from the raster map to the point shapefile “dep_point_nhx”. Now we need to transfer these extracted values to the polygon grid shapefile. This can be done by joining the attribute table of the polygon map to that of the point shapefiles. For example, to transfer the extracted NOy deposition values, right-click on the grid polygon name “dep_polygon” and select “Joins and Relates > Join...” and specify as shown below (the unique identification field “ID” used for joining had been automatically created by the “Raster to Features” tool described above):

Hit “OK” and export the joined polygon shapefile as “dep_polygon_noy”. Now the polygon map contains the NOy deposition:

It’s almost done, but there are a few more things until completion. First, join the NHx deposition in the same way as described above, and change the projection of the polygon map from “Unknown” to the original coordinate system by importing the coordinate system of the raster map “noy_unp”:

Then, this “unprojected” map (with latitude-longitude values) should be projected using a proper equal-area projection because we need to calculate area-weighted averages of N deposition rates. Considering that we are dealing with a global scale map (as opposed to, for example, a US map), the “Behrmann” projection would be appropriate (in the “Project” tool of the ArcToolbox, select “Behrmann (world).prj” from the “Projected Coordinate Systems\World” list):

The values shown on the above map have the unit of “kg(N)/s” (amount of nitrogen deposited per grid cell per second) as read by the MATLAB script (see above). To calculate the area-weighted averages, these map values should be changed to area-based rates such as “kg-N/km2/yr”. Thus, the area of each polygon cell (in km2) is calculated, and each polygon value is divided by its area and multiplied by “60*60*24*365” to change it to annual rate:


A detailed description on making field calculations, including the area calculation, is described in the “12_Calculating_Centroid_Position_Area_and_Perimeter.doc” available on the same webpage where this document is provided. As a final step, the “Polygon In Polygon Analysis” tool from the Hawth’s Analysis Tools is run to calculate the area-weighted averages of N deposition rates:

A detailed description on the Polygon In Polygon Analysis tool and the Hawth’s Analysis Tools is given in the “10_Calculating_Area_Weighted_Means.doc” available on the same webpage where this document is provided. As an example, below map shows the estimated NOy deposition in kg-N/km2/yr for the estuarine systems around the world:



Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.azrefs.org 2016
rəhbərliyinə müraciət

    Ana səhifə