本文整理汇总了C#中OSGeo.GDAL.Dataset.GetGeoTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Dataset.GetGeoTransform方法的具体用法?C# Dataset.GetGeoTransform怎么用?C# Dataset.GetGeoTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSGeo.GDAL.Dataset
的用法示例。
在下文中一共展示了Dataset.GetGeoTransform方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: 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();
}
示例4: 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;
//.........这里部分代码省略.........
示例5: GDALInfoGetPosition
private static string GDALInfoGetPosition(Dataset ds, double x, double y)
{
double[] adfGeoTransform = new double[6];
double dfGeoX, dfGeoY;
ds.GetGeoTransform(adfGeoTransform);
dfGeoX = adfGeoTransform[0] + adfGeoTransform[1] * x + adfGeoTransform[2] * y;
dfGeoY = adfGeoTransform[3] + adfGeoTransform[4] * x + adfGeoTransform[5] * y;
return dfGeoX.ToString() + ", " + dfGeoY.ToString();
}
示例6: GetNonRotatedPreview
// faster than rotated display
private void GetNonRotatedPreview(Dataset dataset, Size size, Graphics g, BoundingBox bbox, ICoordinateSystem mapProjection)
{
double[] geoTrans = new double[6];
dataset.GetGeoTransform(geoTrans);
// default transform
if (!_useRotation && !_haveSpot || (geoTrans[0] == 0 && geoTrans[3] == 0))
geoTrans = new double[] { 999.5, 1, 0, 1000.5, 0, -1 };
Bitmap bitmap = null;
GT = 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.Left > _Envelope.Right) || (bbox.Right < _Envelope.Left)
|| (bbox.Top < _Envelope.Bottom) || (bbox.Bottom > _Envelope.Top))
return;
DsWidth = _imagesize.Width;
DsHeight = _imagesize.Height;
_histogram = new List<int[]>();
for (int i = 0; i < _lbands + 1; i++)
_histogram.Add(new int[256]);
double left = Math.Max(bbox.Left, _Envelope.Left);
double top = Math.Min(bbox.Top, _Envelope.Top);
double right = Math.Min(bbox.Right, _Envelope.Right);
double bottom = Math.Max(bbox.Bottom, _Envelope.Bottom);
double x1 = Math.Abs(GT.PixelX(left));
double y1 = Math.Abs(GT.PixelY(top));
double imgPixWidth = GT.PixelXwidth(right - left);
double imgPixHeight = GT.PixelYwidth(bottom - top);
//get screen pixels image should fill
double dblBBoxW = bbox.Right - bbox.Left;
double dblBBoxtoImgPixX = (double)imgPixWidth / (double)dblBBoxW;
dblImginMapW = (double)size.Width * dblBBoxtoImgPixX * GT.HorizontalPixelResolution;
double dblBBoxH = bbox.Top - bbox.Bottom;
double dblBBoxtoImgPixY = (double)imgPixHeight / (double)dblBBoxH;
dblImginMapH = (double)size.Height * dblBBoxtoImgPixY * -GT.VerticalPixelResolution;
if ((dblImginMapH == 0) || (dblImginMapW == 0))
return;
// ratios of bounding box to image ground space
double dblBBoxtoImgX = (double)size.Width / dblBBoxW;
double dblBBoxtoImgY = (double)size.Height / dblBBoxH;
// set where to display bitmap in Map
if (bbox.Left != left)
{
if (bbox.Right != right)
dblLocX = (_Envelope.Left - bbox.Left) * dblBBoxtoImgX;
else
dblLocX = (double)size.Width - dblImginMapW;
}
if (bbox.Top != top)
{
if (bbox.Bottom != bottom)
dblLocY = (bbox.Top - _Envelope.Top) * dblBBoxtoImgY;
else
dblLocY = (double)size.Height - dblImginMapH;
}
// scale
if (_bitDepth == 12)
bitScalar = 16.0;
else if (_bitDepth == 16)
bitScalar = 256.0;
else if (_bitDepth == 32)
bitScalar = 16777216.0;
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);
unsafe
{
double[][] buffer = new double[Bands][];
Band[] band = new Band[Bands];
int[] ch = new int[Bands];
// get data from image
for (int i = 0; i < Bands; i++)
//.........这里部分代码省略.........
示例7: GDALInfoGetPositionDouble
private static double[] GDALInfoGetPositionDouble(Dataset ds, double x, double y)
{
double[] adfGeoTransform = new double[6];
double dfGeoX, dfGeoY;
ds.GetGeoTransform(adfGeoTransform);
dfGeoX = adfGeoTransform[0] + adfGeoTransform[1] * x + adfGeoTransform[2] * y;
dfGeoY = adfGeoTransform[3] + adfGeoTransform[4] * x + adfGeoTransform[5] * y;
return new double[] { dfGeoX, dfGeoY };
}