Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add feature_histogram() function #553

Merged
merged 4 commits into from
Jul 5, 2021

Conversation

3r3n-n
Copy link
Contributor

@3r3n-n 3r3n-n commented Jul 2, 2021

Hi!

I would like to propose this implementation for the chart.feature_histogram() function (addressing issue #339).

This implementation was manually and visually tested against the GEE JavaScript API example (see images below), Tooltips also work.

It was necessary to import the math library in order to implement the nextPowerOf2() function that is required for adjusting the value of maxBuckets and minBucketWidth in a similar way to what the GEE documentation says.

The start_bins and end_bins variables were added to make nicer midpoint offsets and make them as similar as possible to the Google Charts histogram output.

This function takes the same input arguments as the GEE JavaScript API equivalent... except for maxRaw. I have not found a way to incorporate an equivalent parameter with bqplot. So far, I have not found a case using maxRaw in the JS API function where the same histogram cannot be reproduced with this function in jupyter (without any maxRaw-like input). From the information available in the GEE documentation, I understand that maxRaw only affects the output when calculating a reducer value (but I might be wrong). So the current version of this proposal considers that maxRaw is not necessary for displaying the histogram in Jupyter.

I would like to know if this approach is adequate or if there are some other things that I should take care of, in order to be considered for merge.

These changes passed tox tests for python 3.5, 3.6, 3.7, 3.8.

micro-demo

maxBuckets = None, minBucketWidth = None

JavaScript

js

Python (this function)

py

maxBuckets = None, minBucketWidth = 0.5

JavaScript

js

Python (this function)

py

maxBuckets = 30, minBucketWidth = None

JavaScript

js

Python (this function)

py

maxBuckets = 30, minBucketWidth = 3

JavaScript

js
Python (this function)

py

@giswqs
Copy link
Member

giswqs commented Jul 3, 2021

Excellent work! Could you also add a notebook example (e.g., 79_chart_histogram.ipynb) and put it under https://github.com/giswqs/geemap/tree/master/examples/notebooks. That would be very helpful for geemap users.

@3r3n-n
Copy link
Contributor Author

3r3n-n commented Jul 5, 2021

Done :) Just added the notebook example.

@giswqs
Copy link
Member

giswqs commented Jul 5, 2021

@3r3n-n Looks great! Thank you very much for your time and efforts. Much appreciated.

@giswqs giswqs merged commit 53bca28 into gee-community:master Jul 5, 2021
giswqs added a commit that referenced this pull request Jul 5, 2021
@giswqs
Copy link
Member

giswqs commented Jul 5, 2021

The notebook example has been added to the website https://geemap.org/notebooks/79_chart_histogram

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants