本文整理汇总了C#中OSGeo.GDAL.Dataset.GetProjectionRef方法的典型用法代码示例。如果您正苦于以下问题:C# Dataset.GetProjectionRef方法的具体用法?C# Dataset.GetProjectionRef怎么用?C# Dataset.GetProjectionRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSGeo.GDAL.Dataset
的用法示例。
在下文中一共展示了Dataset.GetProjectionRef方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
}
示例3: GDALRasterProvider
/// <summary>
/// Initializes a new instance of the MapAround.DataProviders.GDALRasterProvider.
/// </summary>
/// <param name="fileName">Image file name</param>
public GDALRasterProvider(string fileName)
{
_fileName = fileName;
Gdal.AllRegister();
try
{
_gdalDataset = Gdal.OpenShared(_fileName, Access.GA_ReadOnly);
// have gdal read the projection
_strProjection = _gdalDataset.GetProjectionRef();
// no projection info found in the image...check for a prj
if (string.IsNullOrEmpty(_strProjection) &&
File.Exists(_fileName.Substring(0, _fileName.LastIndexOf(".")) + ".prj"))
{
_strProjection = File.ReadAllText(_fileName.Substring(0, _fileName.LastIndexOf(".")) + ".prj");
}
_imagesize = new Size(_gdalDataset.RasterXSize, _gdalDataset.RasterYSize);
_bandCount = _gdalDataset.RasterCount;
}
catch (Exception ex)
{
_gdalDataset = null;
throw new Exception("Failed loading " + _fileName + "\n" + ex.Message + ex.InnerException);
}
}
示例4: OpenDataset
protected void OpenDataset(string imageFilename)
{
try
{
_gdalDataset = Gdal.OpenShared(imageFilename, 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);
}
}
示例5: 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)
{
this.LayerName = strLayerName;
this.Filename = imageFilename;
disposed = false;
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(".")) + ".prj"))
{
_projection = File.ReadAllText(imageFilename.Substring(0, imageFilename.LastIndexOf(".")) + ".prj");
}
_imagesize = new Size(_GdalDataset.RasterXSize, _GdalDataset.RasterYSize);
_Envelope = this.GetExtent();
_histoBounds = new Rectangle((int)_Envelope.Left, (int)_Envelope.Bottom, (int)_Envelope.Width, (int)_Envelope.Height);
_lbands = _GdalDataset.RasterCount;
}
catch (Exception ex)
{
_GdalDataset = null;
throw new Exception("Couldn't load " + imageFilename + "\n\n" + ex.Message + ex.InnerException);
}
}