调整了成像网格的坐标系
parent
9df7c8b1a0
commit
97608b5626
|
@ -174,8 +174,6 @@ public: // 方法
|
|||
virtual void saveImage(std::shared_ptr<float>, int start_row, int start_col, int rowcount, int colcount, int band_ids);
|
||||
virtual void saveImage(std::shared_ptr<int>, int start_row, int start_col, int rowcount, int colcount, int band_ids);
|
||||
|
||||
|
||||
|
||||
virtual void saveImage();
|
||||
virtual void setNoDataValue(double nodatavalue, int band_ids);
|
||||
virtual void setNoDataValuei(int nodatavalue, int band_ids);
|
||||
|
@ -197,6 +195,10 @@ public: // 方法
|
|||
|
||||
virtual RasterExtend getExtend();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
QString img_path; // 图像文件
|
||||
int height; // 高
|
||||
|
@ -236,6 +238,10 @@ public:
|
|||
Eigen::MatrixXcd data;
|
||||
};
|
||||
|
||||
|
||||
bool BASECONSTVARIABLEAPI CopyProjectTransformMatrixFromRasterAToRasterB(QString RasterAPath, QString RasterBPath);
|
||||
|
||||
|
||||
// 创建影像
|
||||
gdalImage BASECONSTVARIABLEAPI CreategdalImageDouble(QString& img_path, int height, int width, int band_num, bool overwrite = false, bool isEnvi = false);
|
||||
gdalImage BASECONSTVARIABLEAPI CreategdalImageFloat(QString& img_path, int height, int width, int band_num, bool overwrite = false, bool isEnvi = false);
|
||||
|
|
|
@ -1470,6 +1470,51 @@ gdalImage CreategdalImage(const QString& img_path, int height, int width, int ba
|
|||
}
|
||||
|
||||
|
||||
bool CopyProjectTransformMatrixFromRasterAToRasterB(QString RasterAPath, QString RasterBPath) {
|
||||
// 注册所有GDAL驱动
|
||||
GDALAllRegister();
|
||||
|
||||
// 打开影像A(只读模式)
|
||||
GDALDataset* ds_a = (GDALDataset*)GDALOpen(RasterAPath.toUtf8().constData(), GA_ReadOnly);
|
||||
if (ds_a == nullptr) {
|
||||
std::cerr << "无法打开影像A" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取A的仿射矩阵和投影信息
|
||||
double geotransform[6];
|
||||
ds_a->GetGeoTransform(geotransform); // 包含六参数仿射变换
|
||||
const char* projection = ds_a->GetProjectionRef(); // WKT格式投影
|
||||
|
||||
// 打开影像B(更新模式)
|
||||
GDALDataset* ds_b = (GDALDataset*)GDALOpen(RasterBPath.toUtf8().constData(), GA_Update);
|
||||
if (ds_b == nullptr) {
|
||||
std::cerr << "无法打开影像B" << std::endl;
|
||||
GDALClose(ds_a);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 设置仿射矩阵
|
||||
if (ds_b->SetGeoTransform(geotransform) != CE_None) {
|
||||
std::cerr << "设置仿射矩阵失败" << std::endl;
|
||||
}
|
||||
|
||||
// 设置投影坐标系
|
||||
if (ds_b->SetProjection(projection) != CE_None) {
|
||||
std::cerr << "设置投影失败" << std::endl;
|
||||
}
|
||||
|
||||
// 释放资源
|
||||
GDALClose(ds_a);
|
||||
GDALClose(ds_b);
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ QLookTableResampleFromWGS84ToRange::QLookTableResampleFromWGS84ToRange(QWidget *
|
|||
connect(ui->pushButtonLookTableWGS84Select, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLookTableWGS84SelectClicked(bool)));
|
||||
connect(ui->pushButtonLookTableRangeSelect, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLookTableRangeSelectClicked(bool)));
|
||||
connect(ui->pushButtonLookTableCountSelect, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLookTableCountSelectClicked(bool)));
|
||||
|
||||
}
|
||||
|
||||
QLookTableResampleFromWGS84ToRange::~QLookTableResampleFromWGS84ToRange()
|
||||
|
|
|
@ -90,6 +90,11 @@ ErrorCode TBPImageAlgCls::ProcessWithGridNet(long num_thread,QString xyzRasterPa
|
|||
QMessageBox::information(nullptr, u8"提示", u8"目前只支持显卡");
|
||||
return ErrorCode::FAIL;
|
||||
}
|
||||
|
||||
// 处理成像映射
|
||||
CopyProjectTransformMatrixFromRasterAToRasterB(this->outRasterXYZPath, this->L1ds->getImageRasterPath());
|
||||
|
||||
|
||||
return ErrorCode::SUCCESS;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue