-
Notifications
You must be signed in to change notification settings - Fork 747
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Geometry.BBox API code snippets from JS to Py
PiperOrigin-RevId: 563240005
- Loading branch information
1 parent
1c9504d
commit 113fb78
Showing
30 changed files
with
964 additions
and
0 deletions.
There are no files selected for viewing
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,30 @@ | ||
# Copyright 2023 The Google Earth Engine Community Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START earthengine__apidocs__ee_geometry_bbox_area] | ||
# Define a BBox object. | ||
bbox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43) | ||
|
||
# Apply the area method to the BBox object. | ||
bbox_area = bbox.area(maxError=1) | ||
|
||
# Print the result. | ||
display('bBox.area(...) =', bbox_area) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(bbox, {'color': 'black'}, 'Geometry [black]: bBox') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_bbox_area] |
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,31 @@ | ||
# Copyright 2023 The Google Earth Engine Community Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START earthengine__apidocs__ee_geometry_bbox_bounds] | ||
# Define a BBox object. | ||
bbox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43) | ||
|
||
# Apply the bounds method to the BBox object. | ||
bbox_bounds = bbox.bounds() | ||
|
||
# Print the result. | ||
display('bBox.bounds(...) =', bbox_bounds) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(bbox, {'color': 'black'}, 'Geometry [black]: bBox') | ||
m.add_ee_layer(bbox_bounds, {'color': 'red'}, 'Result [red]: bBox.bounds') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_bbox_bounds] |
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,31 @@ | ||
# Copyright 2023 The Google Earth Engine Community Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START earthengine__apidocs__ee_geometry_bbox_buffer] | ||
# Define a BBox object. | ||
bbox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43) | ||
|
||
# Apply the buffer method to the BBox object. | ||
bbox_buffer = bbox.buffer(distance=100) | ||
|
||
# Print the result. | ||
display('bBox.buffer(...) =', bbox_buffer) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(bbox, {'color': 'black'}, 'Geometry [black]: bBox') | ||
m.add_ee_layer(bbox_buffer, {'color': 'red'}, 'Result [red]: bBox.buffer') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_bbox_buffer] |
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,31 @@ | ||
# Copyright 2023 The Google Earth Engine Community Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START earthengine__apidocs__ee_geometry_bbox_centroid] | ||
# Define a BBox object. | ||
bbox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43) | ||
|
||
# Apply the centroid method to the BBox object. | ||
bbox_centroid = bbox.centroid(maxError=1) | ||
|
||
# Print the result. | ||
display('bBox.centroid(...) =', bbox_centroid) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(bbox, {'color': 'black'}, 'Geometry [black]: bBox') | ||
m.add_ee_layer(bbox_centroid, {'color': 'red'}, 'Result [red]: bBox.centroid') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_bbox_centroid] |
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,34 @@ | ||
# Copyright 2023 The Google Earth Engine Community Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START earthengine__apidocs__ee_geometry_bbox_containedin] | ||
# Define a BBox object. | ||
bbox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43) | ||
|
||
# Define other inputs. | ||
input_geom = ee.Geometry.BBox(-122.085, 37.415, -122.075, 37.425) | ||
|
||
# Apply the containedIn method to the BBox object. | ||
bbox_contained_in = bbox.containedIn(right=input_geom, maxError=1) | ||
|
||
# Print the result. | ||
display('bBox.containedIn(...) =', bbox_contained_in) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(bbox, {'color': 'black'}, 'Geometry [black]: bBox') | ||
m.add_ee_layer(input_geom, {'color': 'blue'}, 'Parameter [blue]: input_geom') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_bbox_containedin] |
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,34 @@ | ||
# Copyright 2023 The Google Earth Engine Community Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START earthengine__apidocs__ee_geometry_bbox_contains] | ||
# Define a BBox object. | ||
bbox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43) | ||
|
||
# Define other inputs. | ||
input_geom = ee.Geometry.BBox(-122.085, 37.415, -122.075, 37.425) | ||
|
||
# Apply the contains method to the BBox object. | ||
bbox_contains = bbox.contains(right=input_geom, maxError=1) | ||
|
||
# Print the result. | ||
display('bBox.contains(...) =', bbox_contains) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(bbox, {'color': 'black'}, 'Geometry [black]: bBox') | ||
m.add_ee_layer(input_geom, {'color': 'blue'}, 'Parameter [blue]: input_geom') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_bbox_contains] |
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,33 @@ | ||
# Copyright 2023 The Google Earth Engine Community Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START earthengine__apidocs__ee_geometry_bbox_convexhull] | ||
# Define a BBox object. | ||
bbox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43) | ||
|
||
# Apply the convexHull method to the BBox object. | ||
bbox_convex_hull = bbox.convexHull(maxError=1) | ||
|
||
# Print the result. | ||
display('bBox.convexHull(...) =', bbox_convex_hull) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(bbox, {'color': 'black'}, 'Geometry [black]: bBox') | ||
m.add_ee_layer( | ||
bbox_convex_hull, {'color': 'red'}, 'Result [red]: bBox.convexHull' | ||
) | ||
m | ||
# [END earthengine__apidocs__ee_geometry_bbox_convexhull] |
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,30 @@ | ||
# Copyright 2023 The Google Earth Engine Community Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START earthengine__apidocs__ee_geometry_bbox_coordinates] | ||
# Define a BBox object. | ||
bbox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43) | ||
|
||
# Apply the coordinates method to the BBox object. | ||
bbox_coordinates = bbox.coordinates() | ||
|
||
# Print the result. | ||
display('bBox.coordinates(...) =', bbox_coordinates) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(bbox, {'color': 'black'}, 'Geometry [black]: bBox') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_bbox_coordinates] |
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,37 @@ | ||
# Copyright 2023 The Google Earth Engine Community Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START earthengine__apidocs__ee_geometry_bbox_difference] | ||
# Define a BBox object. | ||
bbox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43) | ||
|
||
# Define other inputs. | ||
input_geom = ee.Geometry.BBox(-122.085, 37.415, -122.075, 37.425) | ||
|
||
# Apply the difference method to the BBox object. | ||
bbox_difference = bbox.difference(right=input_geom, maxError=1) | ||
|
||
# Print the result. | ||
display('bBox.difference(...) =', bbox_difference) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(bbox, {'color': 'black'}, 'Geometry [black]: bBox') | ||
m.add_ee_layer(input_geom, {'color': 'blue'}, 'Parameter [blue]: input_geom') | ||
m.add_ee_layer( | ||
bbox_difference, {'color': 'red'}, 'Result [red]: bBox.difference' | ||
) | ||
m | ||
# [END earthengine__apidocs__ee_geometry_bbox_difference] |
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,34 @@ | ||
# Copyright 2023 The Google Earth Engine Community Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START earthengine__apidocs__ee_geometry_bbox_disjoint] | ||
# Define a BBox object. | ||
bbox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43) | ||
|
||
# Define other inputs. | ||
input_geom = ee.Geometry.BBox(-122.085, 37.415, -122.075, 37.425) | ||
|
||
# Apply the disjoint method to the BBox object. | ||
bbox_disjoint = bbox.disjoint(right=input_geom, maxError=1) | ||
|
||
# Print the result. | ||
display('bBox.disjoint(...) =', bbox_disjoint) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(bbox, {'color': 'black'}, 'Geometry [black]: bBox') | ||
m.add_ee_layer(input_geom, {'color': 'blue'}, 'Parameter [blue]: input_geom') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_bbox_disjoint] |
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,31 @@ | ||
# Copyright 2023 The Google Earth Engine Community Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START earthengine__apidocs__ee_geometry_bbox_dissolve] | ||
# Define a BBox object. | ||
bbox = ee.Geometry.BBox(-122.09, 37.42, -122.08, 37.43) | ||
|
||
# Apply the dissolve method to the BBox object. | ||
bbox_dissolve = bbox.dissolve(maxError=1) | ||
|
||
# Print the result. | ||
display('bBox.dissolve(...) =', bbox_dissolve) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(bbox, {'color': 'black'}, 'Geometry [black]: bBox') | ||
m.add_ee_layer(bbox_dissolve, {'color': 'red'}, 'Result [red]: bBox.dissolve') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_bbox_dissolve] |
Oops, something went wrong.