Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7943601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:19:02+00:00 2026-06-04T00:19:02+00:00

I am trying to create a multi-dimensional NetCDF file using the R package ncdf

  • 0

I am trying to create a multi-dimensional NetCDF file using the R package ncdf. I am working with climatic daily observations for a set of 1500 points, the number of observations is ~ 18250 for each point.
The problem is that the structure of the NetCDF file (create.ncdf) occupies 4Gb and each point makes the size of the file increase by more than 3 Gb (put.var.ncdf)

This is the code I am using:

# Make a few dimensions we can use
dimX <- dim.def.ncdf( "Long", "degrees", Longvector )
dimY <- dim.def.ncdf( "LAT", "degrees", Latvector )
dimT <- dim.def.ncdf( "Time", "days", 1:18250, unlim=FALSE )

# Make varables of various dimensionality, for illustration purposes
mv <- -9999 # missing value to use
var1d <- var.def.ncdf( "var1d", "units", dimX, mv,prec="double" )
var2d <- var.def.ncdf( "var2d", "units", list(dimX,dimY), mv,prec="double" )
var3d <- var.def.ncdf( "var3d", "units", list(dimX,dimY,dimT), mv,prec="double" )

# Create the test file
nc <- create.ncdf( "writevals.nc", list(var1d,var2d,var3d) )
# !!Creates a nc file with + 4 Gb

# Adding the complete time series for one point (the first point in the list of the dataset)
put.var.ncdf( nc, var3d,dataset[[1]], start=c(Longvector[1],Latvector[1],1),         count=c(1,1,-1))

Longvector and Latvector are vectors taken from the matrix with the Long and Lat for each point. The dataset is a list format and for each point I have a list of numeric values.

dataset[[1]]=c(0,0,0,9.7,0,7.5,3.6,2.9,0,0.5,....) 

Am I missing something or should I try other packages??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:19:03+00:00Added an answer on June 4, 2026 at 12:19 am

    There are some errors in your non-reproducible code, and by my reckoning the file is 219Mb (1500 * 18250 * 8 bytes).

    library(ncdf)
    

    Provide the vectors for the first two dims and the dataset to match at least one slice

    Longvector = seq(-180, 180, length = 50)
    Latvector = seq(-90, 90, length = 30)
    dataset <- list(1:18250)
    
    dimX <- dim.def.ncdf("Long", "degrees", Longvector)
    dimY <- dim.def.ncdf("LAT", "degrees", Latvector)
    dimT <- dim.def.ncdf("Time", "days", 1:18250, unlim = FALSE)
    
    mv <- -9999 
    var1d <- var.def.ncdf( "var1d", "units", dimX, mv,prec="double")
    var2d <- var.def.ncdf( "var2d", "units", list(dimX,dimY), mv,prec="double")
    var3d <- var.def.ncdf( "var3d", "units", list(dimX,dimY,dimT), mv,prec="double")
    
    nc <- create.ncdf( "writevals.nc", list(var1d,var2d,var3d))
    

    Count is the index of the dimension, not the axis position value, so we correct start to 1, and use the count (length) of the 3rd dimension (not -1).

    put.var.ncdf(nc, var3d, dataset[[1]], start = c(1, 1, 1),  count = c(1, 1, length(dataset[[1]])))
    
    close.ncdf(nc)
    

    Interrogate the file size.

    file.info("writevals.nc")$size/1e6
    [1] 219.0866
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a multi dimensional array using this syntax: $x[1] =
I am trying to create a multi dimensional array using $whole_array=array($case_id1,$case_name1,$case_status1); (these are variables
I am trying to create a multi-dimensional array whose parts are determined by a
I am trying to comprehend how I can create multi-dimensional NSMutable arrays in general.
I am trying to create a multi project template. I wish the sub projects
I am trying to create a multi level navigation menu with css. I guess
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Ok so I am trying create a login script, here I am using PHP5
Trying to create a multi module maven project in eclipse. Parent Pom.xml <project xmlns=http://maven.apache.org/POM/4.0.0
I'm trying to create a magnifier app in .NET using the Windows Magnification API

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.