Create a netCDF Dataset with Python (netCDF4)

Поділитися
Вставка
  • Опубліковано 9 лис 2024
  • Demonstration of how to create a netCDF file from scratch with Python using the netCDF package. This tutorial covers how to create a new netCDF file, assign dimensions, create variables, and add data to variables. The new file is viewed in QGIS.
    Visit opensourceoptions.com for more content and courses

КОМЕНТАРІ • 21

  • @yadongji1222
    @yadongji1222 4 роки тому +4

    Thank you very much for this turtorial!Hope you can continue to teach us how to deal with netCDF file~

  • @abegreene135
    @abegreene135 2 роки тому +2

    Really great series, thank you. I was dealing with very similar data but for Australian rainfall. A video suggestion would be converting NC files to tabular data which is what I have to tackle next. Yes and having the script available would be very handy.

  • @keeganjohnson1724
    @keeganjohnson1724 4 роки тому +3

    Thanks for the great video! These are super helpful. I'm currently working with a few NetCDF precipitation files in PyCharm. I've converted them to numpy arrays to perform some calculations. My end product is a 2D numpy array for one timeframe that displays the average precip for a 30-year timeframe. I was wondering what your recommendation would be to convert this array to a raster and plot in PyCharm?

    • @geospatialschool
      @geospatialschool  4 роки тому

      If it's already a 2D numpy array you can plot it using matplotlib. If you want it in raster format you could write it to a new netCDF, or use gdal to write it to a tif (or other format file).

    • @keeganjohnson1724
      @keeganjohnson1724 4 роки тому +1

      @@geospatialschool Thank you, matplotlib worked great. Keep up these videos, super helpful

  • @gambu4810
    @gambu4810 2 роки тому

    Great!! I'm proud of you bra!

  • @nguyentoan9012
    @nguyentoan9012 4 роки тому +2

    Thank you so much for great video.

  • @indrakumarrachalaishram7636

    very nice presentation sir, i want to know a couple of things. i have numpy arrays of time, precip, lat and lon from a netcdf i was working on. i want my new .nc files to have these dimensions and values, what do i do it? also how do i insert a coordinate system to the file? thanks again

  • @manasranjanpanda9859
    @manasranjanpanda9859 4 роки тому +1

    Thank you.. this is so helpful for me, but can you please tell how can I write my numpy array to this netcdf file? I have a numpy arrray (global population data of 0.5 by 0.5 degree) for a single year and I want to convert it into netcdf. Thank you in advance..

  • @viankcorhenrycashpacarrion6415
    @viankcorhenrycashpacarrion6415 2 роки тому

    Excellent video. Please ask How can I create netcdf files but with lat and lon in 2D?
    Reference: WRF atmospheric model files are .nc with lat and lon in 2D.

  • @JavierOsorno
    @JavierOsorno 2 роки тому

    Excellent tutorial, however there is a critical part that does not work for me: the georeferencing of the image. in the youtube video, when you add the layer to an existing qgis project, it shows over the sea (14:50). To correct this, you open a new project, add the layer and magically it appears correctly georeferenced. The layer already has the proper origin and pixel size. I couldn't replicate this with qgis 3.22.3. The data keeps coming out over the ocean. Source and resolution not corrected. Any suggestions on how to fix this problem? thanks for sharing your knowledge :)

  • @mohamednajar8017
    @mohamednajar8017 4 роки тому

    thank you, Its a super helpful video, I have a precipitation Raster for each day, I need to feed these rasters to the NetCDF I created as each raster will represent a time step starts from a specific day (let's say 01-01-1970). Any recommendation

    • @geospatialschool
      @geospatialschool  4 роки тому

      You can create a netcdf with the netcdf4 package, then read in the rasters as numpy arrays with gdal and write the numpy arrays to the netcdf

  • @Anfieldsss
    @Anfieldsss 2 роки тому

    How do you modify global attributes and add a variable in the metadata of a netCDF?

  • @thasweerah
    @thasweerah 4 роки тому

    what if i want to create netcdf file for observed climate station of my country.

  • @fcraft97
    @fcraft97 3 роки тому

    thank you for the video.
    Maybe you can help me: I have a netcdf file with 8 timesteps which are spread over 1month. I want to fill all the dates without data (31-8=23dates) with a "nan"-array so at the end the timesteps are on a daily basis.
    I am trying in the style of "value[8, :, :] = np.random.uniform(0,100, size=(144,73))". (So this is supposed to add a new timestep and fill it with random numbers.) My problem I get an "RuntimeError: NetCDF: HDF error" which I could not find the solution for.
    Any help or idea is highly appreciated :)

    • @fcraft97
      @fcraft97 3 роки тому

      I want to add to this file new timesteps (changig the value for the existing values would also work as I can interpolate the time with cdo and then change the timesteps to nan):
      dimensions(sizes): time(8), lon(144), lat(73), plev(1)
      variables(dimensions): float64 time(time), float64 lon(lon), float64 lat(lat), float64 plev(plev), float32 gh(time, plev, lat, lon)

  • @wind5221
    @wind5221 4 роки тому

    I have used the following link to import and convert time-series csv file to a netCDF file:
    stackoverflow.com/questions/56293164/convert-time-series-data-from-csv-to-netcdf-python?noredirect=1&lq=1
    But I am getting an error in the last line:
    ValueError: could not convert string to float: '1973-09-30'
    What's the issue with the code, or my datasets?
    Thank you

  • @inasolihati3459
    @inasolihati3459 3 роки тому

    I want your script. Please send me🙏

  • @SilabatEshetie
    @SilabatEshetie Рік тому

    Could you put your email please?

    • @geospatialschool
      @geospatialschool  Рік тому

      There's contact information on my website if you need to get in touch with me.