Hi Peppe,

thanks for you work!

By now I am not having any suggestions yet.
However, a question I have is: Do we not have any TIF export in OJ that 
avoids use of jai? We really need to try to avoid JAI, because the OSGeo 
LiveDVD works only with OpenJDK (as far as I know).

Can you push the code to a plugin folder or the core? to have a look at it.

Maybe we should also think about a simple checkbox on the dialog that 
offers to save the "raw DEM data", and not the image data. Or better: 
make to separate functions, using the same code plugin code, but having 
just a boolean value set use the original DEM values?

cheers,
stefan

Am 13.07.13 12:42, schrieb Giuseppe Aruta:
> I forgot: the plugin is available on Toolbar Raster menu
>
>
> 2013/7/13 Giuseppe Aruta <giuseppe_ar...@yahoo.it
> <mailto:giuseppe_ar...@yahoo.it>>
>
>     Hi Stefan (and others),
>     I worked on your code and expanded a little bit the plugin.
>     I came across this plugin which is an attempt  to larger Save to
>     Raster to substitute SaveRasterImageToImagePlugin from Pirol on
>     Sextante Layers.
>     I used some codes from Kosmo and OJ, removing any external jar
>     depency and only using JAI and ImageIO options. The code should be
>     embedded into the plugin
>
>     which are the benefits of this plugin comparing to original Pirol plugin
>     - This plugin currently export a Sextante Raster Image to TIF (not
>     with OpenJDK), JPG, PNG, BMP and ASC.
>     - It can also export part of the image (extracted using fence) to
>     JPG, TIF and PNG (not working with BMP and ASC).
>
>     which are the limits
>     -  ASC export  can export only the file and not with part of it
>     - If I export an ASC to TIF (talking about a monoband TIF), since I
>     use a BuffereImage from
>     rLayer.getImageForDisplay().getAsBufferedImage(), It export the
>     display color values and not the real dem datas
>
>     TODO (a possible list)
>     - applay a LUT  to a DEM and than export to image, ex JPG, with the
>     colormodel. So this raster can be used on a publication or slides
>     - PNG (and TIF) transparency. Pirol raster tool allows to set a
>     color to transparent. It should be interesting that this option
>     should be saved to a PNG (or TIF) exported file. In the past I used
>     a lot  topographic rasters (TIF) where  the white background had to
>     be set to transparent (using gdal)
>     - Possibility to split the bands of a multiband raster on saving (or
>     vice versa) for remote sensing
>
>     I tested this plugin on Ubuntu 64bit with both OpenJDK and Oracle JRE 7
>
>     Any idea to face the limits?
>
>     regeards and thanks
>
>     Peppe
>
>
>     PS.  Of coarse I didn't fine a solution for exporting to TIF on
>     OpenJDK. I tested two other  possibilities: Jimi raster library
>     (from Oracle) or a bridge to imagej software, both working but
>     requiring extra libraries
>
>
>     2013/6/27 Giuseppe Aruta <giuseppe_ar...@yahoo.it
>     <mailto:giuseppe_ar...@yahoo.it>>
>
>         Hi Stefan,
>         thanks a lot. I will go and study the code when I will be back
>         home.
>         Giuseppe
>
>
>         2013/6/27 Stefan Steiniger <sst...@geo.uzh.ch
>         <mailto:sst...@geo.uzh.ch>>
>
>             Hi Peppe and other Devs,
>
>             I fixed the problem :)
>             I send you my last version that seems to write an *.asc file
>             as it is
>             supposed to. At least it looks like OJ itself and QGIS are
>             able to read
>             it. From my file you can start and adding the stuff you
>             still think is
>             necessary. I have made some inline comments.
>
>             I think you actually got a bit confused with the whole row
>             and columns
>             thing (I switched the loops). And you should have put the
>             "write-ln"
>             command after the inner loop is finished, and not in each line.
>
>             Also, I realized that when I checked for the noData value,
>             that there
>             was something wrong. I found then out, that an OJ-Raster has
>             no NoData
>             value property, while Sextante has (however... OJ has a
>             transparency
>             setting). This also means, that when reading an ascii file
>             with the
>             current reader, then this values was not set. So I
>             implemented that
>             property, and will commit my changes in a few minutes.
>
>             The default NoDataValue is now Double.NaN.
>
>             This value will also get transferred when creating a
>             Sextante Raster
>             Image Layer from an image file. However, if a new Sextante
>             Layer is
>             created (not based on an existing file), then the default
>             noDataValue is
>             -99999.0 (i.e. one digit more than the ESRI default of -9999)
>
>             I hope I did not miss out on something, and nothing breaks
>             now when
>             working with Sextante. But I don't guess so.
>
>             I also attach my ascii test file, that I created from the
>             Wikipedia page.
>
>             cheers,
>             stefan
>
>
>             Am 26.06.13 12:56, schrieb Giuseppe Aruta:
>              > Really I don't understand loops in Java
>              > ;-)
>              >
>              >
>              > 2013/6/26 Giuseppe Aruta <giuseppe_ar...@yahoo.it
>             <mailto:giuseppe_ar...@yahoo.it>
>              > <mailto:giuseppe_ar...@yahoo.it
>             <mailto:giuseppe_ar...@yahoo.it>>>
>              >
>              >     Hi Stefan,
>              >     I made some progress, now I am able to save to asc,
>             unfortunately
>              >     each value of the pixel of the ascii is saved an
>             incredible number
>              >     equal to rowXcolumn of the original. So my test file
>             of 101 byte
>              >     becomes a huge file of 2 Gb :-( Surelly I made a misake.
>              >     Then I moved to Switzerland for job, where actully I
>             am. And didn't
>              >     carry with me Eclipse, codes, OpenJMP, etc. I will be
>             back home
>              >     after 5th of July and give a better look (and send
>             the code)
>              >     regards
>              >
>              >     Peppe
>              >
>              >
>              >     2013/6/26 Stefan Steiniger <sst...@geo.uzh.ch
>             <mailto:sst...@geo.uzh.ch>
>              >     <mailto:sst...@geo.uzh.ch <mailto:sst...@geo.uzh.ch>>>
>              >
>              >         Hi Peppe,
>              >
>              >         did you made any progress on that?
>              >         Or is the code the last version you have?
>              >
>              >         slds,
>              >         stefan
>              >
>              >         Am 21.06.13 06:05, schrieb Giuseppe Aruta:
>              >          >
>              >          > Hi all,
>              >          > Recently I worked a bit with Sextante/grids
>             and did some
>              >         specialized
>              >          > short courses. A student of mine used
>             OpenJUMP/Sextante to do
>              >         some
>              >          > analysis. Than he had to convert all the
>             rasters (TIFF
>              >         format) into ESRI
>              >          > Ascii grid files (.asc) as he had to use a
>             more specialized
>              >         software
>              >          > that was accepting only asc. and surfer raster
>             format.
>              >          > Of coarse we used gdal for raster transformation.
>              >          > Well, since  Esri ascii file is a very simple
>             text file
>              >          > (http://en.wikipedia.org/wiki/Esri_grid), in
>             these days (
>              >         that I have
>              >          > spare time)  I tried to make a plugin "Export
>             raster to Esri
>              >         Ascii grid
>              >          > file" for OpenJUMP (that in turn I would like
>             to add to OJ
>              >         NB). All
>              >          > raster parameters are easy implemented by
>             RasterImageLayer and
>              >          > OpenJUMPSextanteRasterLayer.
>              >          > I had some success and some failures.
>              >          > I ask your help, as developers.
>              >          > I added to this mail the code I wrote (coping
>             partially OJ raster
>              >          > classes and from other software like ImageJ) -
>             The foillowing
>              >         code just
>              >          > shows the transformation, excluding
>             initialize(), icon(),
>              >         name(), etc.
>              >          > This code partially works: the file is saved
>             together with
>              >         the header of
>              >          > the raster (see the *black* part of the code,
>             number of
>              >         colums, rows,
>              >          > x-ycoordinates of upper left corner, cell size
>             and NODATA),
>              >          > The red part of code is not working. This part
>             should  lists
>              >         the raster
>              >          > values for each cell, starting at the
>             upper-left corner,
>              >         possibly with
>              >          > decimal values, delimited by space character.
>             I ask you if
>              >         can give me a
>              >          > suggestion for this part.
>              >          > Another part that I would like to implement is the
>              >         MultienableCheck
>              >          > (dark *violet *part of the code). This plugin
>             should be
>              >         activated only
>              >          > if the raster has only one band (I think this
>             is numbered "0" by
>              >          > OpenJUMPSextanteRasterLayer class). Any
>             suggestion is
>              >         accepted: a way to
>              >          > distinguish (within Pirol raster plugin)
>             between grid mono
>              >         band file and
>              >          > others would be quite usefull for future plugins
>              >          > If this plugin is finished I think I will add
>             to OJ NB under
>              >          > Raster>Tools menu.
>              >          > regards and thanks
>              >          >
>              >          > Peppe
>              >          >
>              >          > public class SaveToASCPlugIn extends
>             AbstractPlugIn
>              >          > {
>              >          >
>              >          >    protected double[][] data;
>              >          >    private Properties properties = null;
>              >          >    private static String propertiesFile =
>              >          > LoadSextanteRasterImagePlugIn.getPropertiesFile();
>              >          >    private String lastPath;
>              >          >    NumberFormat cellFormat = null;
>              >          >    public static final String DEFAULT_NODATA =
>             "-9999";
>              >          >
>              >          >    public boolean execute(PlugInContext context)
>              >          >      throws Exception
>              >          >    {
>              >          >      JFileChooser fc = new JFCWithEnterAction();
>              >          >
>              >          >      fc.setFileFilter(new FileFilter() {
>              >          >        public boolean accept(File f) {
>              >          >          return (f.isDirectory()) ||
>              >          >
>               (f.getName().toLowerCase().endsWith(".asc"));
>              >          >        }
>              >          >
>              >          >        public String getDescription() {
>              >          >          return "Arc/Info ASCII Grid (.asc)";
>              >          >        }
>              >          >      });
>              >          >      this.properties = new Properties();
>              >          >      try {
>              >          >        FileInputStream fis = new
>             FileInputStream(propertiesFile);
>              >          >        this.properties.load(fis);
>              >          >        this.lastPath =
>              >          >
>              >
>             
> this.properties.getProperty(LoadSextanteRasterImagePlugIn.KEY_PATH);
>              >          >        fis.close();
>              >          >      }
>              >          >      catch (FileNotFoundException e) {
>              >          >
>              >          >
>              >
>             
> context.getWorkbenchFrame().warnUser(I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.SaveRasterImageAsImagePlugIn.File-not-found"));
>              >          >      }
>              >          >      catch (IOException e) {
>              >          >
>               context.getWorkbenchFrame().warnUser(GenericNames.ERROR);
>              >          >      }
>              >          >
>              >          >      if (this.lastPath != null) {
>              >          >        fc.setCurrentDirectory(new
>             File(this.lastPath));
>              >          >      }
>              >          >      fc.setMultiSelectionEnabled(false);
>              >          >
>              >          >      fc.setDialogTitle(getName());
>              >          >      int returnVal = fc.showSaveDialog(fc);
>              >          >      if (returnVal == 0) {
>              >          >        String ascFileName =
>              >         fc.getSelectedFile().getAbsolutePath();
>              >          >
>              >          >        if
>              >
>             (!ascFileName.toLowerCase().endsWith(".asc".toLowerCase())) {
>              >          >            ascFileName = ascFileName + ".asc";
>              >          >        }
>              >          >
>              >          >        File ascFile = new File(ascFileName);
>              >          >
>              >          >        FileOutputStream ascOut = new
>             FileOutputStream(ascFile);
>              >          >
>              >          >        RasterImageLayer rLayer =
>              >          >
>             (RasterImageLayer)LayerTools.getSelectedLayerable(context,
>              >          > RasterImageLayer.class);
>              >          >        OpenJUMPSextanteRasterLayer rstLayer = new
>              >          > OpenJUMPSextanteRasterLayer();
>              >          >        rstLayer.create(rLayer);
>              >          >
>              >          > *PrintStream o = new PrintStream(ascOut);*
>              >          > *o.println( "ncols " +
>             rLayer.getOrigImageWidth()  );
>              >          >                  //rstLayer.getNX()  );
>              >          >          o.println( "nrows " +
>             rLayer.getOrigImageHeight()  );
>              >          >                  //rstLayer.getNY() );
>              >          >          o.println( "xllcorner " +
>              >         rLayer.getEnvelope().getMinX() );
>              >          >          o.println( "yllcorner " +
>              >         rLayer.getEnvelope().getMinY());
>              >          >          o.println( "cellsize " +
>             rstLayer.getLayerCellSize() );
>              >          >          o.println( "NODATA_value " +
>             DEFAULT_NODATA  );*
>              >          >
>              >          >
>              >          >      GridWrapperNotInterpolated gwrapper = new
>              >          > GridWrapperNotInterpolated(rstLayer,
>              >         rstLayer.getLayerGridExtent());
>              >          >
>              >          >
>              >          >               int nx =
>             rstLayer.getLayerGridExtent().getNX();
>              >          >              int ny =
>             rstLayer.getLayerGridExtent().getNY();
>              >          >               for (int x = 0; x < nx; x++) {//cols
>              >          >                  for (int y = 0; y < ny; y++)
>             {//rows
>              >          >                      double value =
>              >         gwrapper.getCellValueAsFloat(x, y, 0);
>              >          >                      StringBuffer b = new
>             StringBuffer();
>              >          >                      for( int i = 0; i <
>              >         rLayer.getOrigImageWidth(); i++ )
>              >          >                      {
>              >          >                          if(
>              >         Double.isNaN(rstLayer.getNoDataValue()  )
>              >          > ) b.append( rstLayer.getNoDataValue() );
>              >          >                          else if( cellFormat
>             != null ) b.append(
>              >          > cellFormat.format( value ));
>              >          >                          else b.append(
>             cellFormat.format(
>              >         value ) );
>              >          >                          if( i <
>             rLayer.getOrigImageWidth() -1 )
>              >          > b.append(  " "  );
>              >          >                      }
>              >          >                      o.println( b );
>              >          >               }
>              >          >          }
>              >          >          o.close();
>              >          >
>              >          >        rLayer.setImageFileName(ascFileName);
>              >          >        rLayer.setNeedToKeepImage(false);
>              >          >      }
>              >          >
>              >          >      return true;
>              >          >    }
>              >          >
>              >          >
>              >          >    public void setCellFormat( NumberFormat
>             format )
>              >          >      {
>              >          >          cellFormat = format;
>              >          >      }
>              >          >
>              >          >
>              >          > *public static MultiEnableCheck
>              >         createEnableCheck(WorkbenchContext
>              >          > workbenchContext)
>              >          >    {
>              >          >      EnableCheckFactory checkFactory = new
>             EnableCheckFactory(
>              >          >        workbenchContext);
>              >          >      MultiEnableCheck multiEnableCheck = new
>             MultiEnableCheck();
>              >          >
>              >          >
>              >          >
>              >
>             
> multiEnableCheck.add(checkFactory.createExactlyNLayerablesMustBeSelectedCheck(1,
>              >          > RasterImageLayer.class));
>              >          >
>              >          >      return multiEnableCheck;*
>              >          >    }
>              >          >
>              >          > }
>              >          >
>              >          >
>              >          >
>              >
>             
> ------------------------------------------------------------------------------
>              >          > This SF.net email is sponsored by Windows:
>              >          >
>              >          > Build for Windows Store.
>              >          >
>              >          > http://p.sf.net/sfu/windows-dev2dev
>              >          >
>              >          >
>              >          >
>              >          > _______________________________________________
>              >          > Jump-pilot-devel mailing list
>              >          > Jump-pilot-devel@lists.sourceforge.net
>             <mailto:Jump-pilot-devel@lists.sourceforge.net>
>              >         <mailto:Jump-pilot-devel@lists.sourceforge.net
>             <mailto:Jump-pilot-devel@lists.sourceforge.net>>
>              >          >
>             https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>              >          >
>              >
>              >
>             
> ------------------------------------------------------------------------------
>              >         This SF.net email is sponsored by Windows:
>              >
>              >         Build for Windows Store.
>              >
>              > http://p.sf.net/sfu/windows-dev2dev
>              >         _______________________________________________
>              >         Jump-pilot-devel mailing list
>              > Jump-pilot-devel@lists.sourceforge.net
>             <mailto:Jump-pilot-devel@lists.sourceforge.net>
>              >         <mailto:Jump-pilot-devel@lists.sourceforge.net
>             <mailto:Jump-pilot-devel@lists.sourceforge.net>>
>              > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>              >
>              >
>              >
>              >
>              >
>              >
>             
> ------------------------------------------------------------------------------
>              > This SF.net email is sponsored by Windows:
>              >
>              > Build for Windows Store.
>              >
>              > http://p.sf.net/sfu/windows-dev2dev
>              >
>              >
>              >
>              > _______________________________________________
>              > Jump-pilot-devel mailing list
>              > Jump-pilot-devel@lists.sourceforge.net
>             <mailto:Jump-pilot-devel@lists.sourceforge.net>
>              > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>              >
>
>             
> ------------------------------------------------------------------------------
>             This SF.net email is sponsored by Windows:
>
>             Build for Windows Store.
>
>             http://p.sf.net/sfu/windows-dev2dev
>             _______________________________________________
>             Jump-pilot-devel mailing list
>             Jump-pilot-devel@lists.sourceforge.net
>             <mailto:Jump-pilot-devel@lists.sourceforge.net>
>             https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>
>
>
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to