You're welcome. Glad to hear it's working for you. Michael
On 14 November 2011 16:45, 新科 李 <[email protected]> wrote: > Hello Michael, > Just now I checked my codes,and the reason resulted in code error > is as what you pointed out。Thank you very much! > > > Li Xinke > 发件人: Michael Bedward <[email protected]> > 收件人: lxkwh <[email protected]> > 抄送: geotools-gt2-users <[email protected]> > 发送日期: 2011年11月14日, 星期一, 上午 8:50 > 主题: Re: [Geotools-gt2-users] How to crop GeoTiff image using Crop class > > Hello Xinke, > > In your code, this expression... > > (double) clippingAreaVertsModelCoors[2 * 1] > > should be... > > (double) clippingAreaVertsModelCoors[2 * i] > > Michael > > > On 13 November 2011 18:38, lxkwh <[email protected]> wrote: >> Hi, I am going to crop Geotiff image using the Crop class in >> GeoTools(version 8.0-M2),but after running,message displayed as follows: >> >> Exception in thread "AWT-EventQueue-0" >> org.geotools.coverage.processing.CannotCropException: An error occurred >> while cropping. >> >> Why? How to modify the codes. Thans for your help. >> >> Below are my codes. >> >> GeoTiffReader gtReader = new GeoTiffReader(orthoImageFile); >> >> final GridCoverage2D gc = gtReader.read(null); >> >> GeometryFactory gf=new GeometryFactory(); >> >> >> >> LinearRing lr=null; >> >> Coordinate coors[]=new Coordinate[count+1]; >> >> for(int i=0;i<count;i++) coors[i]=new >> >> Coordinate((double)clippingAreaVertsModelCoors[2*1],(double)clippingAreaVertsModelCoors[2*i+1]); >> >> coors[count]=coors[0]; >> >> lr=gf.createLinearRing(coors); >> >> com.vividsolutions.jts.geom.Polygon croppedPolygon=new >> com.vividsolutions.jts.geom.Polygon(lr, null, gf); >> >> Crop orthoImageCrop = new Crop(); >> >> ParameterValueGroup orthoImageCropParameterValueGroup = >> orthoImageCrop.getParameters(); >> orthoImageCropParameterValueGroup.parameter("Source").setValue(gc); >> >> orthoImageCropParameterValueGroup.parameter(Crop.PARAMNAME_ROI).setValue(croppedPolygon); >> // croppedPolygon >> (com.vividsolutions.jts.geom.Polygon) >> >> Hints hints=new Hints(); >> >> GridCoverage2D gcCrop = (GridCoverage2D) >> orthoImageCrop.doOperation(orthoImageCropParameterValueGroup, hints). >> >> Li >> Xinke >> [email protected] >> >> >> 2011-11-13 >> ________________________________ >> lxkwh >> >> ------------------------------------------------------------------------------ >> RSA(R) Conference 2012 >> Save $700 by Nov 18 >> Register now >> http://p.sf.net/sfu/rsa-sfdev2dev1 >> _______________________________________________ >> Geotools-gt2-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >> >> > > > ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
