-
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.Point API code snippets from JS to Py
PiperOrigin-RevId: 571353753
- Loading branch information
1 parent
50e32cc
commit 6443b8a
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_point_area] | ||
# Define a Point object. | ||
point = ee.Geometry.Point(-122.082, 37.42) | ||
|
||
# Apply the area method to the Point object. | ||
point_area = point.area(maxError=1) | ||
|
||
# Print the result. | ||
display('point.area(...) =', point_area) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(point, {'color': 'black'}, 'Geometry [black]: point') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_point_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_point_bounds] | ||
# Define a Point object. | ||
point = ee.Geometry.Point(-122.082, 37.42) | ||
|
||
# Apply the bounds method to the Point object. | ||
point_bounds = point.bounds() | ||
|
||
# Print the result. | ||
display('point.bounds(...) =', point_bounds) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(point, {'color': 'black'}, 'Geometry [black]: point') | ||
m.add_ee_layer(point_bounds, {'color': 'red'}, 'Result [red]: point.bounds') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_point_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_point_buffer] | ||
# Define a Point object. | ||
point = ee.Geometry.Point(-122.082, 37.42) | ||
|
||
# Apply the buffer method to the Point object. | ||
point_buffer = point.buffer(distance=100) | ||
|
||
# Print the result. | ||
display('point.buffer(...) =', point_buffer) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(point, {'color': 'black'}, 'Geometry [black]: point') | ||
m.add_ee_layer(point_buffer, {'color': 'red'}, 'Result [red]: point.buffer') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_point_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_point_centroid] | ||
# Define a Point object. | ||
point = ee.Geometry.Point(-122.082, 37.42) | ||
|
||
# Apply the centroid method to the Point object. | ||
point_centroid = point.centroid(maxError=1) | ||
|
||
# Print the result. | ||
display('point.centroid(...) =', point_centroid) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(point, {'color': 'black'}, 'Geometry [black]: point') | ||
m.add_ee_layer(point_centroid, {'color': 'red'}, 'Result [red]: point.centroid') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_point_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_point_containedin] | ||
# Define a Point object. | ||
point = ee.Geometry.Point(-122.082, 37.42) | ||
|
||
# Define other inputs. | ||
input_geom = ee.Geometry.BBox(-122.085, 37.415, -122.075, 37.425) | ||
|
||
# Apply the containedIn method to the Point object. | ||
point_contained_in = point.containedIn(right=input_geom, maxError=1) | ||
|
||
# Print the result. | ||
display('point.containedIn(...) =', point_contained_in) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(point, {'color': 'black'}, 'Geometry [black]: point') | ||
m.add_ee_layer(input_geom, {'color': 'blue'}, 'Parameter [blue]: input_geom') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_point_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_point_contains] | ||
# Define a Point object. | ||
point = ee.Geometry.Point(-122.082, 37.42) | ||
|
||
# Define other inputs. | ||
input_geom = ee.Geometry.BBox(-122.085, 37.415, -122.075, 37.425) | ||
|
||
# Apply the contains method to the Point object. | ||
point_contains = point.contains(right=input_geom, maxError=1) | ||
|
||
# Print the result. | ||
display('point.contains(...) =', point_contains) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(point, {'color': 'black'}, 'Geometry [black]: point') | ||
m.add_ee_layer(input_geom, {'color': 'blue'}, 'Parameter [blue]: input_geom') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_point_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_point_convexhull] | ||
# Define a Point object. | ||
point = ee.Geometry.Point(-122.082, 37.42) | ||
|
||
# Apply the convexHull method to the Point object. | ||
point_convex_hull = point.convexHull(maxError=1) | ||
|
||
# Print the result. | ||
display('point.convexHull(...) =', point_convex_hull) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(point, {'color': 'black'}, 'Geometry [black]: point') | ||
m.add_ee_layer( | ||
point_convex_hull, {'color': 'red'}, 'Result [red]: point.convexHull' | ||
) | ||
m | ||
# [END earthengine__apidocs__ee_geometry_point_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_point_coordinates] | ||
# Define a Point object. | ||
point = ee.Geometry.Point(-122.082, 37.42) | ||
|
||
# Apply the coordinates method to the Point object. | ||
point_coordinates = point.coordinates() | ||
|
||
# Print the result. | ||
display('point.coordinates(...) =', point_coordinates) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(point, {'color': 'black'}, 'Geometry [black]: point') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_point_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_point_difference] | ||
# Define a Point object. | ||
point = ee.Geometry.Point(-122.082, 37.42) | ||
|
||
# Define other inputs. | ||
input_geom = ee.Geometry.BBox(-122.085, 37.415, -122.075, 37.425) | ||
|
||
# Apply the difference method to the Point object. | ||
point_difference = point.difference(right=input_geom, maxError=1) | ||
|
||
# Print the result. | ||
display('point.difference(...) =', point_difference) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(point, {'color': 'black'}, 'Geometry [black]: point') | ||
m.add_ee_layer(input_geom, {'color': 'blue'}, 'Parameter [blue]: input_geom') | ||
m.add_ee_layer( | ||
point_difference, {'color': 'red'}, 'Result [red]: point.difference' | ||
) | ||
m | ||
# [END earthengine__apidocs__ee_geometry_point_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_point_disjoint] | ||
# Define a Point object. | ||
point = ee.Geometry.Point(-122.082, 37.42) | ||
|
||
# Define other inputs. | ||
input_geom = ee.Geometry.BBox(-122.085, 37.415, -122.075, 37.425) | ||
|
||
# Apply the disjoint method to the Point object. | ||
point_disjoint = point.disjoint(right=input_geom, maxError=1) | ||
|
||
# Print the result. | ||
display('point.disjoint(...) =', point_disjoint) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(point, {'color': 'black'}, 'Geometry [black]: point') | ||
m.add_ee_layer(input_geom, {'color': 'blue'}, 'Parameter [blue]: input_geom') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_point_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_point_dissolve] | ||
# Define a Point object. | ||
point = ee.Geometry.Point(-122.082, 37.42) | ||
|
||
# Apply the dissolve method to the Point object. | ||
point_dissolve = point.dissolve(maxError=1) | ||
|
||
# Print the result. | ||
display('point.dissolve(...) =', point_dissolve) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer(point, {'color': 'black'}, 'Geometry [black]: point') | ||
m.add_ee_layer(point_dissolve, {'color': 'red'}, 'Result [red]: point.dissolve') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_point_dissolve] |
Oops, something went wrong.