保形+畸变坐标变换



我正在尝试使用java地理工具api和opengis库将澳大利亚一些地块的几何坐标参考系统转换为另一个。即WSG84(EPSG:4326(至GDA2020/MGA区域50(EPSG:7850(或WSG84至GDA200/PCG2020(EPSG:8031(。到目前为止,转换后的坐标与它假设的原始坐标有一些偏差。现在我的要求是执行本文中解释的保形+失真转换,这更准确-https://www.icsm.gov.au/datum/gda-transformation-products-and-tools/transformation-grids

然而,我不太确定我需要对当前代码进行哪些更改才能完成上述操作。我在谷歌上搜索了一些代码示例,但找不到我想要的。如有任何帮助,我们将不胜感激。

Query       query       = new Query();
DataStore   dataStore   = getDataStore();
FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore.getFeatureSource(featureTypeName);
query.setFilter(ECQL.toFilter("land_id='" + landID + "'"));
FeatureCollection           collection      = source.getFeatures(query);
FeatureIterator             iterator        = collection.features();
CoordinateReferenceSystem   sourceCRS       = collection.getSchema().getCoordinateReferenceSystem(); // WSG 84
List<Geometry>              geometryList    = new ArrayList<Geometry>();
CoordinateReferenceSystem   targetCRS       = getCRS(targetEPSGCode); // GDA2020 / MGA zone 50
while (iterator.hasNext())
{
Feature             feature =   (Feature) iterator.next();
GeometryAttribute   geom    =   feature.getDefaultGeometryProperty();
Object              geomVal =   geom.getValue();
if (geomVal instanceof Geometry)
{
MathTransform   mathTransform       = CRS.findMathTransform(sourceCRS, targetCRS);
Geometry        transformedGeometry = JTS.transform((Geometry) geomVal, mathTransform);
geometryList.add(transformedGeometry);
}
}
// Use geometryList for further stuff

您需要下载所需的NTv2网格文件,并将其保存到项目src/main/resources/org/geotools/referencing/factory/gridshift文件夹中,然后重新编译项目。还有更多的讨论和一些示例代码可以帮助您检查是否在上面的答案中被选中https://gis.stackexchange.com

最新更新