2

I have uploaded a dataset to GEE and I want to align every image in the collection to have the same geographic extent as the first image of this collection.

My code so far :

var ref_image = imageCollection.first();
var limited_collection = imageCollection.limit(10)

var align = function(image) {
  var im = image.select('b1');
  return image.reproject({
    crs: im.projection().crs(),
    scale: 1000})};

var new_collection = limited_collection.map(align)

print(new_collection)
print(imageCollection)
Map.addLayer(new_collection, {min:0, max:25, bands:['b1']}, 'new collection')

https://code.earthengine.google.com/9107bd80f72128963e617fe260d54ee4

The error I get is:

ImageCollection (Error)
Error in map(ID=0901012350):
Projection: Parameter 'crs' is required.

If I print out the CRS of the first image I get the information:

crs: 
PROJCS["Radolan projection", 
  GEOGCS["Radolan Coordinate System", 
    DATUM["Radolan_Kugel", 
      SPHEROID["Erdkugel", 6370040.0, 0.0]], 
    PRIMEM["Greenwich", 0.0], 
    UNIT["degree", 0.017453292519943295], 
    AXIS["Longitude", EAST], 
    AXIS["Latitude", NORTH]], 
  PROJECTION["Polar_Stereographic"], 
  PARAMETER["central_meridian", 10.0], 
  PARAMETER["latitude_of_origin", 90.0], 
  PARAMETER["scale_factor", 0.9330127019], 
  PARAMETER["false_easting", 0.0], 
  PARAMETER["false_northing", 0.0], 
  UNIT["m*1000.0", 1000.0], 
  AXIS["X", EAST], 
  AXIS["Y", NORTH]]

So the CRS information is stored in the image. Is it only possible to align images with official CRS? Or have I misunderstood the .reproject command?

2

The problem you are having is the projection information has no .crs() method so a null value is being provided to the crs argument in the reprojection function. If you print the projection of ref_image you see it actually has a WKT property, after fiddling around it seems like .wkt() is what you would want to use to get the CRS information from your particular projection.

Also, the way you had the reprojecting coded doesn't match what you want to do (reproject everything be consistent with the first image). You are actually referencing the projection from the individual element that you are mapping over, not the first image projection. Here is the code to do what you are asking:

var ref_image = imageCollection.first();
var limited_collection = imageCollection.limit(10)

var proj = ref_image.projection()
print(proj)

var align = function(image) {
  var im = image.select('b1');
  return image.reproject({
    crs: proj.wkt(),
    scale: 1000})};

var new_collection = limited_collection.map(align)

print(new_collection)
print(imageCollection)
Map.addLayer(new_collection, {min:0, max:25, bands:['b1']}, 'new collection')

Here is the code. I hope this helps!

  • Hey Kel, the first image has nearly the same extend of Germany, but if i use this code and limit the collection to 1000 I see that the new_collection has a much bigger extent then the first image. – till Kadabra Sep 17 '19 at 10:36
  • 1
    The code does not clip the image collection of all the images to the extent of the first image, but rather it converts all the images to the same projection. So, there should be different extents but all using the same coordinates. Were you trying to accomplish something else? – Kel Markert Sep 18 '19 at 19:57
  • oh sorry ;) yes i try to archive that all images get referenced to the first image so that all the images share the same geometry. Is this possible? – till Kadabra Sep 20 '19 at 6:49
  • 1
    Yes, this is possible! You will want to perform a .clip() at the end of align function to clip it to your geometry of choice. – Kel Markert Sep 23 '19 at 7:28
  • ok that i know maybe my English is bad ^^ i try it again: i have upload this image collection but only the first image has the correct size of 900x900 cells with 1km² of area and the right position on the map. The other images have incorrect values in both size and position. So my goal is to get all other images perfectly overlaying on the first image?! – till Kadabra Sep 24 '19 at 10:06

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.