1

I am trying to export composite and classified bands from my GEE workspace to Drive. This classification was performed on Sentinel-2 (COPERNICUS/S2_SR) image collection. The Datatype of bands all shows a different datatype. While [B1-B12] show 'unit64', my classified layer shows 'unit32'. As I want this data to be used to train on a Neural Network, I wanted to know, if it is possible to convert the data types of each band to unit8 and then export it to drive?

I am only interested in 'B2,B3,B4' and 'classification' bands. This is the Bands info for 'im'(variable created to save the info)

Image (13 bands)
type: Image
bands: List (13 elements)
0: "B1", double ∈ [0, 65535], EPSG:4326, 2x2 px
1: "B2", double ∈ [0, 65535], EPSG:4326, 2x2 px
2: "B3", double ∈ [0, 65535], EPSG:4326, 2x2 px
3: "B4", double ∈ [0, 65535], EPSG:4326, 2x2 px
4: "B5", double ∈ [0, 65535], EPSG:4326, 2x2 px
5: "B6", double ∈ [0, 65535], EPSG:4326, 2x2 px
6: "B7", double ∈ [0, 65535], EPSG:4326, 2x2 px
7: "B8", double ∈ [0, 65535], EPSG:4326, 2x2 px
8: "B8A", double ∈ [0, 65535], EPSG:4326, 2x2 px
9: "B9", double ∈ [0, 65535], EPSG:4326, 2x2 px
10: "B11", double ∈ [0, 65535], EPSG:4326, 2x2 px
11: "B12", double ∈ [0, 65535], EPSG:4326, 2x2 px
12: "classification", signed int32, EPSG:4326, 2x2 px

As per the Developer Site I modified the code as below:

var im8 = im.Image.toUnit8();

And got this error

Line 146: Cannot read property 'toUnit8' of undefined

What am I doing wrong? Please guide.

0

1 Answer 1

1

Two things actually, you have a typo but you also called the method in a wrong way. No problemo though!

The API you linked is for an Image object which you already have with the name im. So the method is available directly for that object.

And the method is called toUint8 (for Unsigned INTeger 8-bit), not toUnit8.

The correct call is:

var im8 = im.toUint8();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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