-
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.MultiLineString API code snippets from JS to Py
PiperOrigin-RevId: 563213100
- Loading branch information
1 parent
78dd374
commit 2ec9a26
Showing
31 changed files
with
1,210 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
samples/python/apidocs/ee_geometry_multilinestring_area.py
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,35 @@ | ||
# 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_multilinestring_area] | ||
# Define a MultiLineString object. | ||
multilinestring = ee.Geometry.MultiLineString([ | ||
[[-122.088, 37.418], [-122.086, 37.422], [-122.082, 37.418]], | ||
[[-122.087, 37.416], [-122.083, 37.416], [-122.082, 37.419]], | ||
]) | ||
|
||
# Apply the area method to the MultiLineString object. | ||
multilinestring_area = multilinestring.area(maxError=1) | ||
|
||
# Print the result. | ||
display('multilinestring.area(...) =', multilinestring_area) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer( | ||
multilinestring, {'color': 'black'}, 'Geometry [black]: multilinestring' | ||
) | ||
m | ||
# [END earthengine__apidocs__ee_geometry_multilinestring_area] |
40 changes: 40 additions & 0 deletions
40
samples/python/apidocs/ee_geometry_multilinestring_bounds.py
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,40 @@ | ||
# 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_multilinestring_bounds] | ||
# Define a MultiLineString object. | ||
multilinestring = ee.Geometry.MultiLineString([ | ||
[[-122.088, 37.418], [-122.086, 37.422], [-122.082, 37.418]], | ||
[[-122.087, 37.416], [-122.083, 37.416], [-122.082, 37.419]], | ||
]) | ||
|
||
# Apply the bounds method to the MultiLineString object. | ||
multilinestring_bounds = multilinestring.bounds() | ||
|
||
# Print the result. | ||
display('multilinestring.bounds(...) =', multilinestring_bounds) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer( | ||
multilinestring, {'color': 'black'}, 'Geometry [black]: multilinestring' | ||
) | ||
m.add_ee_layer( | ||
multilinestring_bounds, | ||
{'color': 'red'}, | ||
'Result [red]: multilinestring.bounds', | ||
) | ||
m | ||
# [END earthengine__apidocs__ee_geometry_multilinestring_bounds] |
40 changes: 40 additions & 0 deletions
40
samples/python/apidocs/ee_geometry_multilinestring_buffer.py
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,40 @@ | ||
# 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_multilinestring_buffer] | ||
# Define a MultiLineString object. | ||
multilinestring = ee.Geometry.MultiLineString([ | ||
[[-122.088, 37.418], [-122.086, 37.422], [-122.082, 37.418]], | ||
[[-122.087, 37.416], [-122.083, 37.416], [-122.082, 37.419]], | ||
]) | ||
|
||
# Apply the buffer method to the MultiLineString object. | ||
multilinestring_buffer = multilinestring.buffer(distance=100) | ||
|
||
# Print the result. | ||
display('multilinestring.buffer(...) =', multilinestring_buffer) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer( | ||
multilinestring, {'color': 'black'}, 'Geometry [black]: multilinestring' | ||
) | ||
m.add_ee_layer( | ||
multilinestring_buffer, | ||
{'color': 'red'}, | ||
'Result [red]: multilinestring.buffer', | ||
) | ||
m | ||
# [END earthengine__apidocs__ee_geometry_multilinestring_buffer] |
40 changes: 40 additions & 0 deletions
40
samples/python/apidocs/ee_geometry_multilinestring_centroid.py
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,40 @@ | ||
# 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_multilinestring_centroid] | ||
# Define a MultiLineString object. | ||
multilinestring = ee.Geometry.MultiLineString([ | ||
[[-122.088, 37.418], [-122.086, 37.422], [-122.082, 37.418]], | ||
[[-122.087, 37.416], [-122.083, 37.416], [-122.082, 37.419]], | ||
]) | ||
|
||
# Apply the centroid method to the MultiLineString object. | ||
multilinestring_centroid = multilinestring.centroid(maxError=1) | ||
|
||
# Print the result. | ||
display('multilinestring.centroid(...) =', multilinestring_centroid) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer( | ||
multilinestring, {'color': 'black'}, 'Geometry [black]: multilinestring' | ||
) | ||
m.add_ee_layer( | ||
multilinestring_centroid, | ||
{'color': 'red'}, | ||
'Result [red]: multilinestring.centroid', | ||
) | ||
m | ||
# [END earthengine__apidocs__ee_geometry_multilinestring_centroid] |
41 changes: 41 additions & 0 deletions
41
samples/python/apidocs/ee_geometry_multilinestring_containedin.py
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,41 @@ | ||
# 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_multilinestring_containedin] | ||
# Define a MultiLineString object. | ||
multilinestring = ee.Geometry.MultiLineString([ | ||
[[-122.088, 37.418], [-122.086, 37.422], [-122.082, 37.418]], | ||
[[-122.087, 37.416], [-122.083, 37.416], [-122.082, 37.419]], | ||
]) | ||
|
||
# Define other inputs. | ||
input_geom = ee.Geometry.BBox(-122.085, 37.415, -122.075, 37.425) | ||
|
||
# Apply the containedIn method to the MultiLineString object. | ||
multilinestring_contained_in = multilinestring.containedIn( | ||
right=input_geom, maxError=1 | ||
) | ||
|
||
# Print the result. | ||
display('multilinestring.containedIn(...) =', multilinestring_contained_in) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer( | ||
multilinestring, {'color': 'black'}, 'Geometry [black]: multilinestring' | ||
) | ||
m.add_ee_layer(input_geom, {'color': 'blue'}, 'Parameter [blue]: input_geom') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_multilinestring_containedin] |
41 changes: 41 additions & 0 deletions
41
samples/python/apidocs/ee_geometry_multilinestring_contains.py
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,41 @@ | ||
# 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_multilinestring_contains] | ||
# Define a MultiLineString object. | ||
multilinestring = ee.Geometry.MultiLineString([ | ||
[[-122.088, 37.418], [-122.086, 37.422], [-122.082, 37.418]], | ||
[[-122.087, 37.416], [-122.083, 37.416], [-122.082, 37.419]], | ||
]) | ||
|
||
# Define other inputs. | ||
input_geom = ee.Geometry.BBox(-122.085, 37.415, -122.075, 37.425) | ||
|
||
# Apply the contains method to the MultiLineString object. | ||
multilinestring_contains = multilinestring.contains( | ||
right=input_geom, maxError=1 | ||
) | ||
|
||
# Print the result. | ||
display('multilinestring.contains(...) =', multilinestring_contains) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer( | ||
multilinestring, {'color': 'black'}, 'Geometry [black]: multilinestring' | ||
) | ||
m.add_ee_layer(input_geom, {'color': 'blue'}, 'Parameter [blue]: input_geom') | ||
m | ||
# [END earthengine__apidocs__ee_geometry_multilinestring_contains] |
40 changes: 40 additions & 0 deletions
40
samples/python/apidocs/ee_geometry_multilinestring_convexhull.py
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,40 @@ | ||
# 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_multilinestring_convexhull] | ||
# Define a MultiLineString object. | ||
multilinestring = ee.Geometry.MultiLineString([ | ||
[[-122.088, 37.418], [-122.086, 37.422], [-122.082, 37.418]], | ||
[[-122.087, 37.416], [-122.083, 37.416], [-122.082, 37.419]], | ||
]) | ||
|
||
# Apply the convexHull method to the MultiLineString object. | ||
multilinestring_convex_hull = multilinestring.convexHull(maxError=1) | ||
|
||
# Print the result. | ||
display('multilinestring.convexHull(...) =', multilinestring_convex_hull) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer( | ||
multilinestring, {'color': 'black'}, 'Geometry [black]: multilinestring' | ||
) | ||
m.add_ee_layer( | ||
multilinestring_convex_hull, | ||
{'color': 'red'}, | ||
'Result [red]: multilinestring.convexHull', | ||
) | ||
m | ||
# [END earthengine__apidocs__ee_geometry_multilinestring_convexhull] |
35 changes: 35 additions & 0 deletions
35
samples/python/apidocs/ee_geometry_multilinestring_coordinates.py
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,35 @@ | ||
# 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_multilinestring_coordinates] | ||
# Define a MultiLineString object. | ||
multilinestring = ee.Geometry.MultiLineString([ | ||
[[-122.088, 37.418], [-122.086, 37.422], [-122.082, 37.418]], | ||
[[-122.087, 37.416], [-122.083, 37.416], [-122.082, 37.419]], | ||
]) | ||
|
||
# Apply the coordinates method to the MultiLineString object. | ||
multilinestring_coordinates = multilinestring.coordinates() | ||
|
||
# Print the result. | ||
display('multilinestring.coordinates(...) =', multilinestring_coordinates) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer( | ||
multilinestring, {'color': 'black'}, 'Geometry [black]: multilinestring' | ||
) | ||
m | ||
# [END earthengine__apidocs__ee_geometry_multilinestring_coordinates] |
42 changes: 42 additions & 0 deletions
42
samples/python/apidocs/ee_geometry_multilinestring_cutlines.py
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,42 @@ | ||
# 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_multilinestring_cutlines] | ||
# Define a MultiLineString object. | ||
multilinestring = ee.Geometry.MultiLineString([ | ||
[[-122.088, 37.418], [-122.086, 37.422], [-122.082, 37.418]], | ||
[[-122.087, 37.416], [-122.083, 37.416], [-122.082, 37.419]], | ||
]) | ||
|
||
# Apply the cutLines method to the MultiLineString object. | ||
multilinestring_cut_lines = multilinestring.cutLines( | ||
distances=[10, 100], maxError=1 | ||
) | ||
|
||
# Print the result. | ||
display('multilinestring.cutLines(...) =', multilinestring_cut_lines) | ||
|
||
# Display relevant geometries on the map. | ||
m = geemap.Map() | ||
m.set_center(-122.085, 37.422, 15) | ||
m.add_ee_layer( | ||
multilinestring, {'color': 'black'}, 'Geometry [black]: multilinestring' | ||
) | ||
m.add_ee_layer( | ||
multilinestring_cut_lines, | ||
{'color': 'red'}, | ||
'Result [red]: multilinestring.cutLines', | ||
) | ||
m | ||
# [END earthengine__apidocs__ee_geometry_multilinestring_cutlines] |
Oops, something went wrong.