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?

vpk
  • 111
  • 3
  • 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 '20 at 00:02
  • edited the question to make it one focused question. – vpk Jun 17 '20 at 03:35
  • not sure why the question has been closed, even though I edited it to make a single focused question @Vince. – vpk Jun 17 '20 at 18:15
  • 1
    I voted long before your change. You should use the reopen button to nominate it for reopening. – Vince Jun 17 '20 at 18:26
  • I do not see a button to reopen the question where it is supposed to be. – vpk Jun 18 '20 at 02:30

2 Answers2

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();
vpk
  • 111
  • 3
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?

  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – Kadir Şahbaz Nov 06 '21 at 07:59
  • Hi Kadir, thank you for explaining. I have since created a new question (https://gis.stackexchange.com/questions/415752/spatial-join-2-polygon-feature-collections-and-count-number-of-times-they-inters). As such, you may remove my comment in this current thread if need be – EarthOrbGIS Nov 07 '21 at 18:10