温州2000坐标系转wgs84坐标系
时间: 2024-02-05 19:09:07 浏览: 32
温州2000坐标系转换为WGS84坐标系可以使用以下方法:
1. 使用Proj4库进行转换:
```java
import org.osgeo.proj4j.CoordinateReferenceSystem;
import org.osgeo.proj4j.CoordinateTransform;
import org.osgeo.proj4j.CRSFactory;
import org.osgeo.proj4j.ProjCoordinate;
public class CoordinateConversion {
public static void main(String[] args) {
// 定义温州2000坐标系的EPSG代码
String wenzhou2000EPSG = "EPSG:4490";
// 定义WGS84坐标系的EPSG代码
String wgs84EPSG = "EPSG:4326";
// 创建坐标系工厂
CRSFactory crsFactory = new CRSFactory();
// 根据EPSG代码获取坐标系对象
CoordinateReferenceSystem wenzhou2000CRS = crsFactory.createFromName(wenzhou2000EPSG);
CoordinateReferenceSystem wgs84CRS = crsFactory.createFromName(wgs84EPSG);
// 创建坐标转换对象
CoordinateTransform transform = new CoordinateTransform(wenzhou2000CRS, wgs84CRS);
// 定义温州2000坐标系中的坐标点
ProjCoordinate wenzhou2000Point = new ProjCoordinate(120.7059, 27.9944);
// 创建用于存储转换结果的坐标点对象
ProjCoordinate wgs84Point = new ProjCoordinate();
// 进行坐标转换
transform.transform(wenzhou2000Point, wgs84Point);
// 输出转换后的WGS84坐标系中的坐标点
System.out.println("WGS84坐标系中的坐标点:");
System.out.println("经度:" + wgs84Point.x);
System.out.println("纬度:" + wgs84Point.y);
}
}
```
2. 使用GeoTools库进行转换:
```java
import org.geotools.geometry.jts.JTSFactoryFinder;
import org.geotools.referencing.CRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
public class CoordinateConversion {
public static void main(String[] args) throws Exception {
// 定义温州2000坐标系的EPSG代码
String wenzhou2000EPSG = "EPSG:4490";
// 定义WGS84坐标系的EPSG代码
String wgs84EPSG = "EPSG:4326";
// 根据EPSG代码获取坐标系对象
CoordinateReferenceSystem wenzhou2000CRS = CRS.decode(wenzhou2000EPSG);
CoordinateReferenceSystem wgs84CRS = CRS.decode(wgs84EPSG);
// 创建坐标转换对象
MathTransform transform = CRS.findMathTransform(wenzhou2000CRS, wgs84CRS);
// 定义温州2000坐标系中的坐标点
Coordinate wenzhou2000Point = new Coordinate(120.7059, 27.9944);
// 创建几何对象工厂
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
// 创建温州2000坐标系中的点几何对象
Geometry wenzhou2000Geometry = geometryFactory.createPoint(wenzhou2000Point);
// 进行坐标转换
Geometry wgs84Geometry = JTS.transform(wenzhou2000Geometry, transform);
// 获取转换后的WGS84坐标系中的坐标点
Coordinate wgs84Point = wgs84Geometry.getCoordinate();
// 输出转换后的WGS84坐标系中的坐标点
System.out.println("WGS84坐标系中的坐标点:");
System.out.println("经度:" + wgs84Point.x);
System.out.println("纬度:" + wgs84Point.y);
}
}
```