1

I am attempting to generate 50 random points per land use class through Google Earth Engine. I have performed this operation before on an earlier instance, where the inputs were the following

(1) SRTMGL1 data (2) Table asset data (polygons/points)

However, now I am attempting to repeat the same operation i.e. randomly sample from a FeatureCollection, but instead of sampling 50 random points from polygons subsetted according to their land use class, I am wanting sample from points

i.e. From a vector layer made up of points (not polygons), randomly select 50 points per land use class, and NOT randomly select points within polygons.

However, although the code works, the CSVs I generated after running the code are empty, and there are no entries. I found then that the ee.Filter.eq operation that I applied in my code did not actually filter anything, and after troubleshooting via print(var), it showed zero elements.

After comparing my two scripts, I postulated that the error in filtering arises because now, my Table data has values for land use classifiers under the feature 'id' and 'id2' (corresponding to 2 levels of land cover classification) to be in 'Long' format instead of the 'String' format that I previously managed to get it working on.

Is there a way to convert 'Long' data to 'String' data? Or is there something else wrong with my code/workflow? Or is there a way to properly code to filter from 'Long' data?

The link to my current script is https://code.earthengine.google.com/3a5e3bbffea2c37ca6393b8d5df75d06

Asset properties

  • I cannot access the table, but I guess the workflow would be: in a map function (to go over the fc): get property .get('id'), convert Number to String with Number.format(), replace property with new value with .set('id', value) – Rodrigo E. Principe Jan 17 '18 at 13:27
  • Please share the table or replace it with a public table so that others can reproduce your issue. – Tyler Erickson Jan 18 '18 at 0:02
  • I have tried your suggestion but nothing is executed when I run the script, there are no updates to the "Console" tab and even functions such as print(); or .getInfo(); failed. Next, I cut down the data in the .shp as it exceeded 5000 elements (trimmed to 4999 elements). Previously I imported the .shp as a Table Asset into the Code Editor, but this time, I uploaded it as a Fusion Table, and somehow, the metadata shows that my previously "Long" data are now in "String" format. However, my script still fails. I have made the table public this time. :) – Johanness Jan 22 '18 at 7:56
  • Permission denied for Fusion Table '1Gvc...' – Rodrigo E. Principe Jan 23 '18 at 10:39

Your Answer

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

Browse other questions tagged or ask your own question.