I have a NetCDF file which is 25 by 20 grids by latitude and longitude and contains hourly rainfall data at each grid. In total I have 780 hours worth of data. I was trying to use ArcGIS to create a raster, but I could only get one hour at a time. Is there a way to convert it to another file type or to a raster with all the hours so I can easily use it in my database?
-
Do you want one raster per hour or a statistical summary like mean, sum, ...? – MrXsquared Jan 26 '20 at 23:55
-
@MrXsquared I want to be able to query at a lat/lon and time so raster per hour – I. Jones Jan 27 '20 at 00:37
-
1NetCDF to postgresql https://stackoverflow.com/questions/16016545/load-postgresql-database-with-data-from-a-netcdf-file – Mapperz Jan 27 '20 at 04:14
1 Answers
You may use ArcGIS to convert your netcdf file into geotiff files. You've stated that you are able to get one hour at a time. You'll need to just automate your approach using Arcpy (Python). ArcGIS already has Multidimension Tools Toolset to deal with NetCDF data. You can use Make NetCDF Raster Layer tool. There may be 2 approaches to do the task.
Approach-1
Use Make NetCDF Raster Layer tool such that
Input netCDF File = your nc file
Variable = prate (or whatever variable is there to depict precipitation)
X Dimension = lon
Y Dimension = lat
Output Raster Layer = Your defined output name
Band Dimension = time
Leave Dimension Values blank. It will generate a single raster layer with 780 bands (assuming you have a single nc file having 780 hours of data). You may export this raster layer into geotiff file or simply use it as it is.
Loop through each band of this output raster layer and extract each band. For this, you may look into this link.
You'll just have to name your output files to depict exact timestamp of each band. If you are familiar with python, it should be no issue.
Approach-2
You may access the above mentioned tool using arcpy from the start as follows
arcpy.MakeNetCDFRasterLayer_md(inputfilepath, "prate", "lon", "lat", "temporaryraster", "", dimension_value, "BY_VALUE")
dimension_value here is a list that is generated from netcdffile.getDimensionValue(dimension_type, dateband)
You may loop through each value of dimension_value and use it in above script line to make raster layer for each band from the start.
- 156
- 9