Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何用Java中的NetCDF将Lambert保角圆锥投影转换为lat/lng小数点_Java_Projection_Netcdf_Grib - Fatal编程技术网

如何用Java中的NetCDF将Lambert保角圆锥投影转换为lat/lng小数点

如何用Java中的NetCDF将Lambert保角圆锥投影转换为lat/lng小数点,java,projection,netcdf,grib,Java,Projection,Netcdf,Grib,我正在使用unidata中的NetCDF4Java库来读取GRIB文件。GRIB文件结构如下所示: dimensions: x = 401; y = 301; time = 1; variables: int LambertConformal_Projection; :grid_mapping_name = "lambert_conformal_conic"; :latitude_of_projection_origin = 46.

我正在使用unidata中的NetCDF4Java库来读取GRIB文件。GRIB文件结构如下所示:

  dimensions:
    x = 401;
    y = 301;
    time = 1;
  variables:
    int LambertConformal_Projection;
      :grid_mapping_name = "lambert_conformal_conic";
      :latitude_of_projection_origin = 46.12000274658203; // double
      :longitude_of_central_meridian = 14.815000534057617; // double
      :standard_parallel = 46.12000274658203; // double
      :earth_radius = 6367470.0; // double
      :_CoordinateTransformType = "Projection";
      :_CoordinateAxisTypes = "GeoX GeoY";

    float VAR219-0-219-170_surface(time=1, y=301, x=401);
      :long_name = "Unknown Parameter 219-0-219-170 @ Ground or water surface";
      :units = "";
      :missing_value = NaNf; // float
      :grid_mapping = "LambertConformal_Projection";
      :coordinates = "reftime time y x ";
      :Grib_Variable_Id = "VAR_219-0-219-170_L1";
      :Grib1_Center = 219; // int
      :Grib1_Subcenter = 0; // int
      :Grib1_TableVersion = 219; // int
      :Grib1_Parameter = 170; // int
      :Grib1_Level_Type = 1; // int
      :Grib1_Level_Desc = "Ground or water surface";

    float x(x=401);
      :standard_name = "projection_x_coordinate";
      :units = "km";
      :_CoordinateAxisType = "GeoX";

    float y(y=301);
      :standard_name = "projection_y_coordinate";
      :units = "km";
      :_CoordinateAxisType = "GeoY";

    double reftime;
      :units = "Minute since 2016-02-18T12:00:00Z";
      :standard_name = "forecast_reference_time";
      :long_name = "GRIB reference time";
      :calendar = "proleptic_gregorian";
      :_CoordinateAxisType = "RunTime";

    double time(time=1);
      :units = "Minute since 2016-02-18T12:00:00Z";
      :standard_name = "time";
      :long_name = "GRIB forecast or observation time";
      :calendar = "proleptic_gregorian";
      :_CoordinateAxisType = "Time";

  // global attributes:
  :Originating_or_generating_Center = "Ljubljana";
  :Originating_or_generating_Subcenter = "0";
  :GRIB_table_version = "0,219";
  :file_format = "GRIB-1";
  :Conventions = "CF-1.6";
  :history = "Read using CDM IOSP GribCollection v3";
  :featureType = "GRID";
  :_CoordSysBuilder = "ucar.nc2.dataset.conv.CF1Convention";
}

我想写一个程序,将x和y转换成lat/lng小数点。我不熟悉平面/全球地图。

感谢Fildor提供的链接。我所需要的(以及我发现的)是使用projToLatLon方法。这是我如何从x和y值获得纬度和经度的:

    NetcdfDataset gid = 
    GridDataset gds = ucar.nc2.dt.grid.GridDataset.open("file.GRB");  
    GridCoordSystem gcs =  gds.getGrids().get(0).getCoordinateSystem();
    ProjectionImpl proj = gcs.getProjection();
    Variable vr = gid.findVariable("x");
    Variable vr2 = gid.findVariable("y");
    Array data1 = vr.read();
    Array data2 = vr2.read();

    int[] shape = data1.getShape();
    int[] shape2 = data2.getShape();
    Index index = data1.getIndex();
    Index index2 = data2.getIndex();
    double dval;
    double dval2; 

    for (int j=0; j<shape2[0]; j++)
       for (int i=0; i<shape[0]; i++){
          dval = data1.getDouble(index.set(i));
          dval2 = data2.getDouble(index2.set(j));
          System.out.println(dval + " " + dval2 + " " + proj.projToLatLon(dval, dval2).getLatitude() + "  " + proj.projToLatLon(dval, dval2).getLongitude() );
    }        
NetcdfDataset gid=
GridDataset gds=ucar.nc2.dt.grid.GridDataset.open(“file.GRB”);
GridCoordSystem gcs=gds.getGrids().get(0.getCoordinateSystem();
ProjectionImpl proj=gcs.getProjection();
变量vr=gid.findVariable(“x”);
变量vr2=gid.可查找变量(“y”);
数组data1=vr.read();
数组data2=vr2.read();
int[]shape=data1.getShape();
int[]shape2=data2.getShape();
Index=data1.getIndex();
Index index2=data2.getIndex();
双dval;
双dval2;

对于(int j=0;jSo是什么阻止了你这么做?你做过任何努力吗?是的。我一直在尝试在NetCDF java库中找到一个如何使用投影和垂直转换的示例,但没有成功。不,我的意思是:你真的已经开始编写一些代码了吗?我知道java/编程通常不是你的问题,对吗?不,是的nce我不知道使用投影和垂直变换类的参数。我发现这个类是public CoordinateTransform makeCoordinateTransform,但不知道如何使用它。下面是一些教程:第5节显然是关于坐标变换的