Giter Site home page Giter Site logo

Comments (2)

vincentsarago avatar vincentsarago commented on June 3, 2024

Thanks @j08lue 🙏

count - what is that for weighted data? Count of all finite values where weights are non-zero? Or the sum of the weights?

I would sum the weights I think, I think it's the current behaviour: https://github.com/cogeotiff/rio-tiler/blob/main/rio_tiler/utils.py#L139

min, max, minority, majority, unique and also histogram - we should probably only take values into account where weights are non-zero.

so in

array = data[b] * coverage
else:
array = data[b]
count = array.count() if coverage is None else coverage.sum()
if valid_pixels:
majority = float(keys[counts.tolist().index(counts.max())].tolist())
minority = float(keys[counts.tolist().index(counts.min())].tolist())
else:
majority = numpy.nan
minority = numpy.nan
output.append(
{
"min": float(data[b].min()),
"max": float(data[b].max()),
"mean": float(array.mean()),
"count": float(count),
"sum": float(array.sum()),
"std": float(array.std()),
"median": float(numpy.ma.median(array)),
"majority": majority,
"minority": minority,
"unique": float(counts.size),
**dict(zip(percentiles_names, percentiles_values)),
"histogram": histogram,
**info_px,
}
)
we should use array instead of data

from rio-tiler.

j08lue avatar j08lue commented on June 3, 2024

I would sum the weights

Yes, that must be the right way.

we should use array instead of data

Hmm, no, I think we need to get rid of multiplying coverage with data for all stats and only do that for mean.

What I meant was to make sure we expand the mask of data by the points where coverage equals zero. Since we compress that array (take out masked elements), we would then also exclude pixels with no coverage.

keys, counts = numpy.unique(data[b].compressed(), return_counts=True)

Ideally, data.mask and coverage == 0 should be identical anyways, if data.mask is the rasterized query polygon and coverage is a refined version of the mask around the edges. But we need to be extra sure. Like

data.mask[:, coverage == 0] = True

from rio-tiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.