You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GEE support multipoint feature but the geemap.geojson_to_ee dosent
suggestion to change:
def geojson_to_ee(geo_json, geodesic=False, encoding="utf-8"):
"""Converts a geojson to ee.Geometry()
Args:
geo_json (dict): A geojson geometry dictionary or file path.
geodesic (bool, optional): Whether line segments should be interpreted as spherical geodesics. If false, indicates that line segments should be interpreted as planar lines in the specified CRS. If absent, defaults to true if the CRS is geographic (including the default EPSG:4326), or to false if the CRS is projected. Defaults to False.
encoding (str, optional): The encoding of characters. Defaults to "utf-8".
Returns:
ee_object: An ee.Geometry object
"""
try:
if isinstance(geo_json, str):
if geo_json.startswith("http") and geo_json.endswith(".geojson"):
geo_json = geemap.github_raw_url(geo_json)
out_geojson = geemap.temp_file_path(extension=".geojson")
geemap.download_file(geo_json, out_geojson)
with open(out_geojson, "r", encoding=encoding) as f:
geo_json = json.loads(f.read())
os.remove(out_geojson)
elif os.path.isfile(geo_json):
with open(os.path.abspath(geo_json), encoding=encoding) as f:
geo_json = json.load(f)
# geo_json["geodesic"] = geodesic
if geo_json["type"] == "FeatureCollection":
for feature in geo_json["features"]:
if not feature["geometry"]["type"] in ("Point", "MultiPoint"):
feature["geometry"]["geodesic"] = geodesic
features = ee.FeatureCollection(geo_json)
return features
elif geo_json["type"] == "Feature":
geom = None
if "style" in geo_json["properties"]:
keys = geo_json["properties"]["style"].keys()
if "radius" in keys: # Checks whether it is a circle
geom = ee.Geometry(geo_json["geometry"])
radius = geo_json["properties"]["style"]["radius"]
geom = geom.buffer(radius)
elif geo_json["geometry"]["type"] == "Point":
geom = ee.Geometry(geo_json["geometry"])
else:
geom = ee.Geometry(geo_json["geometry"], "", geodesic)
elif geo_json["geometry"]["type"] == "Point": # Checks whether it is a point
coordinates = geo_json["geometry"]["coordinates"]
longitude = coordinates[0]
latitude = coordinates[1]
geom = ee.Geometry.Point(longitude, latitude)
elif geo_json["geometry"]["type"] == "MultiPoint": # Checks whether it is a point
coordinates = geo_json["geometry"]["coordinates"]
longitude = coordinates[0]
latitude = coordinates[1]
geom = ee.Geometry.MultiPoint(longitude, latitude)
else:
geom = ee.Geometry(geo_json["geometry"], "", geodesic)
return geom
else:
raise Exception("Could not convert the geojson to ee.Geometry()")
except Exception as e:
print("Could not convert the geojson to ee.Geometry()")
raise Exception(e)
The text was updated successfully, but these errors were encountered:
GEE support multipoint feature but the geemap.geojson_to_ee dosent
suggestion to change:
The text was updated successfully, but these errors were encountered: