# Re: missing points break up surface

```Hi Ugo,

Your problem is actually somewhat tricky, sorry to say.
A connected surface display is generated using the topology
of the Field's domain Set: the topology specifies which
samples are neighbors that should be connected together to
form little triangles or quads.  Missing values delete points
from the topology, so the little triangles and quads cannot
be formed.  I have experimented in the past with algorithms
that try to only draw those triangles or quads for which all
vertices are valid (non-missing) but this can be very
misleading, as some non-missing points are then not visible.
Although it is not very pretty, rendering as isolated points
is the most reliable way to show exacty which points are
missing.

Of course, you'd like to find a work around, and there are
a few possibilities:

1. Render as isolated points, but use the following code
to make the points larger:

GraphicsModeControl mode = display1.getGraphicsModeControl();
mode.setPointSize(5.0f);

With the right size, the large points almost look like a
surface.

2. Reconstruct an irregular topology using the non-missing
points, as follows:

float[][] set_samples = domainSet.getSamples();
// count non-missing samples
int len = 0;
for (int i=0; i<LengthX*LengthY; i++) {
if (samples[i] == samples[i]) len++; // not missing
}
FlatField new_ff = null;
if (len > 0) {
float[][] new_set_samples = new float[len];
double[][] new_samples = new double[len];
for (int i=0; i<LengthX*LengthY; i++) {
if (samples[i] == samples[i]) {
new_set_samples[i] = set_samples[i];
new_set_samples[i] = set_samples[i];
new_samples[i] = samples[i];
new_samples[i] = samples[i];
len++;
}
}
Set new_domainSet = new Irregular2DSet( Domain, new_set_samples );
new_ff = new FlatField( overfunc, new_domainSet );
new_ff.setSamples(new_samples);
}
// now new_ff can be used in place of ff
// if all points are missing, new_ff == null

This will draw a surface that just spans across the missing points.
Users will see no indication of where the missing points are, but
in some cases they may not want to.

3. If you want to color the missing points black, then you have
to estimate the elevation of the surface at the missing points.  One
way to do this is to resample the new_ff Field to your original Set,
by adding the following code to my code above:

FlatField re_ff = (FlatField) new_ff.resample(domainSet,
Data.WEIGHTED_AVERAGE, Data.NO_ERRORS);
double[][] re_samples = re_ff.getValues();
for (int i=0; i<LengthX*LengthY; i++) {
if (samples[i] != samples[i]) {
samples[i] = re_samples[i];
samples[i] = temperature_mapped_to_black;
}
}
ff.setSamples( samples );

If there are lots of missing points, then ff will still have
missing points (since the irregular topology of the domain set
of new_ff will not "cover" the domain of ff).

So you may want to try a more robust way of estimating elevations
at missing points.  We have an old Fortran (!) function for doing
this at:

ftp://iris.ssec.wisc.edu/fbarn/fbarn.f

and there are other algorithms.

Sorry that I don't have a more definitive answer for you.  What
you want involves estimating values for missing values, and this
is just a deep issue.

Since I don't have your data or ArcGridReader I was not able to test
my code examples, so there may be a few bugs.  Please let me know if
you have problems or further questions.

Cheers,
Bill

----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
whibbard@xxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html

```
• 1999 messages navigation, sorted by:
• Search the `visad` archives: