You can control the pixel size of an image by setting the scale parameter of ee.Image.reproject():
// Reference a Landsat scene.
var image_30m = ee.Image('LANDSAT/LC08/C01/T1/LC08_044034_20170614');
// Define visualization parameters for a true color image.
var vizParams = {'bands': 'B4,B3,B2',
'min': 5000,
'max': 30000,
'gamma': 1.6};
Map.addLayer(image_30m, vizParams, 'image_30m');
// Get the projection information for a band.
var band2 = image_30m.select('B2');
print('CRS:', band2.projection().crs());
// Display a bilinear resampled image with 10m pixel spacing.
var image_10m = image_30m.resample('bilinear').reproject({
crs: band2.projection().crs(),
scale: 10
});
Map.addLayer(image_10m, vizParams, 'image_10m');
If you want even more control over the projection, you can manually change the CRS transform (crsTransform
) parameter:
// Reference a Landsat scene.
var image_30m = ee.Image('LANDSAT/LC08/C01/T1/LC08_044034_20170614');
// Define visualization parameters for a true color image.
var vizParams = {'bands': 'B4,B3,B2',
'min': 5000,
'max': 30000,
'gamma': 1.6};
Map.addLayer(image_30m, vizParams, 'image_30m');
// Get the projection information for a band.
var band2 = image_30m.select('B2');
var proj = band2.projection().getInfo();
print('CRS:', proj.crs);
print('original CRS transform:', proj.transform);
// Construct a new CRS transform, using 10m spacing.
var transform_new = [
10,
proj.transform[1],
proj.transform[2],
proj.transform[3],
-10,
proj.transform[5],
];
print('new CRS transform:', transform_new);
// Display a bilinear resampled image with 10m pixel spacing.
var image_10m = image_30m.resample('bilinear').reproject(
{
crs: proj.crs,
crsTransform: transform_new
});
Map.addLayer(image_10m, vizParams, 'image_10m');
See the Projections doc page for more information.
I modified your code to print the dimensions of a specified region (ROI).
var ROI = ee.Geometry.Rectangle(-82.5574, 35.5958, -82.5563, 35.59515); // define area
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1')
.filterDate('2014-05-01', '2015-10-01')
.filterBounds(ROI)
.limit(1);
var composite = ee.Algorithms.Landsat.simpleComposite(collection);
var image = composite.clip(ROI);
Map.centerObject(ROI);
Map.addLayer(composite, {bands: 'B4,B3,B2', min:0, max:100}, "composite", false);
Map.addLayer(image, {bands: 'B4,B3,B2', min:0, max:100},"image");
// Extract projection information from the first band of a sample image in the collection.
var sample = ee.Image(collection.first());
var projection = sample.select('B1').projection();
// Reproject the composite image to the selected projection.
image = composite.reproject(projection).clip(ROI);
print('image information', image);
Note that:
- Because image collections may contain images with many different projections, you need to specify the projection of your desired output in order to get back meaningful dimensions. In the example above I used the projection information from the first band of a sample image.
- Bands within an image may have different projections. (This is the case for Landsat 8 images.)
- I made the ROI smaller, so you can see the individual pixels when added to the map.
- I limited the collection to a single image that intersects the ROI, so it is easier to interpret the results.
If you want to access the information on the client side, you can do the following:
// Return the image metadata to the client.
var image_info = image.getInfo();
// On the clientside, using Javascript, print out the dimensions.
print('band B1 dimensions: ' + image_info.bands[0].dimensions);
While it is possible to construct images in Earth Engine that store pixel information as multi-dimensional arrays, most images (including the Landsat collection shown in your example) have scalar values (i.e. 0-dimensional arrays) so it is not necessary to use ee.Array object methods to extract information.
Best Answer
It is possible the access the date in the following way:
Just calling ".getInfo()" on the ee.Date object will give you the number of milliseconds since 1970-01-01 in a Python dictionary.
It is possible to format the date with the ".format" method.