Skip to content

Commit

Permalink
Convert Geometry.Point API code snippets from JS to Py
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 571353753
  • Loading branch information
jdbcode authored and copybara-github committed Oct 6, 2023
1 parent 50e32cc commit 6443b8a
Show file tree
Hide file tree
Showing 30 changed files with 964 additions and 0 deletions.
30 changes: 30 additions & 0 deletions samples/python/apidocs/ee_geometry_point_area.py
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]
31 changes: 31 additions & 0 deletions samples/python/apidocs/ee_geometry_point_bounds.py
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]
31 changes: 31 additions & 0 deletions samples/python/apidocs/ee_geometry_point_buffer.py
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]
31 changes: 31 additions & 0 deletions samples/python/apidocs/ee_geometry_point_centroid.py
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]
34 changes: 34 additions & 0 deletions samples/python/apidocs/ee_geometry_point_containedin.py
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]
34 changes: 34 additions & 0 deletions samples/python/apidocs/ee_geometry_point_contains.py
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]
33 changes: 33 additions & 0 deletions samples/python/apidocs/ee_geometry_point_convexhull.py
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]
30 changes: 30 additions & 0 deletions samples/python/apidocs/ee_geometry_point_coordinates.py
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]
37 changes: 37 additions & 0 deletions samples/python/apidocs/ee_geometry_point_difference.py
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]
34 changes: 34 additions & 0 deletions samples/python/apidocs/ee_geometry_point_disjoint.py
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]
31 changes: 31 additions & 0 deletions samples/python/apidocs/ee_geometry_point_dissolve.py
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]
Loading

0 comments on commit 6443b8a

Please sign in to comment.