阅读背景:

GDAL获取指定地理坐标像元值、获取指定地理范围影像数据

来源:互联网 
//GdalImage.h
#include "StructDef.h"

#include "gdal1.11.2/gdal_priv.h"
#include "gdal1.11.2/gdal.h"
//#ifdef __cplusplus
//extern "C" {
//#endif


struct stRasterInfo
{
	char fileName[255];
	GDALDataset* pDataset;
	XRECT<rtsDataTypeGeo> rasterRange;
	int nBandCount;
};

struct stBitmapInfo
{
	char fileName[255];
	bool isInters;//是否有相交部分
	BYTE* pBuf;
	int nBandCount;

	int xStart;
	int yStart;
	int xEnd;
	int yEnd;

	int xSize;
	int ySize;
	stBitmapInfo():isInters(false), pBuf(NULL), nBandCount(0), xStart(0),yStart(0),xEnd(0),yEnd(0), xSize(0), ySize(0){}
	~stBitmapInfo()
	{
		if( pBuf )
		{
			free( pBuf );
			pBuf = NULL;
		}			
	}
};


static char g_szRasterPath[255] = {0};	//栅格影像所在文件夹全路径路径
static int g_screenWidth = 0;	//屏幕分辨率,宽
static int g_screenHeight = 0;	//屏幕分辨率,高



//由地理坐标得到图像行列号
bool Projection2ImageRowCol(double *adfGeoTransform, double dProjX, double dProjY, int &iCol, int &iRow);

//根据地理位置获得指定点的像元值2015.3.5
//cszRasterPath[IN]:影像文件绝对路径	GeoX, GeoY[IN]:地理位置	pBuf[OUT]:存放读取到的像元值,为NULL读取失败
//nBandCOunt[OUT]:存放波段数	xSize, ySize[IN]:要获取像元值的范围,宽和高默认为1
void GetPixValByGeoPos( const char *cszRasterPath, const double GeoX, const double GeoY,
	int *&pBuf, int &nBandCount, int xSize, int ySize);// = 1  = 1

//初始化路径及分辨率
void InitVariable( const char *szRasterPath, const int screenWidth, const int screenHeight );

//获取影像对象
void GetBuf( const XRECT<rtsDataTypeGeo> showRange, stBitmapInfo *&pBitmap, int& nSize );

//#ifdef __cplusplus
//}
//#endif//GdalImage.h
#include "StructDef.h"

#include 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: