1

I am a beginner in using NetCDF files. I would like to transform several NetCDF into GeoTIFF but the Lat/Lon info is in variables and not as dimensional coordinates. I can't work with these files.

I have tried with GDAL but these files are not georeferenced correctly. The result from ncdump is below.

How can I do this?

netcdf C:/Users/USER/Desktop/net/01/MARC_B1-ECOMARS3D-MANGA4000_20220102T1200Z.nc {
  dimensions:
    ni = 245;
    nj = 266;
    ni_u = 245;
    nj_u = 266;
    ni_v = 245;
    nj_v = 266;
    ni_f = 245;
    nj_f = 266;
    time = UNLIMITED;   // (1 currently)
    level = 30;
  variables:
    float ni(ni=245);
      :long_name = "x-dimension of the grid";
      :standard_name = "x_grid_index";
      :c_grid_axis_shift = 0.0; // double
      :axis = "X";
      :c_grid_dynamic_range = "3:236";
      :_ChunkSizes = 245U; // uint

    float nj(nj=266);
      :long_name = "y-dimension of the grid";
      :standard_name = "y_grid_index";
      :axis = "Y";
      :c_grid_axis_shift = 0.0; // double
      :c_grid_dynamic_range = "3:265";
      :_ChunkSizes = 266U; // uint

    float ni_u(ni_u=245);
      :long_name = "x-dimension of the grid at u location";
      :standard_name = "x_grid_index_at_u_location";
      :c_grid_axis_shift = 0.5; // double
      :axis = "X";
      :c_grid_dynamic_range = "2:235";
      :_ChunkSizes = 245U; // uint

    float nj_u(nj_u=266);
      :long_name = "y-dimension of the grid at u location";
      :standard_name = "y_grid_index_at_u_location";
      :axis = "Y";
      :c_grid_axis_shift = 0.0; // double
      :c_grid_dynamic_range = "3:265";
      :_ChunkSizes = 266U; // uint

    float ni_v(ni_v=245);
      :long_name = "x-dimension of the grid at v location";
      :standard_name = "x_grid_index_at_v_location";
      :c_grid_axis_shift = 0.0; // double
      :axis = "X";
      :c_grid_dynamic_range = "3:236";
      :_ChunkSizes = 245U; // uint

    float nj_v(nj_v=266);
      :long_name = "y-dimension of the grid at v location";
      :standard_name = "y_grid_index_at_v_location";
      :axis = "Y";
      :c_grid_axis_shift = 0.5; // double
      :c_grid_dynamic_range = "3:265";
      :_ChunkSizes = 266U; // uint

    float ni_f(ni_f=245);
      :long_name = "x-dimension of the grid at f location";
      :standard_name = "x_grid_index_at_f_location";
      :c_grid_axis_shift = 0.5; // double
      :axis = "X";
      :c_grid_dynamic_range = "2:235";
      :_ChunkSizes = 245U; // uint

    float nj_f(nj_f=266);
      :long_name = "y-dimension of the grid at f location";
      :standard_name = "y_grid_index_at_f_location";
      :axis = "Y";
      :c_grid_axis_shift = 0.5; // double
      :c_grid_dynamic_range = "3:265";
      :_ChunkSizes = 266U; // uint

    double latitude(nj=266, ni=245);
      :long_name = "latitude";
      :standard_name = "latitude";
      :units = "degrees_north";
      :_FillValue = 1.7E38; // double
      :valid_min = -90.0; // double
      :valid_max = 90.0; // double
      :_ChunkSizes = 266U, 245U; // uint

    double longitude(nj=266, ni=245);
      :long_name = "longitude";
      :standard_name = "longitude";
      :units = "degrees_east";
      :_FillValue = 1.7E38; // double
      :valid_min = -180.0; // double
      :valid_max = 180.0; // double
      :_ChunkSizes = 266U, 245U; // uint

    double time(time=1);
      :long_name = "time in seconds (UT)";
      :standard_name = "time";
      :units = "seconds since 1900-01-01T00:00:00Z";
      :axis = "T";
      :time_origin = "01-JAN-1900 00:00:00";
      :conventions = "relative number of seconds with no decimal part";
      :_ChunkSizes = 512U; // uint

    float level(level=30);
      :long_name = "sigma level";
      :axis = "Z";
      :c_grid_axis_shift = 0.0; // double
      :positive = "up";
      :valid_min = -1.0f; // float
      :valid_max = 0.0f; // float
      :standard_name = "ocean_s_coordinate";
      :formula_terms = "s: level eta: XE depth: H0 a: theta b: b depth_c: hc";
      :formula_definition = "z(n,k,j,i) = eta(n,j,i)*(1+s(k)) + depth_c*s(k) + (depth(j,i)-depth_c)*C(k)";
      :_ChunkSizes = 30U; // uint

    double longitude_u(nj_u=266, ni_u=245);
      :long_name = "longitude at u location";
      :standard_name = "longitude_at_u_location";
      :units = "degrees_east";
      :valid_min = -8.07563352826511; // double
      :valid_max = 5.204288499025337; // double
      :_FillValue = 1.7E38; // double
      :_ChunkSizes = 266U, 245U; // uint

    double longitude_v(nj_v=266, ni_v=245);
      :long_name = "longitude at v location";
      :standard_name = "longitude_at_v_location";
      :units = "degrees_east";
      :valid_min = -8.07563352826511; // double
      :valid_max = 5.204288499025337; // double
      :_FillValue = 1.7E38; // double
      :_ChunkSizes = 266U, 245U; // uint

    double latitude_u(nj_u=266, ni_u=245);
      :long_name = "latitude at u location";
      :standard_name = "latitude_at_u_location";
      :units = "degrees_north";
      :valid_min = 43.131362467866325; // double
      :valid_max = 52.86863753213368; // double
      :_FillValue = 1.7E38; // double
      :_ChunkSizes = 266U, 245U; // uint

    double latitude_v(nj_v=266, ni_v=245);
      :long_name = "latitude at v location";
      :standard_name = "latitude_at_v_location";
      :units = "degrees_north";
      :valid_min = 43.131362467866325; // double
      :valid_max = 52.86863753213368; // double
      :_FillValue = 1.7E38; // double
      :_ChunkSizes = 266U, 245U; // uint

    float SIG(level=30);
      :long_name = "sigma variable";
      :standard_name = "ocean_s_variable";
      :units = ;
      :valid_min = -1.0f; // float
      :valid_max = 0.0f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 30U; // uint

    float Csu_sig(level=30);
      :long_name = "C(s) law at mid layer";
      :standard_name = "ocean_s_coordinate_function_at_midlayer";
      :units = ;
      :valid_min = -2.0f; // float
      :valid_max = 2.0f; // float
      :_FillValue = 999.0f; // float
      :formula_definition = "C(k) = (1-b)*sinh(a*s(k))/sinh(a) + b*[tanh(a*(s(k)+0.5))-tanh(0.5*a)]/(2*tanh(0.5*a))";
      :_ChunkSizes = 30U; // uint

    float hc(nj=266, ni=245);
      :long_name = "depth over which the resolution is increased";
      :standard_name = "ocean_s_coordinate_thick_of_surface_resolution";
      :units = "m";
      :coordinates = "latitude longitude";
      :valid_min = -20.0f; // float
      :valid_max = 500.0f; // float
      :_FillValue = -999.0f; // float
      :_ChunkSizes = 266U, 245U; // uint

    float b;
      :long_name = "bottom control parameter";
      :standard_name = "ocean_s_coordinate_bottom_control";
      :units = ;
      :valid_min = 0.0f; // float
      :valid_max = 1.0f; // float
      :_FillValue = 999.0f; // float

    float theta;
      :long_name = "surface control parameter";
      :standard_name = "ocean_s_coordinate_surface_control";
      :units = ;
      :valid_min = 0.0f; // float
      :valid_max = 20.0f; // float
      :_FillValue = 999.0f; // float

    float H0(nj=266, ni=245);
      :long_name = "bathymetry relative to the mean level";
      :standard_name = "model_sea_floor_depth_below_geoid";
      :units = "m";
      :coordinates = "latitude longitude";
      :valid_min = -50.0f; // float
      :valid_max = 10000.0f; // float
      :_FillValue = -999.0f; // float
      :_ChunkSizes = 266U, 245U; // uint

    float HX(nj_u=266, ni_u=245);
      :long_name = "bathymetry at u-location relative to the mean level";
      :standard_name = "model_sea_floor_depth_below_geoid_at_u_location";
      :units = "m";
      :coordinates = "latitude_u longitude_u";
      :valid_min = -50.0f; // float
      :valid_max = 10000.0f; // float
      :_FillValue = -999.01f; // float
      :_ChunkSizes = 266U, 245U; // uint

    float HY(nj_v=266, ni_v=245);
      :long_name = "bathymetry at v-location relative to the mean level";
      :standard_name = "model_sea_floor_depth_below_geoid_at_v_location";
      :units = "m";
      :coordinates = "latitude_v longitude_v";
      :valid_min = -50.0f; // float
      :valid_max = 10000.0f; // float
      :_FillValue = -999.01f; // float
      :_ChunkSizes = 266U, 245U; // uint

    float XE(time=1, nj=266, ni=245);
      :long_name = "sea surface height";
      :standard_name = "sea_surface_height_above_geoid";
      :units = "m";
      :coordinates = "latitude longitude";
      :valid_min = -50.0f; // float
      :valid_max = 50.0f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 266U, 245U; // uint

    float SAL(time=1, level=30, nj=266, ni=245);
      :long_name = "salinity";
      :standard_name = "sea_water_salinity";
      :units = "1e-3";
      :coordinates = "latitude longitude";
      :valid_min = -5.0f; // float
      :valid_max = 50.0f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float TEMP(time=1, level=30, nj=266, ni=245);
      :long_name = "temperature";
      :standard_name = "sea_water_potential_temperature";
      :units = "degrees_Celsius";
      :coordinates = "latitude longitude";
      :valid_min = -5.0f; // float
      :valid_max = 50.0f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float suspended_inorganic_particulate_matter(time=1, level=30, nj=266, ni=245);
      :long_name = "suspended_inorganic_particulate_matter";
      :standard_name = "mass_concentration_of_suspended_matter_in_sea_water";
      :units = "g.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float nanopicoplankton_nitrogen(time=1, level=30, nj=266, ni=245);
      :long_name = "nanopicoplankton_nitrogen";
      :standard_name = "mole_concentration_of_nanoplankton_expressed_as_nitrogen_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float diatom_nitrogen(time=1, level=30, nj=266, ni=245);
      :long_name = "diatom_nitrogen";
      :standard_name = "mole_concentration_of_diatoms_expressed_as_nitrogen_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float dinoflagellate_nitrogen(time=1, level=30, nj=266, ni=245);
      :long_name = "dinoflagellate_nitrogen";
      :standard_name = "mole_concentration_of_dinoflagellates_expressed_as_nitrogen_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float microzooplankton_nitrogen(time=1, level=30, nj=266, ni=245);
      :long_name = "microzooplankton_nitrogen";
      :standard_name = "mole_concentration_of_microzooplankton_expressed_as_nitrogen_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float mesozooplankton_nitrogen(time=1, level=30, nj=266, ni=245);
      :long_name = "mesozooplankton_nitrogen";
      :standard_name = "mole_concentration_of_mesozooplankton_expressed_as_nitrogen_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float karenia_carbon(time=1, level=30, nj=266, ni=245);
      :long_name = "karenia_carbon";
      :standard_name = "mole_concentration_of_karenia_expressed_as_carbon_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float karenia_nitrogen(time=1, level=30, nj=266, ni=245);
      :long_name = "karenia_nitrogen";
      :standard_name = "mole_concentration_of_karenia_expressed_as_nitrogen_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float karenia_phosphorus(time=1, level=30, nj=266, ni=245);
      :long_name = "karenia_phosphorus";
      :standard_name = "mole_concentration_of_karenia_expressed_as_phosphorus_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float pseudonitzschia_nitrogen(time=1, level=30, nj=266, ni=245);
      :long_name = "pseudonitzschia_nitrogen";
      :standard_name = "mole_concentration_of_pseudonitzschia_expressed_as_nitrogen_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float pseudonitzschia_silicon(time=1, level=30, nj=266, ni=245);
      :long_name = "pseudonitzschia_silicon";
      :standard_name = "mole_concentration_of_pseudonitzschia_expressed_as_silicon_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float domoic_acid(time=1, level=30, nj=266, ni=245);
      :long_name = "domoic_acid";
      :standard_name = "mass_concentration_of_domoic_acid_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float colonial_phaeocystis_nitrogen(time=1, level=30, nj=266, ni=245);
      :long_name = "colonial_phaeocystis_nitrogen";
      :standard_name = "mole_concentration_of_colonial_phaeocystis_expressed_as_nitrogen_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float phaeocystis_cells_nitrogen(time=1, level=30, nj=266, ni=245);
      :long_name = "phaeocystis_cells_nitrogen";
      :standard_name = "mole_concentration_of_phaeocystis_cells_expressed_as_nitrogen_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float phaeocystis_mucus(time=1, level=30, nj=266, ni=245);
      :long_name = "phaeocystis_mucus";
      :standard_name = "concentration_of_phaeocystis_mucus_expressed_as_mass_in_sea_water";
      :units = "mg.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float ammonium(time=1, level=30, nj=266, ni=245);
      :long_name = "ammonium";
      :standard_name = "mole_concentration_of_ammonium_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float nitrate(time=1, level=30, nj=266, ni=245);
      :long_name = "nitrate";
      :standard_name = "mole_concentration_of_nitrate_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float dissolved_silicate(time=1, level=30, nj=266, ni=245);
      :long_name = "dissolved_silicate";
      :standard_name = "mole_concentration_of_silicate_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float dissolved_phosphate(time=1, level=30, nj=266, ni=245);
      :long_name = "dissolved_phosphate";
      :standard_name = "mole_concentration_of_phosphate_in_sea_water";
      :units = "micromole.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float dissolved_oxygen(time=1, level=30, nj=266, ni=245);
      :long_name = "dissolved_oxygen";
      :standard_name = "dissolved_oxygen_in_water_column";
      :units = "mg.l-1";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float cumulative_nanoflagellate_carbon_production(time=1, level=30, nj=266, ni=245);
      :long_name = "cumulative_nanoflagellate_carbon_production";
      :standard_name = "cumulative_nanoflagellate_production_expressed_as_carbon_in_sea_water";
      :units = "g.m-3_from_01jan";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float cumulative_diatom_carbon_production(time=1, level=30, nj=266, ni=245);
      :long_name = "cumulative_diatom_carbon_production";
      :standard_name = "cumulative_diatom_production_expressed_as_carbon_in_sea_water";
      :units = "g.m-3_from_01jan";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float cumulative_dinoflagellate_carbon_production(time=1, level=30, nj=266, ni=245);
      :long_name = "cumulative_dinoflagellate_carbon_production";
      :standard_name = "cumulative_dinoflagellate_production_expressed_as_carbon_in_sea_water";
      :units = "g.m-3_from_01jan";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float organic_nitrogen_benth(time=1, level=30, nj=266, ni=245);
      :long_name = "organic_nitrogen_benth";
      :standard_name = "mole_concentration_of_organic_detritus_expressed_as_nitrogen_in_benthos";
      :units = "mmole.m-2";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float biogenic_silica_benth(time=1, level=30, nj=266, ni=245);
      :long_name = "biogenic_silica_benth";
      :standard_name = "mole_concentration_of_organic_detritus_expressed_as_silicon_in_benthos";
      :units = "mmole.m-2";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

    float detrital_phosphorus_benth(time=1, level=30, nj=266, ni=245);
      :long_name = "detrital_phosphorus_benth";
      :standard_name = "mole_concentration_of_organic_detritus_expressed_as_phosphorus_in_benthos";
      :units = "mmole.m-2";
      :coordinates = "latitude longitude";
      :valid_min = -1.0E30f; // float
      :valid_max = 1.0E30f; // float
      :_FillValue = 999.0f; // float
      :_ChunkSizes = 1U, 30U, 266U, 245U; // uint

  // global attributes:
  :limi = 0; // int
  :lima = 244; // int
  :pasi = 1; // int
  :ljmi = 0; // int
  :ljma = 265; // int
  :pasj = 1; // int
  :lkmi = 1; // int
  :lkma = 30; // int
  :pask = 1; // int
  :global_imin = 0; // int
  :global_imax = 244; // int
  :global_jmin = 0; // int
  :global_jmax = 265; // int
  :Conventions = "CF-1.6 OCO-1.3.1 COMODO-1.0";
  :product_version = "1.0";
  :references = "http://www.previmer.org/";
  :easting = "longitude";
  :northing = "latitude";
  :grid_projection = "n/a";
  :distribution_statement = "Data restrictions: for registered users only";
  :institution = "IFREMER";
  :institution_references = "http://www.ifremer.fr";
  :data_centre = "DYNECO/PHYSED";
  :data_centre_references = "http://wwz.ifremer.fr/mars3d";
  :creation_date = "2022-01-04T07:44:53Z";
  :run_time = "2022-01-04T07:44:53Z";
  :history = "2022-01-04T07:44:53Z: creation";
  :model_name = "MARS";
  :arakawa_grid_type = "C1";
  :source = "MARS ECOMARS-V10";
  :southernmost_latitude = "43.2314";
  :northernmost_latitude = "52.7686";
  :latitude_resolution = "3.597440000000000E-002";
  :westernmost_longitude = "-7.9756";
  :easternmost_longitude = "5.1043";
  :longitude_resolution = "5.360000000000000E-002";
  :minimum_depth = "-2.490000";
  :maximum_depth = "5043.400";
  :depth_resolution = "n/a";
  :forecast_range = "n/a";
  :forecast_type = "n/a";
  :operational_status = "experimental";
  :data_type = "OCO straight grid";
  :format_version = "1.4";
  :netcdf_version = "4.1.2";
  :software_version = "MARC forecasting system v2";
  :contact = "[email protected]";
  :quality_index = "0";
  :title = "MARC B1 ECOMARS3D MANGA4000 v2019 forecast";
  :product_name = "MARC_B1-ECOMARS3D-MANGA4000_20220102T1200Z.nc";
  :comment = "Use of Meteo-France ARPEGE HR meteorological data";
  :area = "MANGA";
  :start_date = "2022-01-02T12:00:00Z";
  :stop_date = "2022-01-02T12:00:00Z";
  :field_type = "1-daily";
}
1
  • Why do you need it as a geotiff? What software are you using? Does latitude and longitude look structured? It looks like a 4D ocean model defined on an Arakawa-C staggered grid. the various latitude and longitude variables are 2D matricies locating the points on the staggered edges or whatever (u,v, rho) of the grids. You could probably get a particular variable of interest out as point data with its matching latitude* and longitude* variable.
    – Dave X
    Apr 20, 2022 at 0:46

