配置环境变量
找到解压后gdal目录下的proj.db文件,并增设环境变量PROJ_LIB: proj.db 所在文件夹,然后重启计算机,不然会出 ERROR 1: PROJ: createGeodeticReferenceFrame: Cannot find proj.db 异常

程序代码
gdal.AllRegister();
Dataset dataset = gdal.Open(converPojectionStyle.getSouceFile());
String projection = dataset.GetProjection();
SpatialReference spatialReference = new SpatialReference(projection);
String attrValue = spatialReference.GetAttrValue("AUTHORITY" , 1);
System.out.println(attrValue);
attrValue = "EPSG:" + attrValue;
if (attrValue.equals(converPojectionStyle.getTargetType())) {
return;
}
Vector<String> options = new Vector<>();
options.add("t_srs EPSG:3857");
System.out.println("进行转换");
WarpOptions warpOptions = new WarpOptions(options);
gdal.Warp(converPojectionStyle.getTargetFile(),new Dataset[] {dataset}, warpOptions);
dataset.delete();
gdal.GDALDestroyDriverManager();
本文指导如何配置GDAL环境变量,包括找到并指向proj.db文件,解决ERROR1:PROJ:createGeodeticReferenceFrame:Cannotfindproj.db问题,同时提供关键步骤和示例代码片段用于数据投影转换操作。
1682

被折叠的 条评论
为什么被折叠?



