NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi again Desiree, Desiree Hilbring wrote: > > Hi Ugo, > > I tried to implement your hints: > > This is where the array gets created: > > public void makeArray2() { > double[][] coords = new double[2][east.length]; > coords[0] = new double[east.length]; > coords[1] = new double[north.length]; > for (int i=0;i<coords[0].length;i++) { > coords[0][i]=east[i]; > coords[1][i]=north[i]; > } > > for (int j=0;j<coords[0].length;j++) { > System.out.println("e "+coords[0][j]); > } > for (int j=0;j<coords[1].length;j++) { > System.out.println("n "+coords[1][j]); > } > } > Not quite. Samples must be double[ 2 ][ east.length * north.length ] You've got east.length * north.length in your grid, remember. > The arrays look similar to the one you mailed me, I even changed my north > and east values in the RealTupleType, because GISterm looked somehow > upside down (spiegelverkehrt?) in the screenshots to ArcView. Yes, the fact that your're seeing the mirror image has to do with the order of your samples. > > I am getting a VisAD Exception which sais, samples are null, is this the > coordinates array with the x and y values or the height array? And how do > I have to specify the height array, does it include the missing values or > not? I can't tell. You could send in the complete error. But from above I'd guess the problem is in the domain samples (aren't there too few of them?). > > Here is the VisAD stuff: > > public void makeSurface() { > > > eastValues = RealType.getRealType("eastValues"); > northValues = RealType.getRealType("northValues"); > heightValues = RealType.getRealType("heightValues"); > > try { > //domain_tuple = new RealTupleType(northValues,eastValues); > domain_tuple = new RealTupleType(eastValues,northValues); > // Create a FunctionType (domain_tuple -> range_tuple); > func_en_h = new FunctionType(domain_tuple, heightValues); > > domain_set = new > Gridded2DDoubleSet(domain_tuple,coords,nRows,nCols); > > // Get the Set samples to facilitate the calculations > float[][] set_samples = domain_set.getSamples( true ); > > // We create another array, with the same number of elements > of > // altitude and temperature, but organized as > float[][] flat_samples = new float[1][nCols * nRows]; > > // ...and then we fill our 'flat' array with the generated > values > // by looping over NCOLS and NROWS > // specifiy height > for(int c = 0; c < nCols; c++){ > for(int r = 0; r < nRows; r++){ > //flat_samples[0][c*nRows+r] = height[c*nRows+r]; > flat_samples[0][c*nRows+r] = heightNaN[c*nRows+r]; > } > } > > /* > for (int n=0;n<height.length;n++) { > flat_samples[0][n]=height[n]; > } > */ > for(int c = 0; c < nRows; c++){ > for(int r = 0; r < nCols; r++){ > System.out.println(c*nRows+r); > // ursprüngliches quadratische x.y.z grid > flat_samples[0][c*nRows+r] = height[c*nRows+r]; > // nicht quadratische gridvisadlayer grid > //flat_samples[0][c*nCols+r] = height[c*nCols+r]; > } > } > > // Create a FlatField > // Use FlatField(FunctionType type, Set domain_set) > vals_ff = new FlatField( func_en_h, domain_set); > > // ...and put the values above into it > // Note the argument false, meaning that the array won't be > copied > vals_ff.setSamples( flat_samples , false ); > > // Create Display and its maps > // A 2D display > display = new DisplayImplJ3D("display1"); > > // Create the ScalarMaps: latitude to XAxis, longitude to > YAxis and > // altitude to RGB and temperature to IsoContour > // Use ScalarMap(ScalarType scalar, DisplayRealType > display_scalar) > eastMap = new ScalarMap( eastValues, Display.YAxis ); > northMap = new ScalarMap( northValues, Display.XAxis ); > heightMap = new ScalarMap(heightValues,Display.ZAxis); > > eastMap.setRange(-1.0, 1.0); > northMap.setRange(-1.0, 1.0); > heightMap.setRange(-1.0, 1.0); > > > // Add maps to display > display.addMap( eastMap ); > display.addMap( northMap ); > display.addMap( heightMap ); > > // Create a data reference and set the FlatField as our data > data_ref = new DataReferenceImpl("data_ref"); > data_ref.setData( vals_ff ); > renderer = new DefaultRendererJ3D(); > > // Add reference to display > display.addReferences(renderer,data_ref); > //display.addReference( data_ref ); > display.addDisplayListener(listener); > > } > catch (VisADException ve) { > System.out.println("VisADException"); > System.out.println(ve.getMessage()); > } > catch (RemoteException re) { > System.out.println("RemoteExcpetion"); > System.out.println(re.getMessage()); > } > } > > Thanks for your help Desiree > I think you're getting "null" from coords, which have the wrong size. Cheers, Ugo
visad
archives: