Thursday, April 17, 2014

NetCDF in CityEngine


What is NetCDF?


If you are like me and completely lost to the meaning of NetCDF when you first heard of it, the following internet descriptions might help...

"NetCDF (Network Common Data Form) is a set of software libraries and self-describing, machine- independent data formats that support the creation, access, and sharing of array-oriented scientific data." -Wikipedia

Still not sure? NetCDF and ArcGIS:

"ArcGIS versions after 9.2 support NetCDF files that follow the Climate and Forecast Metadata Conventions and contain rectilinear grids with equally-spaced coordinates. The Multidimensional Tools toolbox can be used to create raster layers, feature layers, and table views from NetCDF data in ArcMap, or convert feature, raster, and table data to NetCDF." - Also Wikipedia

The fundamentals of NetCDF are explained here.

For the purpose of this blog post a NetCDF file stores multidimensional data in a grid format. The focus of this example converted the NetCDF files to point features using ArcGIS GP tools.

2D points to 3D points


After converting the NetCDF files to point features, the resulting dataset was a points feature class which had numerous points in a grid format. The points represent wind conditions over time. The attributes included X and Y -coordinats; elevation; time; windspeed; and wind angle.

Using the elevation attribute and the Feature to 3D by attribute tool, the points were converted to 3D enabled points with Z values.


2D Point Features
3D Point Features



Using the data in CityEngine


The Z-enabled point features were exported to individual feature classes per date stamp. This was done in order to add the feature classes as seperate layers in CityEngine.

A simple rule file was created to assign a 3D arrow object to each point. The CGA rule then angles the cone according to the windangle attribute; colors the cone on a greenToRed color ramp basis in according to the windspeed attribute.

The code:


attr windangle = 0
attr windspeed = 0
attr maxwindspeed = 6.75
attr windcolor = windspeed/maxwindspeed

Lot --> i("Arrow/Arrow_object.obj")
color(colorRamp ("greenToRed", windcolor))
s(200, 400, 200)
r(270,windangle,0) 
center(xz)

CGA Wind Rule applied in CityEngine


The Result


The result is a 3D web viewer where you can compare wind data (showing speed and direction) in a grid format, as it changes over time.