添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
开发者社区 >

关于java使用geotools中的GeoTiffReader读取tif图像时报错:找不到类 javax.media.jai.PlanarImage 的错误
代码放上:

import java.io.File; import org.geotools.coverage.grid.GridCoverage2D; import org.geotools.gce.geotiff.GeoTiffReader; import org.geotools.geometry.Envelope2D; import org.opengis.referencing.crs.CoordinateReferenceSystem;

public class ImageExt { public static void main(String[] args) { GetImageExt("E:\database\overview\\J46\J46D001001.tif"); } public static String GetImageExt(String strImageUrl){ String strExtent = ""; try { String ImageUrl=strImageUrl.replace("\", "\\");; File ImageFile=new File(ImageUrl); GeoTiffReader reader=new GeoTiffReader(ImageFile); GridCoverage2D coverage = reader.read(null); CoordinateReferenceSystem crs = coverage.getCoordinateReferenceSystem2D(); Envelope2D coverageEnvelope = coverage.getEnvelope2D(); double coverageMinX = coverageEnvelope.getBounds().getMinX(); double coverageMaxX = coverageEnvelope.getBounds().getMaxX(); double coverageMinY = coverageEnvelope.getBounds().getMinY(); double coverageMaxY = coverageEnvelope.getBounds().getMaxY();

    } catch (Exception e) {
        // TODO: handle exception
    System.out.println(coverageMinX);    
    return strExtent;
  Exception in thread "main" java.lang.NoClassDefFoundError: 
 
javax/media/jai/ImageLayout at
zy3dms.ImageExt.GetImageExt(ImageExt.java:18) at
zy3dms.ImageExt.main(ImageExt.java:11) Caused by:
java.lang.ClassNotFoundException: javax.media.jai.ImageLayout at
java.net.URLClassLoader.findClass(URLClassLoader.java:381) at
java.lang.ClassLoader.loadClass(ClassLoader.java:424) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at
java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 2 more

我不解的是两个工程同样的类,一个运行正常,一个报错。

"

这个问题本人已解决,在File ImageFile=new File(strImageUrl);打断点,开启调试模式,
断点运行到GeoTiffReader reader=new GeoTiffReader(ImageFile);时,按F5(进入函数内部),但是没有运行函数,而是跳到classloader.class。
为了加载类时唯一,改为org.geotools.gce.geotiff.GeoTiffReader reader=new org.geotools.gce.geotiff.GeoTiffReader(ImageFile);运行正常。
图片是GeoTiffReader类的内部函数。
图片描述

2020-05-27 17:38:43 企业邮箱发送邮件时,若出现投递失败产生退信,内容提示包含如下: the mta server of * reply:550 failed to meet SPF requirements 或者 the mta server of 163.com — 163mx01.mxmail.netease.com(220.181.14.141) reply:550 MI:SPF mx14,QMCowECpA0qTiftVaeB3Cg—.872S2 1442548128 http://mail.163.com/help 303910