pom.xml
<!-- https://mvnrepository.com/artifact/org.geotools/gt-main -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-main</artifactId>
<version>29.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.geotools/gt-geotiff -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geotiff</artifactId>
<version>29.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.geotools/gt-shapefile -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>29.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.geotools/gt-geojson -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geojson</artifactId>
<version>29.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.geotools/gt-metadata -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-metadata</artifactId>
<version>29.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.geotools/gt-epsg-hsql -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
<version>29.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.geotools/gt-epsg-extension -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-extension</artifactId>
<version>29.2</version>
</dependency>
java代码
public static String GetImageExt(String path) {
String strExtent = "";
double coverageMinX = 0.000;
double coverageMaxX = 0.000;
double coverageMinY = 0.000;
double coverageMaxY = 0.000;
try {
String ImageUrl = path.replace("\\", "\\\\");
File ImageFile = new File(ImageUrl);
GeoTiffReader reader = new GeoTiffReader(ImageFile);
GridCoverage2D coverage = reader.read(null);
Envelope2D coverageEnvelope = coverage.getEnvelope2D();
coverageMinX = coverageEnvelope.getMinX();
coverageMaxX = coverageEnvelope.getMaxX();
coverageMinY = coverageEnvelope.getMinY();
coverageMaxY = coverageEnvelope.getMaxY();
} catch (Exception e) {
// TODO: handle exception
}
System.out.println(coverageMinX);
System.out.println(coverageMaxX);
System.out.println(coverageMinY);
System.out.println(coverageMaxY);
return strExtent;
}
文章评论