Inputing NetCDF variables into arcpy script

2249
2
Jump to solution
02-06-2013 11:36 AM
AnnaLabetski1
New Contributor
Hi all,

I'm working with NetCDF data that it organized by month, I only need a certain portion, within the range I specified I am converting their date format to the ArcMap recognized date and time format with this:

 element = num2date(item, units='days since 1850-1-1', calendar='365_day') 


I am then trying to imput this element which changes with every loop, into the following script:

 arcpy.MakeNetCDFFeatureLayer_md(apcp_2100_nc, "prveg", "lon", "lat", apcp_Layer, "lon;lat", "#", "#", ("time", str(element)), "BY_VALUE") 


This is running but the output is only the first element of the NetCDF layer which is the default setting in ArcGIS.

I am thinking that I am not inputing the dimension_values in correctly which is the ("time", str(element)).

Any ideas? Let me know if you need to see any more of my code to understand better.

Thanks!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
markdenil
Occasional Contributor III
Since your element variable is part of the dimension that seems to not be working, perhaps knowing what num2date is doing might help.

do you get the same output using only time as a dimension, instead of time and element?
As I recall, the help for the multidimension tools is not always quite right,
but should the dimensions be in a list, instead of a tuple?

The 9.3 geoprocessor needed the dimensions in a semi-colon delimited string....

View solution in original post

0 Kudos
2 Replies
markdenil
Occasional Contributor III
Since your element variable is part of the dimension that seems to not be working, perhaps knowing what num2date is doing might help.

do you get the same output using only time as a dimension, instead of time and element?
As I recall, the help for the multidimension tools is not always quite right,
but should the dimensions be in a list, instead of a tuple?

The 9.3 geoprocessor needed the dimensions in a semi-colon delimited string....
0 Kudos
AnnaLabetski1
New Contributor
Hi Mark,

Thanks! It was the tuple issue, I tried lists before but it didn't work, turns out that it has to be a list of lists even if there's only one variable, this is actually quite obvious but I guess I just wasn't thinking. Yeah, the help for this function also organized it as a dictionary which didn't work at all, so I think that threw me off. Using only time gave the same output and it would not accept semi-colons which was really frusterating.

If you're curious, num2date is a built in function with the NetCDF add on to python, it converts the stored numbers (such as 9567.5) to a date such as 04-12-2100 12:00:00 which is the necessary input for the arcgis tool.

Good luck to anyone else working with NetCDF data

Cheers!
0 Kudos