1
var bands = ['B1','B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'NDVI', 'BG', 'BR', 'SLOPE', 'SRTM', 'NDWI'];
var trainingTesting = withLayers.select(bands).sampleRegions({
  collection: new_merge,
  properties: ['landcover'],
  scale: 30
}).randomColumn('random');

print (trainingTesting);

// Partition the training
var training = trainingTesting.filter(ee.Filter.lte('random', 0.7));
print('Training n =', training.aggregate_count('.all'));

var testing = trainingTesting.filter(ee.Filter.gt('random', 0.7));
print('Testing n =', testing.aggregate_count('.all'));


Export.table.toDrive({
  collection: ee.FeatureCollection(training),
  description: 'Perlis_training',
  fileFormat: 'CSV'
});

I tried to export the whole samples before doing any splitting and the samples were all okay..

However, I want to export on the 70% of the samples which I've labeled it as training but the information on the coordinate system was not included in the export. How can I extract the coordinate of the training samples after being split?

  • when you say > information on the coordinate system was not included in the export are you meaning that the additional information on coordinates are not there or the coordinates itself is not there? – Rupesh Mankavil Mar 18 at 12:59
  • The coordinates itself.. Before the splitting was conducted, all the samples have the coordinates. However, after the splitting being conducted, i exported to csv files, there was no coordinates in it. – Fiera Mar 20 at 3:38
1

Depends on where you data is from. Guess and check. If you data is from the web, odds are they are using 'web mercator'. NAD83 also a common datum for North America. If it's a city in Europe, the UTM seems to be common.

  • Export.table.toDrive({ collection: new_merge, description: 'Example', fileFormat: 'SHP' }); The above command was used to export the whole samples (before splitting) into csv file. The coordinates was given in x and y.. I tried to export to shp file, it was okay.. However, i used the same commad to export only the training samples (after splitted to 70%) into csv file, there was no cooridnates given. Furthermore, i've tried to export to shp file, an error occurred. the crs for my study area is 'EPSG: 4326' – Fiera Mar 20 at 3:40
  • Shapefile has three parts: the table is only one part. Attempting to export just the table loses the other parts of the table. The way you are splitting to 70% seems to be breaking the link between the parts. – Mox Mar 20 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.