I am new to code and using Earth Engine Python API. I converted a shapefile to a GeoJSON. I need to convert my geojson file to a feature collection and upload it into my Google Earth Engine repository. I am using this code (check picture), however I get an error that says
EEException: Invalid GeoJSON geometry.
I then use a GeoJSON online validator tool, and it seems like my file is valid and the geometry type is a point. My GeoJSON is a feature collection with more than 3000 points. How can I overcome this? I added a block with my code, and screenshots of the GeoJSON file.
Code
# Specify the Google Drive file ID of the shapefile
file_id = '1iA9L6tn0dwVlABPngFAgjRxd8xXET1c4'
file_path = '/content/drive/My Drive/Colab Notebooks/Data/TrainingSet_SabieCroc/Training_setSc.shp'
url = f'https://drive.google.com/uc?id={file_id}'
# Read the shapefile into a GeoDataFrame
training_data = gpd.read_file(file_path)
#print (training_data)
# Convert the GeoDataFrame to GeoJSON and save it
geojson_path = '/content/drive/My Drive/Colab Notebooks/Data/TrainingSet_SabieCroc/Training_setSc.geojson'
training_data.to_file(geojson_path, driver='GeoJSON')
# Read the GeoJSON file as a dictionary
with open(geojson_path, 'r') as f:
geojson_data = json.load(f)
# Convert the GeoJSON file to a feature collection
training_set= ee.FeatureCollection(geojson_data)
#Specify the asset ID where you want to upload the feature collection
#asset_id = 'projects/thandeka-skosana/assets/training_set'
# Export the feature collection to an Earth Engine asset
#export_task = ee.batch.Export.table.toAsset(
#collection=training_set,
#description='Export Training Set',
#assetId=asset_id
#)
# Start the export task
#export_task.start()


ee.Geometry.Pointonly supports X and Y. You'll need to remove the Z coordinates from theGeoDataFramebefore turning it into aFeatureCollection.