Hi Michael,

thanks a lot, it works! I had there "stupid typo" :)

I am vectorizing the following way:
         final File file = new 
File("/home/jirka/hibernate-spatial/event-tutorial/test2.tif");

         AbstractGridFormat format = GridFormatFinder.findFormat(file);
         AbstractGridCoverage2DReader reader = format.getReader(file);

         GridCoverage2D cov = reader.read(null);
         int band = Integer.valueOf(0);
         Envelope bounds = cov.getEnvelope();
         Set<Double> outsideValues = Collections.singleton(1.0d);
         boolean insideEdges = Boolean.TRUE;

         FeatureCollection<SimpleFeatureType,SimpleFeature> collection =
           RasterToVectorProcess.process(cov, band, bounds, 
outsideValues, insideEdges, null);

Next step I need to achieve is to merge the created feature collection 
into one multipolygon. I was trying an example from process module 
documentation:

         // 3 is one more then the current number of cpu cores
         ProcessExecutor backgroundExecutor = 
Processors.newProcessExecutor( 3, null );
         org.geotools.process.Process buffer = Processors.createProcess( 
new NameImpl("gt","buffer") );
         Map<String,Object> input = new KVP("features", collection, 
"buffer", 0.00 );
         Progress progress = backgroundExecutor.submit( buffer, input );

         if( progress.getProgress() == Progress.WORKING )
             System.out.println( "Progress: Working");
         else
             System.out.println( "Progress:"+progress.getProgress() + 
"percent complete" );

         Map<String,Object> result = progress.get();
         SimpleFeatureCollection resultFeatureCollection = 
(SimpleFeatureCollection result.get("features");

But doesn't work for me:
     Progress:0.0percent completeException in thread "main"
     java.util.concurrent.ExecutionException: 
java.lang.NullPointerException: geom1 parameter required
         at 
org.geotools.process.ProgressTask$Synchronizer.innerGet(ProgressTask.java:218)
         at org.geotools.process.ProgressTask.get(ProgressTask.java:76)
         at org.geotools.process.ProgressTask.get(ProgressTask.java:39)
         at event.App.main(App.java:72)
     Caused by: java.lang.NullPointerException: geom1 parameter required
         at 
org.geotools.process.literal.BufferProcess.execute(BufferProcess.java:57)
         at 
org.geotools.process.ProgressTask$Synchronizer.innerRun(ProgressTask.java:301)
         at org.geotools.process.ProgressTask.run(ProgressTask.java:120)
         at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
         at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
         at java.lang.Thread.run(Thread.java:662)

What am I doing wrong? Or is there some better way to do it?

Thank you very much,
Jiri Novak

On 07/25/2011 11:27 PM, Michael Bedward wrote:
> Hi Jiri,
>
> Please see this page in the user guide about WorldImageReader and let
> us know if it helps or not:
> http://docs.geotools.org/latest/userguide/library/coverage/image.html
>
> Michael
>
>
> On 26 July 2011 06:22, Jiří Novák<[email protected]>  wrote:
>> Providing a .tfw file alongside with .tif didn't work for me. Is there some
>> special way to tell geotools it exists or should be detected implicitly?
>>
>> Jiri Novak
>>
>> On 07/25/2011 11:26 AM, Jiří Novák wrote:
>>> Hi,
>>>
>>> thank you both for replying.
>>>
>>>>>   your image does not have either a proper grid-to-world transformation
>>>>>   or a proper coordinate reference system.
>>>>>   You should try to add a proper tfw[1] file to it.
>>> Problem is that I can not change the way how the tifs gets created, we
>>> have a closed library for transforming it from proper binary format which
>>> specification I don't know :(
>>> Third party just give us those tifs and an information file with the
>>> coordinates of bottom left and upper right corner for the affine
>>> transformation to JTSK (Krovak) which looks like that:
>>>
>>> 1163999.872425 763749.745142 1165000.000203 765000.000334 JTSK
>>>
>>> It's posible to add somehow this information into the (geo)tif and use the
>>> standard approach in geotools or do I have to follow the way Michael planted
>>> - it's using plain JAI library and then (somehow?) convert it to geotools's
>>> SimpleFeatureCollection?
>>>
>>> Thank you,
>>> Jiri Novak
>>>
>>> On 07/25/2011 05:48 AM, Simone Giannecchini wrote:
>>>> Ciao Jiri,
>>>> your image does not have either a proper grid-to-world transformation
>>>> or a proper coordinate reference system.
>>>> You should try to add a proper tfw[1] file to it.
>>>>
>>>> Regards,
>>>> Simone Giannecchini
>>>> [1] http://en.wikipedia.org/wiki/World_file
>>>> -------------------------------------------------------
>>>> Ing. Simone Giannecchini
>>>> GeoSolutions S.A.S.
>>>> Founder
>>>>
>>>> Via Poggio alle Viti 1187
>>>> 55054  Massarosa (LU)
>>>> Italy
>>>>
>>>> phone: +39 0584 962313
>>>> fax:      +39 0584 962313
>>>> mob:    +39 333 8128928
>>>>
>>>> http://www.geo-solutions.it
>>>> http://geo-solutions.blogspot.com/
>>>> http://www.youtube.com/user/GeoSolutionsIT
>>>> http://www.linkedin.com/in/simonegiannecchini
>>>> http://twitter.com/simogeo
>>>>
>>>> -------------------------------------------------------
>>>>
>>>>
>>>>
>>>> On Mon, Jul 25, 2011 at 9:45 AM, Michael Bedward
>>>> <[email protected]>    wrote:
>>>>> Hi Jiri
>>


------------------------------------------------------------------------------
Magic Quadrant for Content-Aware Data Loss Prevention
Research study explores the data loss prevention market. Includes in-depth
analysis on the changes within the DLP market, and the criteria used to
evaluate the strengths and weaknesses of these DLP solutions.
http://www.accelacomm.com/jaw/sfnl/114/51385063/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to