当前位置: 首页>>代码示例>>C#>>正文


C# GDAL.Dataset类代码示例

本文整理汇总了C#中OSGeo.GDAL.Dataset的典型用法代码示例。如果您正苦于以下问题:C# Dataset类的具体用法?C# Dataset怎么用?C# Dataset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Dataset类属于OSGeo.GDAL命名空间,在下文中一共展示了Dataset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RasterizeGdbFeature

        public static void RasterizeGdbFeature(string gdbPath, string inputeFeatureLayer, out Dataset outputDataset, string fieldName, double rasterCellSize)
        {
            ReadFeature readFeature = new ReadFeature(gdbPath, inputeFeatureLayer);
            Layer layer = readFeature.GetFeatureLayer();

            ConversionGdal.ConvertFeatureToRaster(layer, out outputDataset, rasterCellSize, fieldName);
        }
开发者ID:alamsal,项目名称:GDAL_UTILS_Csharp,代码行数:7,代码来源:RasterizeLayerGdal.cs

示例2: AutoCreateWarpedVRT

 public static Dataset AutoCreateWarpedVRT(Dataset src_ds, string src_wkt, string dst_wkt, ResampleAlg eResampleAlg, double maxerror)
 {
     IntPtr cPtr = GdalPINVOKE.AutoCreateWarpedVRT(Dataset.getCPtr(src_ds), src_wkt, dst_wkt, (int)eResampleAlg, maxerror);
     Dataset ret = (cPtr == IntPtr.Zero) ? null : new Dataset(cPtr, true, ThisOwn_true());
     if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
开发者ID:wangfeilong321,项目名称:vdpm,代码行数:7,代码来源:Gdal.cs

示例3: GDALInfoGetPosition

        private static void GDALInfoGetPosition(Dataset ds, double x, double y, out double dfGeoX, out double dfGeoY)
        {
            double[] adfGeoTransform = new double[6];
            ds.GetGeoTransform(adfGeoTransform);

            dfGeoX = adfGeoTransform[0] + adfGeoTransform[1] * x + adfGeoTransform[2] * y;
            dfGeoY = adfGeoTransform[3] + adfGeoTransform[4] * x + adfGeoTransform[5] * y;
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:8,代码来源:GDALReader.cs

示例4: GDAL_Info

        public GDAL_Info(Dataset ds)
        {
            Projection = ds.GetProjectionRef();
            Resolution = new Size(ds.RasterXSize, ds.RasterYSize);
            Bands = new DataBandInfo[ds.RasterCount];
            for (int i = 0; i < ds.RasterCount; i++)
            {
                Band band = ds.GetRasterBand(i + 1);
                Bands[i] = new DataBandInfo();
                int temp;
                band.GetMaximum(out Bands[i].MaxValue, out temp);
                band.GetMaximum(out Bands[i].MinValue, out temp);
                band.GetNoDataValue(out Bands[i].NODATAValue, out temp);
                ColorInterp clr = band.GetRasterColorInterpretation();
                switch (clr)
                {
                    case ColorInterp.GCI_RedBand:
                        Bands[i].Name = "RedBand";
                        Bands[i].Image = Resource1.red_layer;
                        BppType += "R";
                        break;
                    case ColorInterp.GCI_GreenBand:
                        Bands[i].Name = "GreenBand";
                        Bands[i].Image = Resource1.green_layer;
                        BppType += "G";
                        break;
                    case ColorInterp.GCI_BlueBand:
                        Bands[i].Name = "BlueBand";
                        Bands[i].Image = Resource1.blue_layer;
                        BppType += "B";
                        break;
                    default:
                        Bands[i].Name = clr.ToString();
                        Bands[i].Image = null;
                        BppType += "?";
                        break;
                }
                BppType += "[" + Gdal.GetDataTypeName(band.DataType) + "]";
                Bpp += (ushort)Gdal.GetDataTypeSize(band.DataType);

                if (i + 1 < ds.RasterCount)
                    BppType += ",";
            }
            BppType += " (" + Bpp + ")";
            
            Driver = ds.GetDriver().LongName;

            Metadata = ds.GetMetadata("");
            ImgMetadata = ds.GetMetadata("IMAGE_STRUCTURE");
            SubDSMetadata = ds.GetMetadata("SUBDATASETS");
            GeoLocMetadata = ds.GetMetadata("GEOLOCATION");

            GDALInfoGetPosition(ds, 0.0, 0.0, out UpperLeftX, out UpperLeftY);
            GDALInfoGetPosition(ds, 0.0, ds.RasterYSize, out UpperRightX, out UpperRightY);
            GDALInfoGetPosition(ds, ds.RasterXSize, 0.0, out LowerLeftX, out LowerLeftY);
            GDALInfoGetPosition(ds, ds.RasterXSize, ds.RasterYSize, out LowerRightX, out LowerRightY);
            GDALInfoGetPosition(ds, ds.RasterXSize / 2, ds.RasterYSize / 2, out CenterX, out CenterY);
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:58,代码来源:GDALReader.cs

示例5: GdalImage

        /// <summary>
        ///
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="ds"></param>
        /// <param name="band"></param>
        internal GdalImage(string filename, Dataset ds, ImageBandType band)
        {
            _dataset = ds;
            if (band == ImageBandType.ARGB)
            {
                using (Band bnd = ds.GetRasterBand(1))
                {
                    bnd.SetRasterColorInterpretation(ColorInterp.GCI_AlphaBand);
                }
                using (Band bnd = ds.GetRasterBand(2))
                {
                    bnd.SetRasterColorInterpretation(ColorInterp.GCI_RedBand);
                }
                using (Band bnd = ds.GetRasterBand(3))
                {
                    bnd.SetRasterColorInterpretation(ColorInterp.GCI_GreenBand);
                }
                using (Band bnd = ds.GetRasterBand(4))
                {
                    bnd.SetRasterColorInterpretation(ColorInterp.GCI_BlueBand);
                }
            }
            else if (band == ImageBandType.RGB)
            {
                using (Band bnd = ds.GetRasterBand(1))
                {
                    bnd.SetRasterColorInterpretation(ColorInterp.GCI_RedBand);
                }
                using (Band bnd = ds.GetRasterBand(2))
                {
                    bnd.SetRasterColorInterpretation(ColorInterp.GCI_GreenBand);
                }
                using (Band bnd = ds.GetRasterBand(3))
                {
                    bnd.SetRasterColorInterpretation(ColorInterp.GCI_BlueBand);
                }
            }
            else if (band == ImageBandType.PalletCoded)
            {
                using (Band bnd = ds.GetRasterBand(3))
                {
                    bnd.SetRasterColorInterpretation(ColorInterp.GCI_PaletteIndex);
                }
            }
            else
            {
                using (Band bnd = ds.GetRasterBand(3))
                {
                    bnd.SetRasterColorInterpretation(ColorInterp.GCI_GrayIndex);
                }
            }

            Filename = filename;
            WorldFile = new WorldFile { Affine = new double[6] };
            Gdal.AllRegister();
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:62,代码来源:GdalImage.cs

示例6: getCPtrAndSetReference

 public static HandleRef getCPtrAndSetReference(Dataset obj, object parent) {
   if (obj != null)
   {
     obj.swigParentRef = parent;
     return obj.swigCPtr;
   }
   else
   {
     return new HandleRef(null, IntPtr.Zero);
   }
 }
开发者ID:diegowald,项目名称:intellitrack,代码行数:11,代码来源:Dataset.cs

示例7: getCPtrAndDisown

 public static HandleRef getCPtrAndDisown(Dataset obj, object parent) {
   if (obj != null)
   {
     obj.swigCMemOwn = false;
     obj.swigParentRef = parent;
     return obj.swigCPtr;
   }
   else
   {
     return new HandleRef(null, IntPtr.Zero);
   }
 }
开发者ID:diegowald,项目名称:intellitrack,代码行数:12,代码来源:Dataset.cs

示例8: GetPreview

        protected virtual void GetPreview(Dataset dataset, Size size, Graphics g,
                                          Envelope displayBbox, ProjectionInfo mapProjection, Map map)
#endif
        {

            if (!NeedRotation(dataset))
            {
                GetNonRotatedPreview(dataset, size, g, displayBbox, mapProjection);
                return;
            }

            var geoTransform = new GeoTransform(dataset);
            
            Bitmap bitmap = null;
            var bitmapTL = new Point();

            //Coordinate imageTL = new Coordinate(), imageBR = new Coordinate();
            //int bitmapWidth, bitmapHeight;
            var bitmapSize = new Size();

            const int pixelSize = 3; //Format24bppRgb = byte[b,g,r] 

            if (dataset != null)
            {
                //check if image is in bounding box
                if ((displayBbox.MinX > _envelope.MaxX) || (displayBbox.MaxX < _envelope.MinX)
                    || (displayBbox.MaxY < _envelope.MinY) || (displayBbox.MinY > _envelope.MaxY))
                    return;

                // init histo
                Histogram = new List<int[]>();
                for (int i = 0; i < Bands + 1; i++)
                    Histogram.Add(new int[256]);

                // bounds of section of image to be displayed
                //var left = Math.Max(displayBbox.MinX, _envelope.MinX);
                //var top = Math.Min(displayBbox.MaxY, _envelope.MaxY);
                //var right = Math.Min(displayBbox.MaxX, _envelope.MaxX);
                //var bottom = Math.Max(displayBbox.MinY, _envelope.MinY);

                var trueImageBbox = displayBbox.Intersection(_envelope);

                // put display bounds into current projection
                Envelope shownImageBbox;
                if (Transform != null)
                {
#if !DotSpatialProjections
                    Transform.MathTransform.Invert();
                    shownImageBbox = GeometryTransform.TransformBox(trueImageBbox, Transform.MathTransform);
                    Transform.MathTransform.Invert();
#else
                    shownImageBbox = GeometryTransform.TransformBox(trueImageBbox, _transform.Source, _transform.Target);
#endif
                }
                else
                {
                    shownImageBbox = trueImageBbox;
                }

                // find min/max x and y pixels needed from image
                var g2i = geoTransform.GroundToImage(shownImageBbox).Intersection(new Envelope(0, _imageSize.Width, 0, _imageSize.Height));
                var gdalImageRect = ToRectangle(g2i);
                var displayImageSize = gdalImageRect.Size;

                //// find ground coordinates of image pixels
                //var groundBR = geoTransform.ImageToGround(imageBR);
                //var groundTL = geoTransform.ImageToGround(imageTL);

                // convert ground coordinates to map coordinates to figure out where to place the bitmap
                var bitmapBR = new Point((int)map.WorldToImage(trueImageBbox.BottomRight()).X + 1,
                                         (int)map.WorldToImage(trueImageBbox.BottomRight()).Y + 1);
                bitmapTL = new Point((int)map.WorldToImage(trueImageBbox.TopLeft()).X,
                                     (int)map.WorldToImage(trueImageBbox.TopLeft()).Y);

                bitmapSize.Width = bitmapBR.X - bitmapTL.X;
                bitmapSize.Height = bitmapBR.Y - bitmapTL.Y;

                // check to see if image is on its side
                if (bitmapSize.Width > bitmapSize.Height && displayImageSize.Width < displayImageSize.Height)
                {
                    displayImageSize.Width = bitmapSize.Height;
                    displayImageSize.Height = bitmapSize.Width;
                }
                else
                {
                    displayImageSize.Width = bitmapSize.Width;
                    displayImageSize.Height = bitmapSize.Height;
                }

                // scale
                var bitScalar = GetBitScalar();

                // 0 pixels in length or height, nothing to display
                if (bitmapSize.Width < 1 || bitmapSize.Height < 1)
                    return;

                //initialize bitmap
                BitmapData bitmapData;
                bitmap = InitializeBitmap(bitmapSize, PixelFormat.Format24bppRgb, out bitmapData);
                
//.........这里部分代码省略.........
开发者ID:junglewithyou,项目名称:SharpMap,代码行数:101,代码来源:GdalRasterLayer.cs

示例9: ReleaseManagedResources

 protected override void ReleaseManagedResources()
 {
     _factory = null;
     //_geoTransform = null;
     _gdalDataset.Dispose();
     _gdalDataset = null;
     
     base.ReleaseManagedResources();
 }
开发者ID:junglewithyou,项目名称:SharpMap,代码行数:9,代码来源:GdalRasterLayer.cs

示例10: GetNonRotatedPreview

        private void GetNonRotatedPreview(Dataset dataset, Size size, Graphics g,
                                          Envelope bbox, ProjectionInfo mapProjection)
#endif
        {
            double[] geoTrans = new double[6];
            dataset.GetGeoTransform(geoTrans);

            // default transform
            if (!_useRotation && !HaveSpot || (geoTrans[0] == 0 && geoTrans[3] == 0))
                geoTrans = new[] { 999.5, 1, 0, 1000.5, 0, -1 };
            Bitmap bitmap = null;
            var geoTransform = new GeoTransform(geoTrans);
            int DsWidth = 0;
            int DsHeight = 0;
            BitmapData bitmapData = null;
            double[] intVal = new double[Bands];
            int p_indx;
            double bitScalar = 1.0;

            double dblImginMapW = 0, dblImginMapH = 0, dblLocX = 0, dblLocY = 0;

            int iPixelSize = 3; //Format24bppRgb = byte[b,g,r] 

            if (dataset != null)
            {
                //check if image is in bounding box
                if ((bbox.MinX > _envelope.MaxX) || (bbox.MaxX < _envelope.MinX)
                    || (bbox.MaxY < _envelope.MinY) || (bbox.MinY > _envelope.MaxY))
                    return;

                DsWidth = _imageSize.Width;
                DsHeight = _imageSize.Height;

                Histogram = new List<int[]>();
                for (int i = 0; i < Bands + 1; i++)
                    Histogram.Add(new int[256]);

                double left = Math.Max(bbox.MinX, _envelope.MinX);
                double top = Math.Min(bbox.MaxY, _envelope.MaxY);
                double right = Math.Min(bbox.MaxX, _envelope.MaxX);
                double bottom = Math.Max(bbox.MinY, _envelope.MinY);

                double x1 = Math.Abs(geoTransform.PixelX(left));
                double y1 = Math.Abs(geoTransform.PixelY(top));
                double imgPixWidth = geoTransform.PixelXwidth(right - left);
                double imgPixHeight = geoTransform.PixelYwidth(bottom - top);

                //get screen pixels image should fill 
                double dblBBoxW = bbox.Width;
                double dblBBoxtoImgPixX = imgPixWidth / dblBBoxW;
                dblImginMapW = size.Width * dblBBoxtoImgPixX * geoTransform.HorizontalPixelResolution;


                double dblBBoxH = bbox.Height;
                double dblBBoxtoImgPixY = imgPixHeight / dblBBoxH;
                dblImginMapH = size.Height * dblBBoxtoImgPixY * -geoTransform.VerticalPixelResolution;

                if ((dblImginMapH == 0) || (dblImginMapW == 0))
                    return;

                // ratios of bounding box to image ground space
                double dblBBoxtoImgX = size.Width / dblBBoxW;
                double dblBBoxtoImgY = size.Height / dblBBoxH;

                // set where to display bitmap in Map
                if (bbox.MinX != left)
                {
                    if (bbox.MaxX != right)
                        dblLocX = (_envelope.MinX - bbox.MinX) * dblBBoxtoImgX;
                    else
                        dblLocX = size.Width - dblImginMapW;
                }
                if (bbox.MaxY != top)
                {
                    if (bbox.MinY != bottom)
                        dblLocY = (bbox.MaxY - _envelope.MaxY) * dblBBoxtoImgY;
                    else
                        dblLocY = size.Height - dblImginMapH;
                }

                bitScalar = GetBitScalar();

                try
                {
                    bitmap = new Bitmap((int)Math.Round(dblImginMapW), (int)Math.Round(dblImginMapH),
                                        PixelFormat.Format24bppRgb);
                    bitmapData =
                        bitmap.LockBits(
                            new Rectangle(0, 0, (int)Math.Round(dblImginMapW), (int)Math.Round(dblImginMapH)),
                            ImageLockMode.ReadWrite, bitmap.PixelFormat);

                    byte cr = _noDataInitColor.R;
                    byte cg = _noDataInitColor.G;
                    byte cb = _noDataInitColor.B;

                    //
                    Double[] noDataValues = new Double[Bands];
                    Double[] scales = new Double[Bands];

                    ColorTable colorTable = null;
//.........这里部分代码省略.........
开发者ID:junglewithyou,项目名称:SharpMap,代码行数:101,代码来源:GdalRasterLayer.cs

示例11: GdalRasterLayer

        /// <summary>
        /// initialize a Gdal based raster layer
        /// </summary>
        /// <param name="strLayerName">Name of layer</param>
        /// <param name="imageFilename">location of image</param>
        public GdalRasterLayer(string strLayerName, string imageFilename)
        {
            SpotPoint = new PointF(0, 0);
            Projection = "";
            BitDepth = 8;
            NonSpotGain = new double[] {1, 1, 1, 1};
            SpotGain = new double[] {1, 1, 1, 1};
            Gain = new double[] {1, 1, 1, 1};
            NonSpotGamma = 1;
            SpotGamma = 1;
            Gamma = 1;
            TransparentColor = Color.Empty;
            ColorCorrect = true;
            LayerName = strLayerName;
            Filename = imageFilename;

            //TilingSize = new Size(256, 128);

            Gdal.AllRegister();

            try
            {
                _gdalDataset = Gdal.OpenShared(Filename, Access.GA_ReadOnly);

                // have gdal read the projection
                Projection = _gdalDataset.GetProjectionRef();

                // no projection info found in the image...check for a prj
                if (Projection == "" &&
                    File.Exists(imageFilename.Substring(0, imageFilename.LastIndexOf(".", StringComparison.CurrentCultureIgnoreCase)) + ".prj"))
                {
                    Projection =
                        File.ReadAllText(imageFilename.Substring(0, imageFilename.LastIndexOf(".", StringComparison.CurrentCultureIgnoreCase)) + ".prj");
                }

                _imageSize = new Size(_gdalDataset.RasterXSize, _gdalDataset.RasterYSize);
                _envelope = GetExtent();

                HistoBounds = new Rectangle((int)_envelope.MinX, (int)_envelope.MinY, (int)_envelope.Width,
                                            (int)_envelope.Height);
                Bands = _gdalDataset.RasterCount;
            }
            catch (Exception ex)
            {
                _gdalDataset = null;
                throw new Exception("Couldn't load " + imageFilename + "\n\n" + ex.Message + ex.InnerException);
            }
        }
开发者ID:junglewithyou,项目名称:SharpMap,代码行数:53,代码来源:GdalRasterLayer.cs

示例12: NeedRotation

        private bool NeedRotation(Dataset dataset)
        {
            if (UseRotation)
                return true;
            if (Transform != null)
                return true;
            if (HaveSpot)
                return true;

            var geoTransform = new GeoTransform(dataset);

            return geoTransform.IsScaling || geoTransform.IsRotating;

        }
开发者ID:junglewithyou,项目名称:SharpMap,代码行数:14,代码来源:GdalRasterLayer.cs

示例13: ReadHeader

 private void ReadHeader()
 {
     try
     {
         _dataset = Gdal.Open(Filename, Access.GA_Update);
     }
     catch
     {
         try
         {
             _dataset = Gdal.Open(Filename, Access.GA_ReadOnly);
         }
         catch (Exception ex)
         {
             throw new GdalException(ex.ToString());
         }
     }
     Init(_dataset.RasterXSize, _dataset.RasterYSize);
     NumBands = _dataset.RasterCount;
     WorldFile = new WorldFile { Affine = new double[6] };
     double[] test = new double[6];
     _dataset.GetGeoTransform(test);
     Bounds = new RasterBounds(Height, Width, test);
     WorldFile.Affine = test;
     DoClose();
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:26,代码来源:GdalTiledImage.cs

示例14: ReadHeader

 private void ReadHeader()
 {
     _dataset = Helpers.Open(Filename);
     Init(_dataset.RasterXSize, _dataset.RasterYSize);
     NumBands = _dataset.RasterCount;
     WorldFile = new WorldFile { Affine = new double[6] };
     double[] test = new double[6];
     _dataset.GetGeoTransform(test);
     Bounds = new RasterBounds(Height, Width, test);
     WorldFile.Affine = test;
     Close();
 }
开发者ID:hanchao,项目名称:DotSpatial,代码行数:12,代码来源:GdalTiledImage.cs

示例15: CloseFile

 public override void CloseFile()
 {
     if (dataset != null)
     {
         dataset.Dispose();
         dataset = null;
     }
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:8,代码来源:GDALReader.cs


注:本文中的OSGeo.GDAL.Dataset类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。