private void SetAttribute(IGRIB2GridDefinitionSection gds) { if (gds != null) { _coordEnvelope = new Core.DF.CoordEnvelope(gds.LonFirstPoint, gds.LonEndPoint, gds.LatEndPoint, gds.LatFirstPoint); _width = gds.Nx; _height = gds.Ny; _definition = new GRIB_Definition((float)gds.LonFirstPoint, (float)gds.LatFirstPoint, (float)gds.LonEndPoint, (float)gds.LatEndPoint, (float)gds.Dx, (float)gds.Dy, gds.Nx, gds.Ny, "30", -9999); int gridtype = gds.GridTemplateNo; using (SpatialReferenceBuilder builder = new SpatialReferenceBuilder()) { _spatialRef = builder.GetSpatialRef(gridtype, gds.LatFirstPoint, gds.LatEndPoint, 0); } _resolutionX = _definition.LonResolution; _resolutionY = _definition.LatResolution; _coordEnvelope = _definition.GetCoordEnvelope(); } if (_records == null) { _bandCount = 0; } else { _bandCount = _records.Count; } _dataType = enumDataType.Float; }
public IArrayRasterDataProvider Build(GRIB_Definition definition, GRIB_Point[] points) { float[][] bandValues = new float[1][]; bandValues[0] = new float[definition.Width * definition.Height]; InitBandValues(bandValues[0], definition.Width, definition.Height, points); //空间参考,以后根据格点场的投影类型修改 ISpatialReference spatialRef = SpatialReference.GetDefault(); return(new ArrayRasterDataProvider <float>(definition.ValueName, bandValues, definition.Width, definition.Height, definition.GetCoordEnvelope(), spatialRef)); }
private void SetAttributes(Grib1GridDefinitionSection gds, Grib1ProductDefinitionSection pds) { if (gds != null) { _definition = new GRIB_Definition((float)gds.LonFirstPoint, (float)gds.LatEndPoint, (float)gds.Dy, gds.Nx, gds.Ny, pds.Level.Name, float.NaN); _height = gds.Ny; _resolutionX = (float)gds.Dx; _resolutionY = (float)gds.Dy; _width = gds.Nx; } _decscale = pds.DecimalScale; _referenceTime = pds.ReferenceTime; _timeUnit = pds.TimeUnit; _isBmsExist = pds.BmsExists(); _coordEnvelope = _definition.GetCoordEnvelope(); _dataType = enumDataType.Float; }
private void SetAttributes(Grib1GridDefinitionSection gds, Grib1ProductDefinitionSection pds) { if (gds != null) { _definition = new GRIB_Definition((float)gds.LonFirstPoint, (float)gds.LatFirstPoint, (float)gds.LonEndPoint, (float)gds.LatEndPoint, (float)gds.Dx, (float)gds.Dy, gds.Nx, gds.Ny, pds.Level.Name, pds.Level.Value1); _level = pds.Level.Value1; _firstlat = gds.LatFirstPoint; _firstlon = gds.LonFirstPoint; _lastlat = gds.LatEndPoint; _lastlon = gds.LonEndPoint; //日本的J区域网格为“瘦网格”,即每行格点数不同, //已通过GDS中的_thinnedGrid值计算dx和Nx //if (pds.Center == 34 && _firstlat == 0 && _firstlon == 60 && _lastlat == 90 && _lastlon == 150) //日本J区域 //{ // _resolutionX = (float)gds.Dy; // _resolutionY = (float)gds.Dy; // _height = gds.Ny; // _width = gds.Ny; //} //else { _resolutionX = (float)gds.Dx; _resolutionY = (float)gds.Dy; _height = gds.Ny; _width = gds.Nx; } _resolution = gds.Resolution; _coordEnvelope = _definition.GetCoordEnvelope(); _gridtype = gds.GridType; _thinnedGrid = gds.ThinnedGrid; _thinnedGridNum = gds.ThinnedGridNum; _thinnedXNums = gds.ThinnedXNums; _xReverse = gds.XReverse; _yReverse = gds.YReverse; } else if (pds.Center == 7)//美国KWBC, { _resolutionX = 5.0f; _gridtype = 0; if (pds.Grid_Id == 21)//A区域 { _definition = new GRIB_Definition(180f, 0f, 0f, 90f, 5f, 2.5f, 37, 36, null, -9999); _width = _definition.Width; _height = _definition.Height; _firstlat = 0; _firstlon = 0; _lastlat = 90; _resolutionY = 2.5f; _coordEnvelope = new CoordEnvelope(0, 180, 0, 90); } else if (pds.Grid_Id == 22)//B区域 { _definition = new GRIB_Definition(-180f, 0f, 0f, 90f, 5f, 2.5f, 37, 36, null, -9999); _width = _definition.Width; _height = _definition.Height; _firstlat = 0; _firstlon = -180; _lastlat = 90; _resolutionY = 2.5f; _coordEnvelope = new CoordEnvelope(-180, 0, 0, 90); } else if (pds.Grid_Id == 23)//C区域 { _definition = new GRIB_Definition(0f, -90f, 180f, 0f, 5f, 2.5f, 37, 36, null, -9999); _width = _definition.Width; _height = _definition.Height; _firstlat = -90; _firstlon = 0; _lastlat = 0; _resolutionY = 2.5f; _coordEnvelope = new CoordEnvelope(0, 180, -90, 0); } else if (pds.Grid_Id == 24)//D区域 { _definition = new GRIB_Definition(-180f, -90f, -90f, 0f, 5f, 2.5f, 37, 36, null, -9999); _width = _definition.Width; _height = _definition.Height; _firstlat = -90; _firstlon = -180; _lastlat = 0; _resolutionY = 2.5f; _coordEnvelope = new CoordEnvelope(-180, 0, -90, 0); } else if (pds.Grid_Id == 25)//北半球 { _definition = new GRIB_Definition(-180f, 0f, 180f, 90f, 5f, 5f, 72, 18, null, -9999); _width = _definition.Width; _height = _definition.Height; _firstlat = 0; _firstlon = -180; _lastlat = 90; _resolutionY = 5.0f; _coordEnvelope = new CoordEnvelope(-180, 180, 0, 90); } else if (pds.Grid_Id == 26)//南半球 { _definition = new GRIB_Definition(-180f, -90f, 180f, 0f, 5f, 5f, 72, 18, null, -9999); _width = _definition.Width; _height = _definition.Height; _firstlat = -90; _firstlon = -180; _lastlat = 0; _resolutionY = 5.0f; _coordEnvelope = new CoordEnvelope(-180, 180, -90, 0); } } _decscale = pds.DecimalScale; _referenceTime = pds.ReferenceTime; _timeUnit = pds.TimeUnit; _isBmsExist = pds.BmsExists(); _dataType = enumDataType.Float; using (SpatialReferenceBuilder builder = new SpatialReferenceBuilder()) { int prjType = GetPrjTypeByGridType(_gridtype); _spatialReff = builder.GetSpatialRef(prjType, _firstlat, _lastlat, 0); } }