ee.Geometry.Polygon.serialize
Returns the serialized representation of this object.
Usage | Returns |
---|
Polygon.serialize(legacy) | String |
Argument | Type | Details |
---|
this: geometry | Geometry | The Geometry instance. |
legacy | Boolean, optional | Enables legacy format. |
Examples
// Define a Polygon object.
var polygon = ee.Geometry.Polygon(
[[[-122.092, 37.424],
[-122.086, 37.418],
[-122.079, 37.425],
[-122.085, 37.423]]]);
// Apply the serialize method to the Polygon object.
var polygonSerialize = polygon.serialize();
// Print the result to the console.
print('polygon.serialize(...) =', polygonSerialize);
// Display relevant geometries on the map.
Map.setCenter(-122.085, 37.422, 15);
Map.addLayer(polygon,
{'color': 'black'},
'Geometry [black]: polygon');
Python setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
import ee
import geemap.core as geemap
# Define a Polygon object.
polygon = ee.Geometry.Polygon([[
[-122.092, 37.424],
[-122.086, 37.418],
[-122.079, 37.425],
[-122.085, 37.423],
]])
# Apply the serialize method to the Polygon object.
polygon_serialize = polygon.serialize()
# Print the result.
display('polygon.serialize(...) =', polygon_serialize)
# Display relevant geometries on the map.
m = geemap.Map()
m.set_center(-122.085, 37.422, 15)
m.add_layer(polygon, {'color': 'black'}, 'Geometry [black]: polygon')
m
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["The `serialize()` method returns a serialized (string) representation of a given Earth Engine Geometry object, such as a Polygon."],["This method can be used to convert a Geometry object into a format suitable for storage or transmission."],["An optional `legacy` argument can be provided to enable legacy formatting if needed."],["Examples in JavaScript and Python demonstrate using `serialize()` with a Polygon Geometry."]]],["The `serialize` method returns a string representation of a Geometry object, specifically a Polygon in this case. It accepts an optional boolean argument, `legacy`, to enable a legacy format. The examples demonstrate creating a Polygon object and then serializing it using `polygon.serialize()`. The result is then printed, and the polygon is displayed on a map using both JavaScript and Python environments. The method serializes the polygon into a string.\n"]]