OK, so I diagnosed further and found out that due to legacy code, I had 
parts of the project on geotools 2.5. Obviously, there has been some 
change in coverage or so. While in NOv/Dec, when I last used this 
project, I was able to cross-reference 2.6-SNAPSHOT with the rest of the 
code in 2.5, but it is not possible anymore.

I upgraded my dependencies to 2.6.2, all seems good so far, but I have 
new problems with the generation of the original coverage from tiff:

reader = new GeoTiffReader(file);
...
coverage = (GridCoverage2D) reader.read(null);

seems not to make geotools happy anymore....+ there is a new warning I 
have never seen before, something about kakadu...:)

Mar 13, 2010 1:26:14 AM it.geosolutions.util.KakaduUtilities loadKakadu
WARNING: Native library load failed.java.lang.UnsatisfiedLinkError: no 
kdu_jni in java.library.path
Exception in thread "main" java.lang.NoSuchMethodError: 
org.geotools.gce.geotiff.GeoTiffReader.read([Lorg/opengis/parameter/GeneralParameterValue;)Lorg/geotools/coverage/grid/GridCoverage2D;

solved using GridCoverage a = reader.read(null;
and subsequently casting to GridCoverage2D ,...weird

What I cannot solvee are CRS.decode() errors:
WARNING: Can't load a service for category "MathTransformProvider". 
Cause is "MissingResourceException: Can't find resource for bundle 
org.geotools.resources.i18n.Vocabulary, key 250".
java.util.MissingResourceException: Can't find resource for bundle 
org.geotools.resources.i18n.Vocabulary, key 250

I have never seen those from geotools before...Argh...

Am off to holidays and will investigate more in a week. Makes me feel 
like a geotools newbie again...
M.





On 3/12/2010 11:54 PM, Michael Bedward wrote:
> Oops... no, that's not the problem Martin. I'm afraid that's just me
> complicating things for you.
>
> I've changed the type of the bounds parameter from Envelope2D to
> org.opengis.geometry.Envelope:
>
> http://jira.codehaus.org/browse/GEOT-2980
>
> The example code reflects that change.  If you are using a 2.6.2 the
> parameter type is Envelope2D.  The example code would be as below.
> Sorry for the confusion.
>
> Also, have you tried passing null for the bounds which is interpreted
> as vectorize the whole coverage ?
>
> Michael
>
>
> public class RasterToVector {
>
>      public static void main(String[] args) throws Exception {
>          new RasterToVector().demo();
>      }
>
>      private void demo() throws Exception {
>          // beware annoying difference in parameter order and meaning between
>          // Envelope2D and ReferencedEnvelope !
>          Envelope2D env = new
> ReferencedEnvelope(DefaultGeographicCRS.WGS84, 0.0, 0.0, 8.0, 8.0);
>
>          GridCoverage2D cov = createChessboardCoverage(256, 256, 32, env);
>          FeatureCollection<SimpleFeatureType, SimpleFeature>  fc =
> RasterToVectorProcess.process(cov, 0, env,
> Collections.singletonList(0.0d), null);
>
>          MapContext map = new DefaultMapContext();
>          map.setTitle("raster to vector conversion");
>          Style style = SLD.createPolygonStyle(Color.BLUE, Color.CYAN, 1.0f);
>          map.addLayer(fc, style);
>          JMapFrame.showMap(map);
>      }
>
>      private GridCoverage2D createChessboardCoverage(int imgWidth, int
> imgHeight, int squareWidth, Envelope2D env) {
>          GridCoverageFactory factory =
> CoverageFactoryFinder.getGridCoverageFactory(null);
>          GridCoverage2D cov = factory.create("chessboard",
> createChessboardImage(imgWidth, imgHeight, squareWidth), env);
>          return cov;
>      }
>
>      private RenderedImage createChessboardImage(int imgWidth, int
> imgHeight, int squareWidth) {
>          BufferedImage img = new BufferedImage(imgWidth, imgHeight,
> BufferedImage.TYPE_BYTE_BINARY);
>          WritableRaster raster = img.getRaster();
>
>          for (int y = 0; y<  imgHeight; y++) {
>              boolean oddRow = (y / squareWidth) % 2 == 1;
>              for (int x = 0; x<  imgWidth; x++) {
>                  boolean oddCol = (x / squareWidth) % 2 == 1;
>                  raster.setSample(x, y, 0, (oddCol == oddRow ? 1 : 0));
>              }
>          }
>
>          return img;
>      }
> }
>
>
>    


-- 
Martin Tomko
Postdoctoral Research Assistant

Geographic Information Systems Division
Department of Geography
University of Zurich - Irchel
Winterthurerstr. 190
CH-8057 Zurich, Switzerland

email:  [email protected]
site:   http://www.geo.uzh.ch/~mtomko
mob:    +41-788 629 558
tel:    +41-44-6355256
fax:    +41-44-6356848


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to