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 Bill, .... > > In the code below I read the image and gain a flatField, which is > > already read in the wrong position (the imageposition 0-2000,0-2000). > > I do a resampling which obviously does not what I need, but I assume it > > is there that something should happen. > > > > Set domainSet2 = new Linear2DSet(domain, 1632840.5, 1634840.5, > > (int) (1634840.5 - 1632840.5), 5097079.5, 5099079.5, > > (int) (5099079.5 - 5097079.5)); > > imageField.resample(domainSet2); > > This should be: > > imageField = imageField.resample(domainSet2); > > Because the domain RealTupleType for imageField comes > from DefaultFamily.open(), it will be easier to > resample demField to domainSet2 than to resample > imageField to the domain Set of demField. To do this, > construct domainTuple (for demField) using: > > RealTupleType domainTuple > new RealTupleType(easting, northing, coord_sys, null); > > where coord_sys is an instance of your new CoordinateSystem > extension class that defines the mappings of > (easting, northing) to and from the reference (x, y) > (the coordinates of imageField). I still miss something. The dem is in the right coordinate system, whereas the image is not referenced in the geographic space. So I would expect to do the inverse of what you are telling me, since I want to map the image into the dem space and not the dem space into the image that is placed in the origin of its system. I try explain better throught some code how I tried to follow you suggestions: I first read the dem data and create the types for it: /* * get the elevation map */ easting = RealType.getRealType("easting", SI.meter, null); northing = RealType.getRealType("northing", SI.meter, null); The image is in 1 meter resolution. The GeoToImageCoordinateSystem contains simply the ubtraction or addition of the west and south to put the image in the right portion of world (and back). GeoToImageCoordinateSystem iCord = new GeoToImageCoordinateSystem( RealTupleType.SpatialCartesian2DTuple); RealTupleType domainTuple = new RealTupleType(easting, northing, iCord, null); elevation = RealType.getRealType("elevation", SI.meter, null); FunctionType funcDomainElevation = new FunctionType(domainTuple, elevation); Set demDomainSet = new Linear2DSet(domainTuple, dataWindow.getWest(), dataWindow.getEast(), NCOLS, dataWindow.getSouth(), dataWindow .getNorth(), NROWS); . . get the samples from a matrix or wherever . . FlatField demField = new FlatField(funcDomainElevation, demDomainSet); demField.setSamples(flatSamples); eastingMap = new ScalarMap(easting, Display.XAxis); northingMap = new ScalarMap(northing, Display.YAxis); elevationMap = new ScalarMap(elevation, Display.ZAxis); Passing that flatfield to the display at this point, makes it show up properly. Now I step over to the image: /* * get the jpg foto file */ FlatField imageField = null; try { imageField = (FlatField) new DefaultFamily("dflt").open(new URL( "file:/home/moovida/microsuap/059130_2_1.jpg")); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // compute ScalarMaps from type components FunctionType functionType = (FunctionType) imageField.getType(); RealTupleType domain = functionType.getDomain(); RealTupleType range = (RealTupleType) functionType.getRange(); here I get the set to which the dem filed should be resampled: Set imageDomainSet = imageField.getDomainSet(); x = (RealType) domain.getComponent(0); y = (RealType) domain.getComponent(1); redType = (RealType) range.getComponent(0); greenType = (RealType) range.getComponent(1); blueType = (RealType) range.getComponent(2); rowMap = new ScalarMap(x, Display.XAxis); colMap = new ScalarMap(y, Display.YAxis); redMap = new ScalarMap(redType, Display.Red); greenMap = new ScalarMap(greenType, Display.Green); blueMap = new ScalarMap(blueType, Display.Blue); display = new DisplayImplJ3D("display"); // The display display.addMap(rowMap); display.addMap(colMap); display.addMap(elevationMap); display.addMap(redMap); display.addMap(greenMap); display.addMap(blueMap); now create the merged flatfield Field newDemfield = demField.resample(imageDomainSet); Field endField = FieldImpl.combine(new Field[] { imageField, newDemField }); DataReferenceImpl dataReference = new DataReferenceImpl("dataref"); dataReference.setData(demField); display.addReference(dataReference); This doesn't show up anything. I thought the resample would have used the adapted CoordinateSystem for resampling, but it never passes through the toReference and fromReference methods of the GeoToImageCoordinateSystem. I'm clueless... Andrea ============================================================================== To unsubscribe visad, visit: http://www.unidata.ucar.edu/mailing-list-delete-form.html ==============================================================================
visad
archives: