【发布时间】:2019-11-03 10:29:16
【问题描述】:
我有一个读取一组坐标的函数,我得到了 UTM 坐标。后来我将这些 UTM 坐标转换为 WGS84。当此数据来自 4 个文件(shp、.dbf、.shx 和 .prj)的集合时,没有问题。
这是我获取坐标并转换它们的代码:
public Geometry getGeometryDistrict(String refCatDistrict, String shapeFileDistrict){
Geometry union = null;
File shapeFile = new File (shapeFileDistrict);
try {
Query query = new Query();
query.setCoordinateSystem(DefaultGeographicCRS.WGS84);
Filter filter = CQL.toFilter("obj_co_id = '"+refCatDistrict+"'");
query.setFilter(filter);
FileDataStore storeDistrict = FileDataStoreFinder.getDataStore(shapeFile);
SimpleFeatureSource featureSource = storeDistrict.getFeatureSource();
SimpleFeatureCollection collection = featureSource.getFeatures(query);
SimpleFeature fDistrict = null;
ArrayList<Geometry> geometries = new ArrayList<>();
SimpleFeatureIterator itrDistrict = collection.features();
while(itrDistrict.hasNext()){
fDistrict = itrDistrict.next();
Geometry geomDistrict = (Geometry)fDistrict.getDefaultGeometry();
geometries.add(geomDistrict);
}
GeometryFactory factory = new GeometryFactory();
GeometryCollection geometryCollection = (GeometryCollection) factory.buildGeometry( geometries );
union = geometryCollection.union();
itrDistrict.close();
storeDistrict.dispose();
}catch(IOException | NoSuchElementException | CQLException e){
Throwable cause = e.getCause();
System.out.println(cause);
}
return union;
}
我的问题是这些数据并不总是有 .prj 文件(需要转换坐标),只有 3 个文件到达(.dbf、.shp 和 .shx)。
我的疑问是:是否有任何方法可以在没有 .prj 文件的情况下将 UTM 坐标转换为 WGS84?
【问题讨论】:
-
没有
.prj文件,你只有一个随机数的集合 -
OP 知道坐标在 UTM 中并希望转换为 WGS84。如果他想将 UTM 中的 shapefile 转换为 WGS84,即使没有 .prj 文件或任意坐标对,我也不清楚。