-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #553 from 3r3n-n/add-feature-histogram-function
add feature_histogram() function
- Loading branch information
Showing
4 changed files
with
327 additions
and
5 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "c8e4fe74-fe9f-4cab-a0b0-b7a9a11ebd3b", | ||
"metadata": {}, | ||
"source": [ | ||
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/giswqs/geemap/blob/master/examples/notebooks/79_chart_histogram.ipynb)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "5f731179-ca4f-43be-88e3-71801aa4b08f", | ||
"metadata": {}, | ||
"source": [ | ||
"Uncomment the following line to install [geemap](https://geemap.org) if needed." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "32fb1f00-46b6-4dc6-be1f-948a627b74df", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# !pip install geemap" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "956a608f-829c-4bd2-950a-4019c4b5a686", | ||
"metadata": {}, | ||
"source": [ | ||
"Install the necessary libraries." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0b9c023d-0fcc-4911-b08a-708900a67af9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import ee\n", | ||
"import geemap\n", | ||
"import geemap.chart as chart" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "d5436f2d-721c-405e-85fd-ff3d49788ff1", | ||
"metadata": {}, | ||
"source": [ | ||
"Initialize GEE." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e9c39bdc-b8c1-468a-878c-83e5a1d61a64", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ee.Initialize()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ebcba2d6-8a64-48d6-bf7e-d7f8ac2ce735", | ||
"metadata": {}, | ||
"source": [ | ||
"Set the data and plot options." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "fbe7052a-be33-48ae-83c9-d65ce902c4bc", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"source = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands()\n", | ||
"region = ee.Geometry.Rectangle(-123.41, 40.43, -116.38, 45.14)\n", | ||
"my_sample = source.sample(region, 5000)\n", | ||
"property = '07_ppt'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "92ff81dd-ef42-4e4c-ac9c-0cc7c20a5631", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"options = {\"title\": 'July Precipitation Distribution for NW USA',\n", | ||
" \"xlabel\": 'Precipitation (mm)',\n", | ||
" \"ylabel\": 'Pixel count',\n", | ||
" \"colors\": ['#1d6b99']\n", | ||
" }" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "a337adcf-10ff-470b-b7eb-93b767215158", | ||
"metadata": {}, | ||
"source": [ | ||
"Generate histogram with default number of bins:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "304b9c4b-5eb5-4ace-8903-340ad03e2d67", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"chart.feature_histogram(my_sample, property, **options)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7dd9d9fa-7a68-4eb8-a468-a703798c0cc6", | ||
"metadata": {}, | ||
"source": [ | ||
"Generate histogram and set a maximum number of bins:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e64a479e-5805-4ef9-85a5-63e5d4089e3e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"chart.feature_histogram(my_sample, property, maxBuckets = 30, **options)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "78306cd7-17d5-4308-80ed-e6871c37a113", | ||
"metadata": {}, | ||
"source": [ | ||
"Generate histogram and set a minimum bin size:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b460444e-7c99-4317-98e7-6165e933e58a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"chart.feature_histogram(my_sample, property, minBucketWidth = 0.5, **options)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "a6302898-bd41-4603-898a-c74858687b53", | ||
"metadata": {}, | ||
"source": [ | ||
"Generate histogram, set a maximum number of bins and a minimum bin size:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2b3a462b-d4f6-4061-acf3-0c26ef718a12", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"chart.feature_histogram(my_sample, property, minBucketWidth = 3, maxBuckets = 30, **options)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters