For those having the "NIR.subtract" error, just checkout 2:23 to 2:25 in x0.25 speed. He adds .first() to the end of the line. So then the full code for the first line should be: var image = L8.filterBounds(ee.Geometry.Point(-4, 56.9)).filterMetadata('CLOUD_COVER', 'less_than', 1).first()
Indeed, since the subtract function is meant to operate between images, passing a imageCollection into the function will throw an error. The .first() function is meant to take the first image of the collection. Another way to aggregate to collection to one image could be to take the mean, max, or min values.
Thanks a lot guys... I had an issue earlier trying to combine two images to perform the NDVI analysis and it was returning one image as the result... I just used the "mean" function and it returned both images... Thanks
This is an excellent tutorial! I highly appreciate your effort in sharing these experiences, which substantially diminish my challenges in learning GEE. Thank you!
Hi, I understood the image filter properly. My question is how to export a series of images between a range of times, not the median image. I mean how can I get all images from 2017-01-01 to 2017-12-31?
I have a question that is not really related to this particular video... I want to calculate the reflectance of all bands in a specific point, using landsat8... Is that possible? Thanks!
i can't perform subtract. How to convert ee.ImageCollection to a ee.Image object? Kindly help. I filtered based on specificity and all. But nothing works
That is indeed a common issue. Even if there is only one image in the image collection, it is still considered a collection (of one image). If you want to convert it, you need some sort of aggregation function. You could do collection.first() to get the first image of your collection. Other options I use often are collection.min(), collection.max(), collection.mean() or collection.median() if the collection has many images and you want to aggregate them into one image, these do the trick. Min() will take the smallest pixel value for each pixel, mean() will calculate the average pixel value of all images in the collection and so on. These functions return an ee.Image that you can use to substract.
Dear Sam, I wanted to convert the NEX-GDDP temperature data from Kelvin to Celsius, but the code below did not work. I watched your third and fourth videos but still have a problem. Can you help me? Code: var dataset = ee.ImageCollection('NASA/NEX-GDDP') .filter(ee.Filter.date('2018-07-01', '2018-07-02')); var minimumAirTemperature = dataset.select('tasmin'); var tminnew = dataset.expression( 'tmin-273.15', { 'tmin': minimumAirTemperature }) Map.addLayer( tminnew, minimumAirTemperatureVis, 'Minimum Air Temperature'); Regards, Javad
Hi Javad! I think I see what's happening here. you filter your image collection by date. and this gives you a new imageCollection with less images. The expression function however, can only be executed on an Image, not an entire collection. What you are doing is running the expression function on the collection, but then it gives the error that dataset.expression is not a function. What you should do is turn your imageCollection into an image. It goes by fast, but in my video, I add .first() to my collection. this just takes the first image that is in my collection. the variable I end up with then is no longer a collection of images but just a single image. you could also use for example the mean(), max(), min() function to get one image from your filtered collection. Let me know if it works!
does anyone know how to do logarithm calculation in GEE? im trying to do image expression/function for TSS. i'm struggling with logarithm and this "image.expression is not a function". does anyone know the solution? thank you
hi! I want to display the TSS calculation results with colors in the range, for example TSS 0-10 m / L in yellow. Is that possible? thanks for your sharing
It is not possible to display a range of values in a certain color although that would be a great addition. There is also no direct function to turn value ranges into classes. But with a bit of creativity it is possible to classify value ranges as shown in this stackexchange: gis.stackexchange.com/questions/264000/reclassifying-raster-values-in-google-earth-engine/264004 After this you could give each created class a chosen color. Let me know if it works out!
This tutorial helps me a lot, but I still come across a problem. When I finish the code, the console says 'image.expression is not a function'. What's going wrong?
The 'expression' function is used only for ee.Image objects. I Think your variable might not be such an object, so expression would not be a valid function. Could it be you still have an imageCollection object? when you print the variable, as in print(image), the variable type will appear briefly before printing the result. You might want to check that out first ;)
Yes, it's still imageCollection object. var image = S2.filterBounds(Region).filterMetadata('CLOUD_COVERAGE_ASSESSMENT', 'less_than', 20).filterDate('2017-01-01','2018-08-31'); This line of code produces an ImageCollection COPERNICUS/S2 (84 elements). But I don't know how to convert it to ee.Image object.
Okey so you now have a collection of 84 elements (images) that fit your requirements, but you only want one image. You could do image.first(). This will select the first image of your collection. Or you could do image.median(), which will take the median image of all 84. Both of these operations will give you an ee.Image as result in stead of ImageCollection. There are other functions as well, such as .average(), .min() to take the lowest values, .max() to take the highest values and so on, but I think .first() or .median() will suit you best!
exactly! The expression function can only be used on a single image not on a collection, glad I could help. FYI, the next video will be about how to map functions over entire collections
the subtract function is a function for images only. So I suspect that your NIR is not an image object. Could it be that it is still an image collection (maybe of just one image)? You can turn this into an image by doing NIR.first() for example, which selects the first item in an image collection. Let me know if it works!
@@ProgramSam var image= imageCollection.filterBounds(ee.Geometry.Point(106.6880844,10.8007089)).filterMetadata('CLOUD_COVER','less_than',1); var RED = image.select('B4'); var NIR = image.select('B5'); var NDVI = NIR.subtract(RED).divide(NIR.add(RED)); Map.addLayer(NDVI) these are my codes
@@hungnguyenphi4552 Well it is indeed as I mentioned. You filter an image collection, which returns a new image collection. Then the select function selects the band in all the images of the collection, which still is a valid function. But then you subtract the two image collections. This something that does not work. you can only subtract and add images.
Hi Sam, Congratulations of your work in this topic, it's very important for other persons what wish initializated with tool. I want know how can multiplicate value of imagery for number integer, this intention is for change the units in the products of Google Earth Engine, for example; I have return of process in GEE 0.0005 and i need this value look in 5. Please, help me. PD: Excuse me for my Writing, I'm Spanish speaker.
Hi Carlos, thanks for your feedback! I totally get what you mean and that is indeed possible. Since images are GEE objects, you need to multiply them with a GEE number object. JavaScript won't understand when you try to multiply an object with a number. So what you should do is: image.multiply(ee.Number(10000)) in your case.
It is in the documentation of this specific image source. Each band corresponds to a certain range of wavelengths, and these happen to be named b4 and b5 for red and nir in this dataset
@@ProgramSam If you post the video to bilibili, you will get a lot of fans. Because China has a large number of students who want to see the GEE tutorial.
@@ProgramSam Sending links in the comments will be blocked. If you really want to know, you can leave your gmail or outlook account and I will email it to you.
@@mc8471 Thanks, I have found the videos. I would love to reach more people, but sadly bilibili is chinese only, and that's a language I haven't mastered yet 😉. I'll see if I can contact the uploader. Not that I don't want my videos to be on the site, I just don't reallyappreciate it being uploaded without ever being contacted or properly referenced 👍.
If you want an introduction on how to show images, check out the video about filtering and displaying images first: ruclips.net/video/4w6Mt6HTC2I/видео.html It was never my intention to teach people Javascript, there are already plenty of tutorials about that programming language online, but thanks for your feedback!
For those having the "NIR.subtract" error, just checkout 2:23 to 2:25 in x0.25 speed. He adds .first() to the end of the line. So then the full code for the first line should be:
var image = L8.filterBounds(ee.Geometry.Point(-4, 56.9)).filterMetadata('CLOUD_COVER', 'less_than', 1).first()
Indeed, since the subtract function is meant to operate between images, passing a imageCollection into the function will throw an error. The .first() function is meant to take the first image of the collection. Another way to aggregate to collection to one image could be to take the mean, max, or min values.
Thanks a lot guys... I had an issue earlier trying to combine two images to perform the NDVI analysis and it was returning one image as the result... I just used the "mean" function and it returned both images... Thanks
@@ProgramSam What if i have specific image?
This is the best GEE tutorial on the internet so far! I really appreciate your work, It's really well explained.. Thanks a lot sam!
I love to hear that! Thank you 🤗
This is an excellent tutorial! I highly appreciate your effort in sharing these experiences, which substantially diminish my challenges in learning GEE. Thank you!
Thank you! It brings me joy to hear that 😊
Thank u so much for this series! regards from India :)
Oh yeah, plz do not stop this amazing work, super usefull!
Thanks! I'm glad you find it useful :D
Hi, I understood the image filter properly. My question is how to export a series of images between a range of times, not the median image. I mean how can I get all images from 2017-01-01 to 2017-12-31?
great tutorials sir 😀
Thanks! 😃
I have a question that is not really related to this particular video...
I want to calculate the reflectance of all bands in a specific point, using landsat8...
Is that possible?
Thanks!
i can't perform subtract. How to convert ee.ImageCollection to a ee.Image object? Kindly help. I filtered based on specificity and all. But nothing works
That is indeed a common issue. Even if there is only one image in the image collection, it is still considered a collection (of one image). If you want to convert it, you need some sort of aggregation function. You could do collection.first() to get the first image of your collection. Other options I use often are collection.min(), collection.max(), collection.mean() or collection.median() if the collection has many images and you want to aggregate them into one image, these do the trick. Min() will take the smallest pixel value for each pixel, mean() will calculate the average pixel value of all images in the collection and so on. These functions return an ee.Image that you can use to substract.
Hello sir,
Can you tell me How to Add Map Scale On Google Earth Engine. And Also North Line
Dear Sam,
I wanted to convert the NEX-GDDP temperature data from Kelvin to Celsius, but the code below did not work. I watched your third and fourth videos but still have a problem. Can you help me?
Code:
var dataset = ee.ImageCollection('NASA/NEX-GDDP')
.filter(ee.Filter.date('2018-07-01', '2018-07-02'));
var minimumAirTemperature = dataset.select('tasmin');
var tminnew = dataset.expression(
'tmin-273.15',
{
'tmin': minimumAirTemperature
})
Map.addLayer(
tminnew, minimumAirTemperatureVis, 'Minimum Air Temperature');
Regards,
Javad
Hi Javad!
I think I see what's happening here. you filter your image collection by date. and this gives you a new imageCollection with less images. The expression function however, can only be executed on an Image, not an entire collection. What you are doing is running the expression function on the collection, but then it gives the error that dataset.expression is not a function. What you should do is turn your imageCollection into an image. It goes by fast, but in my video, I add .first() to my collection. this just takes the first image that is in my collection. the variable I end up with then is no longer a collection of images but just a single image. you could also use for example the mean(), max(), min() function to get one image from your filtered collection.
Let me know if it works!
best vids thus far
thank you for the feedback!
what is the difference between B and b here and how you chose b? you changed it in the video when it gave error without explanation
at what timestamp did I do that? Can't find exactly what you are mentioning
does anyone know how to do logarithm calculation in GEE? im trying to do image expression/function for TSS. i'm struggling with logarithm and this "image.expression is not a function". does anyone know the solution? thank you
hi!
I want to display the TSS calculation results with colors in the range, for example TSS 0-10 m / L in yellow. Is that possible?
thanks for your sharing
It is not possible to display a range of values in a certain color although that would be a great addition. There is also no direct function to turn value ranges into classes. But with a bit of creativity it is possible to classify value ranges as shown in this stackexchange: gis.stackexchange.com/questions/264000/reclassifying-raster-values-in-google-earth-engine/264004
After this you could give each created class a chosen color. Let me know if it works out!
tq for tutoring to us. I love your way of teaching. when i running the code I got this error pls guidance in this regard.
drive.google.com/file/d/1wNyiP3OQmrGNCajfXOBn7mBm76ZbfI45/view?usp=sharing
This tutorial helps me a lot, but I still come across a problem. When I finish the code, the console says 'image.expression is not a function'. What's going wrong?
The 'expression' function is used only for ee.Image objects. I Think your variable might not be such an object, so expression would not be a valid function. Could it be you still have an imageCollection object? when you print the variable, as in print(image), the variable type will appear briefly before printing the result. You might want to check that out first ;)
Yes, it's still imageCollection object.
var image = S2.filterBounds(Region).filterMetadata('CLOUD_COVERAGE_ASSESSMENT', 'less_than', 20).filterDate('2017-01-01','2018-08-31');
This line of code produces an ImageCollection COPERNICUS/S2 (84 elements). But I don't know how to convert it to ee.Image object.
Okey so you now have a collection of 84 elements (images) that fit your requirements, but you only want one image. You could do image.first(). This will select the first image of your collection. Or you could do image.median(), which will take the median image of all 84. Both of these operations will give you an ee.Image as result in stead of ImageCollection.
There are other functions as well, such as .average(), .min() to take the lowest values, .max() to take the highest values and so on, but I think .first() or .median() will suit you best!
Problem solved. Thanks a lot.
So the key is to use only one single image when using expressions.
exactly! The expression function can only be used on a single image not on a collection, glad I could help. FYI, the next video will be about how to map functions over entire collections
when i run the code, the console says "NIR.subtract is not function', help me out please.
the subtract function is a function for images only. So I suspect that your NIR is not an image object. Could it be that it is still an image collection (maybe of just one image)? You can turn this into an image by doing NIR.first() for example, which selects the first item in an image collection. Let me know if it works!
@@ProgramSam var image= imageCollection.filterBounds(ee.Geometry.Point(106.6880844,10.8007089)).filterMetadata('CLOUD_COVER','less_than',1);
var RED = image.select('B4');
var NIR = image.select('B5');
var NDVI = NIR.subtract(RED).divide(NIR.add(RED));
Map.addLayer(NDVI)
these are my codes
@@hungnguyenphi4552 Well it is indeed as I mentioned. You filter an image collection, which returns a new image collection. Then the select function selects the band in all the images of the collection, which still is a valid function. But then you subtract the two image collections. This something that does not work. you can only subtract and add images.
@@hungnguyenphi4552 had you solve this problem ?
Hey guys, I believe the problem was that you guys didn't seehim add '.first()' to the end of his first line (checkout 2:23 - 2:25 in slow motion)
Hi Sam,
Congratulations of your work in this topic, it's very important for other persons what wish initializated with tool.
I want know how can multiplicate value of imagery for number integer, this intention is for change the units in the products of Google Earth Engine, for example;
I have return of process in GEE 0.0005 and i need this value look in 5. Please, help me.
PD: Excuse me for my Writing, I'm Spanish speaker.
Hi Carlos, thanks for your feedback! I totally get what you mean and that is indeed possible. Since images are GEE objects, you need to multiply them with a GEE number object. JavaScript won't understand when you try to multiply an object with a number. So what you should do is: image.multiply(ee.Number(10000)) in your case.
@@ProgramSam error: Image.select: Parameter 'input' is required.I am having this error. How to coorect it? pls explain
Best of the best
Thank you!
why B4 =red and B5 = NIR
It is in the documentation of this specific image source. Each band corresponds to a certain range of wavelengths, and these happen to be named b4 and b5 for red and nir in this dataset
I once saw these videos on bilibili,but I'm for the origin resource。
Thanks for letting me know, where they my videos on bilibili? And if so, could you share the link with me?
@@ProgramSam If you post the video to bilibili, you will get a lot of fans. Because China has a large number of students who want to see the GEE tutorial.
@@ProgramSam Sending links in the comments will be blocked. If you really want to know, you can leave your gmail or outlook account and I will email it to you.
@@mc8471 Thanks, I have found the videos. I would love to reach more people, but sadly bilibili is chinese only, and that's a language I haven't mastered yet 😉. I'll see if I can contact the uploader. Not that I don't want my videos to be on the site, I just don't reallyappreciate it being uploaded without ever being contacted or properly referenced 👍.
Not a good video NIR.subtract error. I don’t know any coding show how to make single image
If you want an introduction on how to show images, check out the video about filtering and displaying images first: ruclips.net/video/4w6Mt6HTC2I/видео.html
It was never my intention to teach people Javascript, there are already plenty of tutorials about that programming language online, but thanks for your feedback!
@@ProgramSam Still it doesn't work. Mine is the exact same code of your's.