ee.Geometry.Point.toGeoJSONString
Returns a GeoJSON string representation of the geometry.
Usage | Returns |
---|
Point.toGeoJSONString() | String |
Argument | Type | Details |
---|
this: geometry | Geometry | The Geometry instance. |
Examples
// Define a Point object.
var point = ee.Geometry.Point(-122.082, 37.42);
// Apply the toGeoJSONString method to the Point object.
var pointToGeoJSONString = point.toGeoJSONString();
// Print the result to the console.
print('point.toGeoJSONString(...) =', pointToGeoJSONString);
// Display relevant geometries on the map.
Map.setCenter(-122.085, 37.422, 15);
Map.addLayer(point,
{'color': 'black'},
'Geometry [black]: point');
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 Point object.
point = ee.Geometry.Point(-122.082, 37.42)
# Apply the toGeoJSONString method to the Point object.
point_to_geojson_string = point.toGeoJSONString()
# Print the result.
display('point.toGeoJSONString(...) =', point_to_geojson_string)
# Display relevant geometries on the map.
m = geemap.Map()
m.set_center(-122.085, 37.422, 15)
m.add_layer(point, {'color': 'black'}, 'Geometry [black]: point')
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."],[[["`toGeoJSONString()` is a method that returns a GeoJSON string representation of an Earth Engine Geometry object, such as a Point."],["This method takes a Geometry object as input and returns a string containing the GeoJSON representation."],["The provided examples demonstrate how to use `toGeoJSONString()` in both JavaScript and Python environments to convert a Point geometry to a GeoJSON string and display it."]]],["The `toGeoJSONString()` method converts a geometry object into its GeoJSON string representation. It takes a `Geometry` instance as input. The method is available for `Point` objects in both JavaScript and Python. Example usages demonstrate creating a `Point` object, applying `toGeoJSONString()`, and printing the resulting GeoJSON string. The example also shows how to add the point on the map in black color.\n"]]