1 Answer 1

0

Probably a bit late but, I encountered the same. Maybe you need to do a couple of adjustments to the code, but you will see the main idea behind it.

data = netcdf_file[element][variable_name]
print(data)
# Get latitude and longitude information
longitudes = data[:, 0]
latitudes = data[:, 1]
ash_values = data[:, 2]
# Define the geospatial metadata
lon_min = float(longitudes.min())
lon_max = float(longitudes.max())
lat_min = float(latitudes.min())
lat_max = float(latitudes.max())
# Create a regular grid of latitude and longitude points
lon_points = np.arange(lon_min, lon_max + resolution, resolution)
lat_points = np.arange(lat_min, lat_max + resolution, resolution)
# Ensure the grid sizes match the data size
num_lon_points = len(lon_points)
num_lat_points = len(lat_points)

so2_grid = np.full((num_lat_points, num_lon_points), no_data_value, dtype=data.dtype)

# Fill the grid with SO2 values at intersecting points
for i in range(len(latitudes)):
    lon_index = int((longitudes[i] - lon_min) / resolution)
    lat_index = int((latitudes[i] - lat_min) / resolution)
    if 0 <= lon_index < num_lon_points and 0 <= lat_index < num_lat_points:
        so2_grid[lat_index, lon_index] = ash_values[i]

out_var_dir = output_dir / source / variable_name
out_var_dir.mkdir(exist_ok=True, parents=True)
# Create a GeoTIFF file for the current flight level
output_file = out_var_dir / f'{source}_{variable_name}_{date}.tif'

# Define CRS and transform
crs = 'EPSG:4326'  # WGS 84
transform = from_origin(longitudes.min(), latitudes.min(), resolution, -resolution)  # Adjust resolution as needed

# Create and write to GeoTIFF
with rasterio.open(output_file, 'w', driver='GTiff', height=so2_grid.shape[0], width=so2_grid.shape[1], count=1,
                   dtype=data.dtype, crs=crs, transform=transform, nodata=no_data_value) as dst:
    dst.write_band(1, so2_grid)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.