do you have a prj for this data that contains the definition of the
coordinate reference system?
Looking at the coordinates in the header of the file I can tell this
data is ina projected crs but if you don't have the prj the code will
assume wgs84 and proceed. From that point and on, you cannot rely on
the coordinates of the gridcoverage and therefore a reprojection may
lead to nasty results.

Simone.
-------------------------------------------------------
Ing. Simone Giannecchini
GeoSolutions S.A.S.
Founder - Software Engineer
Via Carignoni 51
55041  Camaiore (LU)
Italy

phone: +39 0584983027
fax:      +39 0584983027
mob:    +39 333 8128928


http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/simonegiannecchini
http://twitter.com/simogeo

-------------------------------------------------------



On Wed, May 26, 2010 at 10:35 AM, Adnila <[email protected]> wrote:
>
> of course I can. here you are!
>
> this is my code for the resampling method: gc2D is input coverage,
> gridcellwidth is the needed cell width and gridcellwidthold is the old one,
> which should be changed.
>
> public GridCoverage2D gridResample(GridCoverage2D gc2D, double
> gridCellWidth, double gridCellWidthOld) {
>
>                // initialize new processor and parameters
>                DefaultProcessor processor = new DefaultProcessor(null);
>                ParameterValueGroup parameters =
>                       processor.getOperation("Resample").getParameters();
>                parameters.parameter("Source").setValue(gc2D);
>
>                // interpolation can be NearestNeighbor, Bilinear or Bicubic
>                
> parameters.parameter("InterpolationType").setValue("NearestNeighbor");
>
>                // get current grid geometry, envelope and range
>                GridGeometry2D curGridGeom = gc2D.getGridGeometry();
>                Envelope2D curWorldEnv = curGridGeom.getEnvelope2D();
>                GridEnvelope2D curGridEnv = curGridGeom.getGridRange2D();
>
>                // cell size to fixed value
>                double cellSize = gridCellWidth;
>
>                int xDim = (int) (curWorldEnv.getWidth()/cellSize);
>                int yDim = (int) (curWorldEnv.getHeight()/cellSize);
>
>                GridEnvelope2D newGEnv = new GridEnvelope2D(curGridEnv.x, 
> curGridEnv.y,
> xDim, yDim);
>                GridGeometry2D newGG = new GridGeometry2D(newGEnv, 
> (Envelope)curWorldEnv);
>                parameters.parameter("GridGeometry").setValue(newGG);
>
>                GridCoverage2D resampledCov = (GridCoverage2D)
> processor.doOperation(parameters);
>                return resampledCov;
> }
>
> this method seems ok.
>
> this is my method for reprojecting the above resampled girdcoverage: input
> is resampled gridcoverage
>
>        public GridCoverage2D project(GridCoverage2D gc2D) {
>
>                CoordReferSyst crs = new CoordReferSyst();
>                DefaultProcessor processor = new DefaultProcessor(null);
>
>                ParameterValueGroup parameters =
>                        processor.getOperation("Resample").getParameters();
>
>                parameters.parameter("Source").setValue(gc2D);
>
>                // interpolation can be NearestNeighbor, Bilinear or Bicubic
>                
> parameters.parameter("InterpolationType").setValue("NearestNeighbor");
>
>                GridGeometry2D curGridGeom = gc2D.getGridGeometry();
>                Envelope curWorldEnv = curGridGeom.getEnvelope2D();
>
>                GridEnvelope2D curGridEnv = curGridGeom.getGridRange2D();
>
>                // create new GridGeometry with half as many cells
>                GridGeometry newGridGeom = new GridGeometry2D(curGridEnv, 
> curWorldEnv);
>
>
> parameters.parameter("CoordinateReferenceSystem").setValue(crs.crs_ETRS89_LAEA());
>
>                parameters.parameter("GridGeometry").setValue(newGridGeom);
>                GridCoverage2D reprojectedCov = (GridCoverage2D)
> processor.doOperation(parameters);
>
>                return reprojectedCov;
>        }
>
> test data:
> http://osgeo-org.1803224.n2.nabble.com/file/n5102432/GRID_TM0_TW_20030105.asc
> GRID_TM0_TW_20030105.asc
> to load data in:
> ArcGridReader agr = new ArcGridReader(file);
>                        gc2D = (GridCoverage2D) agr.read(null);
>
> the result of reprojecting looks not that bad, but not right yet. I tried
> the doOperation method instead of DEFAULT.resample.
>
> it looks like this:
> http://osgeo-org.1803224.n2.nabble.com/file/n5102432/test1.jpg
> the tiny rectangle above europe is the reprojected data. it should be
> somewhere in Germany, concret in Dresden.
>
> what am I doing wrong? It is just something with the geometry but I do not
> get it right how to fix it.
>
>
>
>
>
>
> --
> View this message in context: 
> http://osgeo-org.1803224.n2.nabble.com/Reprojection-tp5098885p5102432.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>

------------------------------------------------------------------------------

_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to