In Google Earth Engine, How do I select pixels from one image collection which correspond to a selected pixel value from another image collection?Pixel values Google Earth EngineExporting all images in a Google Earth Engine image collection (Google Earth Engine API)Supervised Classification with the Google Earth EngineHow to get the download urls for an image collection from Google Earth EngineCalculating the area of classified pixels in google earth engineScale values of raster in Google Earth EngineDigitize Points in Google Earth EngineEarth engine- ee Reucer mean for points- pixel or image?
Search and replace a substring only if another substring is not present
Meaning of "tumbleweed coifs"
Is law enforcement responsible for damages made by a search warrant?
Subverting the essence of fictional and/or religious entities; is it acceptable?
Meaning of ギャップ in the following sentence
Where can I see modifications made to the PATH environment variable by the Go installer
(7 of 11: Fillomino) What is Pyramid Cult's Favorite Shape?
How to transform a function from f[#1] to f[x]
Reasons for using monsters as bioweapons
What is the most 'environmentally friendly' way to learn to fly?
Export economy of Mars
Does a bard know when a character uses their Bardic Inspiration?
Using Forstner bits instead of hole saws
A wiild aanimal, a cardinal direction, or a place by the water
Subtle ways to render a planet uninhabitable
How can I perform a deterministic physics simulation?
Why did the United States not resort to nuclear weapons in Vietnam?
Why is the Hamming and Hanning window the most widely used for speech spectograms?
Password management for kids - what's a good way to start?
Why is the Vasa Museum in Stockholm so Popular?
What is Albrecht Dürer's Perspective Machine drawing style?
How does Rust's 128-bit integer `i128` work on a 64-bit system?
Accurately recalling the key - can everyone do it?
What license to choose for my PhD thesis?
In Google Earth Engine, How do I select pixels from one image collection which correspond to a selected pixel value from another image collection?
Pixel values Google Earth EngineExporting all images in a Google Earth Engine image collection (Google Earth Engine API)Supervised Classification with the Google Earth EngineHow to get the download urls for an image collection from Google Earth EngineCalculating the area of classified pixels in google earth engineScale values of raster in Google Earth EngineDigitize Points in Google Earth EngineEarth engine- ee Reucer mean for points- pixel or image?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to plot the count of burn pixels for modis burned area product within my geometry regions called "table" for only agricultural pixels (obtained from 'lc' image collection). I couldn't find anything in the docs to indicate you can do such a query between 2 image collections. Anyone have any suggestions?
I have tried using a mask, but it seems that this might only work on individual ee.Image not between different image collections. The code is shown below:
var modba = ee.ImageCollection('MODIS/006/MCD64A1').filterDate('2017-01-
01', '2017-12-31').select('BurnDate')
var modbaN = ee.ImageCollection('MODIS/006/MCD64A1').filterDate('2017-01-
01', '2017-12-31').select('Uncertainty')
var lc = ee.ImageCollection('MODIS/006/MCD12Q1').filterDate('2017-01-01',
'2017-12-31').select('LC_Type1')
var AgOnly = lc.map(function(img)
var ag = img.select('LC_Type1');
return ag.eq(12);
//Would also like to maybe have 2 or 3 LC types to select here
);
var mask_ba = modba.map(function(img)
return img.updateMask(AgOnly);
);
var bats =
//ui.Chart.image.seriesByRegion(modba, table, ee.Reducer.count());
ui.Chart.image.seriesByRegion(mask_ba, table, ee.Reducer.count());
print(bats);
var unts =
ui.Chart.image.seriesByRegion(modbaN, table, ee.Reducer.mean());
print(unts);
mask google-earth-engine
add a comment |
I want to plot the count of burn pixels for modis burned area product within my geometry regions called "table" for only agricultural pixels (obtained from 'lc' image collection). I couldn't find anything in the docs to indicate you can do such a query between 2 image collections. Anyone have any suggestions?
I have tried using a mask, but it seems that this might only work on individual ee.Image not between different image collections. The code is shown below:
var modba = ee.ImageCollection('MODIS/006/MCD64A1').filterDate('2017-01-
01', '2017-12-31').select('BurnDate')
var modbaN = ee.ImageCollection('MODIS/006/MCD64A1').filterDate('2017-01-
01', '2017-12-31').select('Uncertainty')
var lc = ee.ImageCollection('MODIS/006/MCD12Q1').filterDate('2017-01-01',
'2017-12-31').select('LC_Type1')
var AgOnly = lc.map(function(img)
var ag = img.select('LC_Type1');
return ag.eq(12);
//Would also like to maybe have 2 or 3 LC types to select here
);
var mask_ba = modba.map(function(img)
return img.updateMask(AgOnly);
);
var bats =
//ui.Chart.image.seriesByRegion(modba, table, ee.Reducer.count());
ui.Chart.image.seriesByRegion(mask_ba, table, ee.Reducer.count());
print(bats);
var unts =
ui.Chart.image.seriesByRegion(modbaN, table, ee.Reducer.mean());
print(unts);
mask google-earth-engine
add a comment |
I want to plot the count of burn pixels for modis burned area product within my geometry regions called "table" for only agricultural pixels (obtained from 'lc' image collection). I couldn't find anything in the docs to indicate you can do such a query between 2 image collections. Anyone have any suggestions?
I have tried using a mask, but it seems that this might only work on individual ee.Image not between different image collections. The code is shown below:
var modba = ee.ImageCollection('MODIS/006/MCD64A1').filterDate('2017-01-
01', '2017-12-31').select('BurnDate')
var modbaN = ee.ImageCollection('MODIS/006/MCD64A1').filterDate('2017-01-
01', '2017-12-31').select('Uncertainty')
var lc = ee.ImageCollection('MODIS/006/MCD12Q1').filterDate('2017-01-01',
'2017-12-31').select('LC_Type1')
var AgOnly = lc.map(function(img)
var ag = img.select('LC_Type1');
return ag.eq(12);
//Would also like to maybe have 2 or 3 LC types to select here
);
var mask_ba = modba.map(function(img)
return img.updateMask(AgOnly);
);
var bats =
//ui.Chart.image.seriesByRegion(modba, table, ee.Reducer.count());
ui.Chart.image.seriesByRegion(mask_ba, table, ee.Reducer.count());
print(bats);
var unts =
ui.Chart.image.seriesByRegion(modbaN, table, ee.Reducer.mean());
print(unts);
mask google-earth-engine
I want to plot the count of burn pixels for modis burned area product within my geometry regions called "table" for only agricultural pixels (obtained from 'lc' image collection). I couldn't find anything in the docs to indicate you can do such a query between 2 image collections. Anyone have any suggestions?
I have tried using a mask, but it seems that this might only work on individual ee.Image not between different image collections. The code is shown below:
var modba = ee.ImageCollection('MODIS/006/MCD64A1').filterDate('2017-01-
01', '2017-12-31').select('BurnDate')
var modbaN = ee.ImageCollection('MODIS/006/MCD64A1').filterDate('2017-01-
01', '2017-12-31').select('Uncertainty')
var lc = ee.ImageCollection('MODIS/006/MCD12Q1').filterDate('2017-01-01',
'2017-12-31').select('LC_Type1')
var AgOnly = lc.map(function(img)
var ag = img.select('LC_Type1');
return ag.eq(12);
//Would also like to maybe have 2 or 3 LC types to select here
);
var mask_ba = modba.map(function(img)
return img.updateMask(AgOnly);
);
var bats =
//ui.Chart.image.seriesByRegion(modba, table, ee.Reducer.count());
ui.Chart.image.seriesByRegion(mask_ba, table, ee.Reducer.count());
print(bats);
var unts =
ui.Chart.image.seriesByRegion(modbaN, table, ee.Reducer.mean());
print(unts);
mask google-earth-engine
mask google-earth-engine
edited Dec 20 '18 at 10:59
Val
3,4732 gold badges11 silver badges33 bronze badges
3,4732 gold badges11 silver badges33 bronze badges
asked Dec 19 '18 at 16:20
toferkeytoferkey
33 bronze badges
33 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
It's still doable with a wider date range and several land cover types.
In that case, just keep your old code that calculates AgOnly, and modify the code that calculates mask_ba as below:
var mask_ba = modba.map(function(img)
var img_year = img.date().format('YYYY');
var start_date = ee.Date(img_year.cat('-01-01'));
var end_date = start_day.advance(1, 'year');
var Agri_this_year = AgOnly.filterDate(start_date, end_date).max();
return img.updateMask(Agri_this_year);
);
Basically, the above code just extracts the year of the current img, then use filterDate method to select the land type cover of that year from AgOnly image collection, and finally apply updateMask.
The same idea could be applied to other land cover types.
Hope this helps.
add a comment |
As I understand, what you're trying to do is to mask each image in modba image collection (which has 12 images or one per month) by the corresponding image in AgOnly image collection (which has only 1 image for the whole year). That's totally doable.
In your provided code, you're updateMask using AgOnly (an image collection) which is not allowed by GEE.
All you need to do is just make AgOnly an image before using it for updateMask.
Try this:
var AgOnly = lc.map(function(img)
var ag = img.select('LC_Type1');
return ag.eq(12);
//Would also like to maybe have 2 or 3 LC types to select here
).max();
The max() method will convert your image collection into an image. You can also use min() or mean() if you like, which will all give the same result as there's only one image in AgOnl anyway.
I should have specified a wider date range in the original code. Your approach seems like a great way to do it with one image. However, I need to do it for about 15 years of data and several different land cover types. Would there be a way to do that? Thanks!
– toferkey
Dec 28 '18 at 20:26
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53855260%2fin-google-earth-engine-how-do-i-select-pixels-from-one-image-collection-which-c%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's still doable with a wider date range and several land cover types.
In that case, just keep your old code that calculates AgOnly, and modify the code that calculates mask_ba as below:
var mask_ba = modba.map(function(img)
var img_year = img.date().format('YYYY');
var start_date = ee.Date(img_year.cat('-01-01'));
var end_date = start_day.advance(1, 'year');
var Agri_this_year = AgOnly.filterDate(start_date, end_date).max();
return img.updateMask(Agri_this_year);
);
Basically, the above code just extracts the year of the current img, then use filterDate method to select the land type cover of that year from AgOnly image collection, and finally apply updateMask.
The same idea could be applied to other land cover types.
Hope this helps.
add a comment |
It's still doable with a wider date range and several land cover types.
In that case, just keep your old code that calculates AgOnly, and modify the code that calculates mask_ba as below:
var mask_ba = modba.map(function(img)
var img_year = img.date().format('YYYY');
var start_date = ee.Date(img_year.cat('-01-01'));
var end_date = start_day.advance(1, 'year');
var Agri_this_year = AgOnly.filterDate(start_date, end_date).max();
return img.updateMask(Agri_this_year);
);
Basically, the above code just extracts the year of the current img, then use filterDate method to select the land type cover of that year from AgOnly image collection, and finally apply updateMask.
The same idea could be applied to other land cover types.
Hope this helps.
add a comment |
It's still doable with a wider date range and several land cover types.
In that case, just keep your old code that calculates AgOnly, and modify the code that calculates mask_ba as below:
var mask_ba = modba.map(function(img)
var img_year = img.date().format('YYYY');
var start_date = ee.Date(img_year.cat('-01-01'));
var end_date = start_day.advance(1, 'year');
var Agri_this_year = AgOnly.filterDate(start_date, end_date).max();
return img.updateMask(Agri_this_year);
);
Basically, the above code just extracts the year of the current img, then use filterDate method to select the land type cover of that year from AgOnly image collection, and finally apply updateMask.
The same idea could be applied to other land cover types.
Hope this helps.
It's still doable with a wider date range and several land cover types.
In that case, just keep your old code that calculates AgOnly, and modify the code that calculates mask_ba as below:
var mask_ba = modba.map(function(img)
var img_year = img.date().format('YYYY');
var start_date = ee.Date(img_year.cat('-01-01'));
var end_date = start_day.advance(1, 'year');
var Agri_this_year = AgOnly.filterDate(start_date, end_date).max();
return img.updateMask(Agri_this_year);
);
Basically, the above code just extracts the year of the current img, then use filterDate method to select the land type cover of that year from AgOnly image collection, and finally apply updateMask.
The same idea could be applied to other land cover types.
Hope this helps.
edited Mar 27 at 1:28
answered Dec 30 '18 at 14:56
KevinKevin
1331 gold badge1 silver badge8 bronze badges
1331 gold badge1 silver badge8 bronze badges
add a comment |
add a comment |
As I understand, what you're trying to do is to mask each image in modba image collection (which has 12 images or one per month) by the corresponding image in AgOnly image collection (which has only 1 image for the whole year). That's totally doable.
In your provided code, you're updateMask using AgOnly (an image collection) which is not allowed by GEE.
All you need to do is just make AgOnly an image before using it for updateMask.
Try this:
var AgOnly = lc.map(function(img)
var ag = img.select('LC_Type1');
return ag.eq(12);
//Would also like to maybe have 2 or 3 LC types to select here
).max();
The max() method will convert your image collection into an image. You can also use min() or mean() if you like, which will all give the same result as there's only one image in AgOnl anyway.
I should have specified a wider date range in the original code. Your approach seems like a great way to do it with one image. However, I need to do it for about 15 years of data and several different land cover types. Would there be a way to do that? Thanks!
– toferkey
Dec 28 '18 at 20:26
add a comment |
As I understand, what you're trying to do is to mask each image in modba image collection (which has 12 images or one per month) by the corresponding image in AgOnly image collection (which has only 1 image for the whole year). That's totally doable.
In your provided code, you're updateMask using AgOnly (an image collection) which is not allowed by GEE.
All you need to do is just make AgOnly an image before using it for updateMask.
Try this:
var AgOnly = lc.map(function(img)
var ag = img.select('LC_Type1');
return ag.eq(12);
//Would also like to maybe have 2 or 3 LC types to select here
).max();
The max() method will convert your image collection into an image. You can also use min() or mean() if you like, which will all give the same result as there's only one image in AgOnl anyway.
I should have specified a wider date range in the original code. Your approach seems like a great way to do it with one image. However, I need to do it for about 15 years of data and several different land cover types. Would there be a way to do that? Thanks!
– toferkey
Dec 28 '18 at 20:26
add a comment |
As I understand, what you're trying to do is to mask each image in modba image collection (which has 12 images or one per month) by the corresponding image in AgOnly image collection (which has only 1 image for the whole year). That's totally doable.
In your provided code, you're updateMask using AgOnly (an image collection) which is not allowed by GEE.
All you need to do is just make AgOnly an image before using it for updateMask.
Try this:
var AgOnly = lc.map(function(img)
var ag = img.select('LC_Type1');
return ag.eq(12);
//Would also like to maybe have 2 or 3 LC types to select here
).max();
The max() method will convert your image collection into an image. You can also use min() or mean() if you like, which will all give the same result as there's only one image in AgOnl anyway.
As I understand, what you're trying to do is to mask each image in modba image collection (which has 12 images or one per month) by the corresponding image in AgOnly image collection (which has only 1 image for the whole year). That's totally doable.
In your provided code, you're updateMask using AgOnly (an image collection) which is not allowed by GEE.
All you need to do is just make AgOnly an image before using it for updateMask.
Try this:
var AgOnly = lc.map(function(img)
var ag = img.select('LC_Type1');
return ag.eq(12);
//Would also like to maybe have 2 or 3 LC types to select here
).max();
The max() method will convert your image collection into an image. You can also use min() or mean() if you like, which will all give the same result as there's only one image in AgOnl anyway.
answered Dec 27 '18 at 5:29
KevinKevin
1331 gold badge1 silver badge8 bronze badges
1331 gold badge1 silver badge8 bronze badges
I should have specified a wider date range in the original code. Your approach seems like a great way to do it with one image. However, I need to do it for about 15 years of data and several different land cover types. Would there be a way to do that? Thanks!
– toferkey
Dec 28 '18 at 20:26
add a comment |
I should have specified a wider date range in the original code. Your approach seems like a great way to do it with one image. However, I need to do it for about 15 years of data and several different land cover types. Would there be a way to do that? Thanks!
– toferkey
Dec 28 '18 at 20:26
I should have specified a wider date range in the original code. Your approach seems like a great way to do it with one image. However, I need to do it for about 15 years of data and several different land cover types. Would there be a way to do that? Thanks!
– toferkey
Dec 28 '18 at 20:26
I should have specified a wider date range in the original code. Your approach seems like a great way to do it with one image. However, I need to do it for about 15 years of data and several different land cover types. Would there be a way to do that? Thanks!
– toferkey
Dec 28 '18 at 20:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53855260%2fin-google-earth-engine-how-do-i-select-pixels-from-one-image-collection-which-c%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown