java实现将WGS84经纬度转化为UTM zone 50N
时间: 2024-05-12 13:20:04 浏览: 190
以下是Java代码示例,使用Proj4J库将WGS84经纬度转换为UTM zone 50N:
```java
import org.osgeo.proj4j.CoordinateReferenceSystem;
import org.osgeo.proj4j.CRSFactory;
import org.osgeo.proj4j.CoordinateTransform;
import org.osgeo.proj4j.ProjCoordinate;
public class WGS84toUTM50N {
public static void main(String[] args) {
// Define WGS84 coordinate system
CRSFactory crsFactory = new CRSFactory();
CoordinateReferenceSystem wgs84 = crsFactory.createFromName("EPSG:4326");
// Define UTM zone 50N coordinate system
CoordinateReferenceSystem utm50n = crsFactory.createFromName("EPSG:32650");
// Create coordinate transform
CoordinateTransform transform = new CoordinateTransform(wgs84, utm50n);
// Define WGS84 longitude and latitude
double lon = 121.5;
double lat = 25.0;
// Transform WGS84 to UTM zone 50N
ProjCoordinate wgs84Coord = new ProjCoordinate(lon, lat);
ProjCoordinate utm50nCoord = new ProjCoordinate();
transform.transform(wgs84Coord, utm50nCoord);
// Print UTM zone 50N coordinates
System.out.println("UTM zone 50N X: " + utm50nCoord.x);
System.out.println("UTM zone 50N Y: " + utm50nCoord.y);
}
}
```
注意,这里使用EPSG代码来定义WGS84和UTM zone 50N坐标系统。如果您需要使用其他坐标系统,请查阅Proj4J文档并相应地修改代码。
阅读全文