0

I am using Google Earth Engine to reduce a raster region to polygon vectors. What I want to achieve is:

  • Obtain a set of polygons each of which matches the grid of measurement in the raster dataset. If the raster dataset's measurements are 0.25 x 0.25 degree, I want to break up the region in the map to polygons that align with these 0.25 x 0.25 degree grids.

Here's how I am doing the raster to vector conversion:

// a "geometry" polygon is imported

var raster_features = ee.ImageCollection('ECMWF/ERA5/DAILY')
                     .select('maximum_2m_air_temperature')
                     .filterBounds(geometry)
                     .filterDate('2017-01-01', '2018-12-31');
                   
var mean_features = raster_features.mean().multiply(10000).toInt();
var scale_to_use = mean.projection().nominalScale();

var vector_features = mean_features.reduceToVectors({
  reducer : null,
  geometry : geometry,

  //scale: 28000,
  scale: scale_to_use,

  crs :mean.projection().getInfo().crs,
  //crsTransform :mean_features.projection().getInfo().transform,

  geometryType: 'polygon',
  labelProperty : 'grid',
  eightConnected: false
});
Map.addLayer(vector_features, {}, 'vector_features')

The resolution of ECMWF/ERA5/DAILY dataset is 0.25 arc degrees. I was expecting the length and breadth of the grids returned by reduceToVectors to be 0.25 deg, but they are 1 deg instead. I want to get polygons in the resolution that the dataset is in, which is 0.25 degree. How do I achieve that?

5
  • 1
    Welcome to GIS SE. As a new user, please take the Tour, which emphasizes the importance of asking One question per Question. You have quite a few more than two questions here. We use a Focused question/Best answer model; please Edit your Question to ask one focused question.
    – Vince
    Jun 17, 2020 at 0:02
  • edited the question to make it one focused question.
    – vpk
    Jun 17, 2020 at 3:35
  • not sure why the question has been closed, even though I edited it to make a single focused question @Vince.
    – vpk
    Jun 17, 2020 at 18:15
  • 1
    I voted long before your change. You should use the reopen button to nominate it for reopening.
    – Vince
    Jun 17, 2020 at 18:26
  • I do not see a button to reopen the question where it is supposed to be.
    – vpk
    Jun 18, 2020 at 2:30

2 Answers 2

0

I found that replacing the definition of scale_to_use variable as given below solves this problem. It may be because the image collection itself has a default scale value of 1 degree, which the images inside the collection have the correct values, i.e., 0.25 degree.

var example_image = raster_features.first();
var scale_to_use = example_image.projection().nominalScale();
0

@vpk I tried your script and the output was mostly correct, meaning that most grid squares matched individual pixels but there were some rectangular polygons that were created which were made of 2 pixels. Did you encounter this as well?

2

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.