Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

New answers tagged

0

The following code shows my approach to get landsat8_sr data from multiple years with multiple images from each year calculate mean value for each year calculate min mask for each year (mask only if cloud appear in all images in a year) calculate max mask for all years (mask as long as cloud appears in one year) // Landsat 8 Cloud Masking Example (source:...


3

There are two issues in your code, first, the image that you are looking for is not in the collection that you specified, second, the name of the image is not the same as the one in sentinel hub. What I did here was to first limit the area of interest by drawing a polygon, and then filter the sentinel 2 collection by date and area of interest. Map....


1

You can use ee.ImageCollection.mosaic() to convert your image collection to an image, and ee.Image.clip() to clip the image to a specified geometry/polygon. For example: // Define an example geometry. var geom = ee.Geometry.Point(-121.646, 43.762).buffer(1e4); Map.centerObject(geom); var naip = ee.ImageCollection("USDA/NAIP/DOQQ") .filterDate('2011-07-03'...


1

Those strips look like the different overpass lines. In short, there were slightly different ground conditions on each of the three "before" days shown in your data which caused the sensor to record slightly different values for each day. For example if one day had more overall ground moisture it's going to show up as a darker image. The images probably don'...


1

Ordering is alphabetical, which is in case of images from 1 path/row combination equal to the acquisition date. Because you are selecting images from different path row combinations the ordering is not truly chronological and you should define the ordering of your image collection. With respect to your second question, you'll have to use getInfo's probably:...


0

So after a bit of fiddling I managed to work out the issue. It turns out that rather I needed to apply the expression to the image collection, then calculate the means for the regions, rather than the other way around as I was doing initially. So apply the expression to an image collection, then use the reduce functions to calculate the average expressions ...


0

It looks like your KML has not been converted to fusion table properly. There are no rows/features. Fusion tables are getting shut down after December 3rd anyways so it might be a better idea to go a different route. One way is to conver the KML to SHP and then upload that directly to GEE.


2

Here is an alternative approach that avoids nested map() calls, ee.Image.clip(), ee.Algorithms.If(), and accumulating results with a dictionary. Modify the cloud masking function to add a band cloud_flag that indicates whether or not there is a cloud. // Copyright 2019 Google LLC. // SPDX-License-Identifier: Apache-2.0 var cloudMaskL457 = function(image) {...


0

If you want to download the masked image, just create a new clipped variable and export it. Add this piece of code to the end your script (I selected bands 4, 3 and 2 in order to get an RGB): // create clipped RGB var clipped = above10.select(['B4','B3','B2']).clip(geometry) // Export clipped with your chosen parameters Export.image.toDrive({ image: ...


0

Something like this might work? You could improve the naming of your plot function I gues.. /** * Function to mask clouds based on the pixel_qa band of Landsat SR data. * @param {ee.Image} image Input Landsat SR image * @return {ee.Image} Cloudmasked Landsat image */ var cloudMaskL457 = function(image) { var qa = image.select('pixel_qa'); // If ...


0

I have an idea (not sure if it is right). First, you can add a property month for each image in your ImageColleciton. Then, calculate NDVI by ImageCollection.map(NDVIfunction), Finally, obtain the desired NDVI maximum per month by ee.ImageCollection.aggregate_max. Hope this will help you.


2

The error “Remote request too large …” is an unfortunate limitation — unfortunate in that it really shouldn't exist, and it's also not worded very well. What it actually means is that you're somehow trying to compute an image that's too big (number of pixels times number of bytes needed to store each pixel). Most likely, this is due to your reprojection and ...


0

I've tried a few different versions with your code but actually nothing is wrong with it. You are trying to export a composite image with 11 bands as 1 GeoTIFF image. Meaning the image you are seeing with stripes is having information of 11 bands per pixel. You need to open this with a remote sensing or GIS program such as QGIS in order to visualize properly....


2

The image you are looking for is not currently available in the Google Earth Engine repository. If you know that the image exists, you should report it. The best way to know if an image is in the repository is creating a collection and then printing it. For example, if you want to check the images of the tile T15SXD in june 2018 write the following: // ...


2

The issue is in the visualization parameters. If you see the documentation for ee.data.getMapId you can see in the accepted parameters: bands (not band), and it must be a list of bands. So var viz = { bands: ['VV'], min: -50.0, max: -10, };


0

Found your bug. It is so small, it is easy to overlook. your seriesProperty isn't in "quotes". Modify your code in your ui.Chart.image.seriesByRegion() function dictionary. so that the series property is in quotes. It should work. seriesProperty: "FID_incend",


0

Thank you very much. This helps me a lot. But now I need each Feature as a Polygon because I want to search for Data in the new Polygon. I always get an Error for the code like: "ImageCollection (Error) Feature, argument 'geometry': Invalid type. Expected: Geometry. Actual: Feature." Here is my Code var bounds_AOI_West = bounds_AOI.filterMetadata("...


2

The instrumentMode for HH-HV or HV is EW and not IW. Also, there is no 10m resolution available for these polarizations. To make sure you pick your geometry right: HH-HV or HH polarization for the monitoring of polar environments, sea-ice zones VV-VH or VV polarization for all other observation zones (with an exception for the Baltic Sea observed ...


0

Your problem lies elsewhere. when you use .min() Reduces an image collection by calculating the minimum value of each pixel across the stack of all matching bands.. This does not find the image with the lowest "CLOUD_COVERAGE_ASSESSMENT" Your code is nearly there, as in the .sort() you put the collection in order of your cloud coverage. Just change your ....


0

Looking for this? var img_cropRice = ee.List(img_cropLC.get('cropland_class_names')) // knowing rice is at the third position: var rice = img_cropRice.get(3); Link


0

Not the best answer, and would only work with your code. This solution is not at all portable. You can add this to your code at the bottom. var bounds_AOI_West = bounds_AOI.filterMetadata("system:index","equals","+5270+8474").first() var bounds_AOI_Center = bounds_AOI.filterMetadata("system:index","equals","+5308+8474").first() var bounds_AOI_East = ...


0

The problem lies in 2 places. chirps.sort('system:time_start', false); You .sort(), but don't actually place the result in a variable. (so nothing happens) var lastimg=chirps.limit(1, 'system:time_start').first(); The second, is when you use the .limit() function, you added the property. Which is also a sort... and by not putting a false, it went with ...


0

found it: var range = chirps.reduceColumns(ee.Reducer.minMax(), ["system:time_start"]) print('Date range: ', ee.Date(range.get('min')), ee.Date(range.get('max')))


2

You can do it easily by converting the timestamp of the image to a date object and then just requesting the "year" property. Modify your code as follows. // This function adds a time band to the image. var createTimeBand = function(image) { // get the system:time_start property and extract the year var timestamp = ee.Date(image.get('system:time_start')...


2

The full dataset is for continental US. A bit much to turn into points. If you zoom in further to your image, you can see that it isn't individual pixels, but actually pixel groups. It is easy to vectorise this with a reduceToVectors() function, but without knowing what the aim of the Feature Collection, it is difficult to tell you which direction to take....


0

There are 2 issues here: The documentation for List.get says: ee.List.get Returns the element at the specified position in list. A negative index counts backwards from the end of the list. Usage Returns List.get(index) Object Argument Type Details this: list List index Integer when using the expression for (var i in ListofNumbers)...


2

Note that the new, better way to do this is with imageCollection.toBands().


2

I believe the issue is in your feature collection. I can't access it as you don't have it shared, so can't investigate what is going on there. But I have tested the script with a random geometry placed on the map, and had no issues. Check that your feature collection doesn't have too many features to it. ================================== EDIT Thanks ...


1

A common technique in Earth Engine to export things like lists, values etc which are too large is to first create a feature collection from them and then export them. The feature collection need not have any geometry, so you can create features with empty geometry with the values of interest as properties. In your case, the following snippet does the trick ...


2

ee.Image.reduceToVectors converts an image to features, so its return value is a FeatureCollection. You cannot export a FeatureCollection using Export.image because a FeatureCollection is not an Image. If you want an image where the features have been drawn, then use ee.Image.paint after reduceToVectors. (It requires an image, which is the "background" for ...


0

It might be worth going through the GEE documents for some scripting: https://developers.google.com/earth-engine/ You'll end up with an ImageCollection (in your example 39 images) which you either need to reduce to 1 image by selecting the first image with .first() If you trully want to add all images you need to create an featureCollection from your ...


0

I think getting box as a dict makes it JSON serializable, try: task = ee.batch.Export.image.toCloudStorage( image=imageOfSeries.toArray(), description=AssetName, fileNamePrefix=AssetName, bucket=GCbucketName, scale=scale, region=box.getInfo(), fileFormat='TFRecord', formatOptions={ 'patchDimensions': [patch_size, ...


0

Okay so this worked: var res = toplot.map(function(image) { var reduced = image.reduceRegion({geometry: ROI, reducer: ee.Reducer.mean(), crs: 'EPSG:4326', scale: scale}) return image.set('mean', reduced); }); var vals = res.aggregate_array('...


1

You will have to make a long addition to your script to extract not from the mosaic, but from a collection for each of your indices. Then you reduce the images with .reduceregion() and add it as a property to a feature. After that, you create a collection of the feature so that it can be exported to a csv. ////////////////// // Export index results as a ...


0

It is not a problem of Google colad, but, as I said in my comment, you must install rtree. warn("Cannot generate spatial index: Missing package `rtree`.") Look at Overlay Function from GeoPandas Not Working To be able to use the overlay function you need more than just install geopandas, you need install rtree, but rtree is a wrapper to the C library ...


0

In no way the best solution to this as it will require some formatting of the csv after download. But it was the quickest I could do without having to spend way too much time re-writing all your code. When you want to export to a csv, what you export is the properties of a feature collection. So I made a null geometry feature collection containing your ...


2

Just similar as you retrieve the image from the imageSelect function, you can get the image inside the polySelect function. Note that I changed the Map.addLayer to Map.Layers.set(), so the image is overwritten and not added,which is probably what you want making this kind of UI tools. var reduceTheRegion = function(){ var poly = polySelect.getValue(); ...


1

You are mixing client-side with server-side code. See the GEE help for that. Hopefully, this will show you how to work with a client-side for loop to export multiple featureCollections. As your asset is not shared, I am unsure if the code will work for the buffer you're trying to make. // get the list of features (client side) var Tables = ee.data.getList({...


1

Reduceregions should be applied to single images, instead of an image collection. Therefore, you shoul dmap over the image collection: // map over the collection (reduceRegions works on single imagery) var nl = nighttimeLights.map(function(image){ var year = image.date().format('YYYY'); var feats = image.reduceRegions({ collection: shp, reducer:...


1

You can map a function that operates on an image over an entire imageCollection before reducing. For example, I use snippets from your code above to generate a cloud-free composite of Ghana by defining the masking functions first, then applying them to the imageCollection. Note that I expanded the date range because it looks like 2013 may have some ...


2

You can retrieve the info using getInfo and save it to local file # put centroids in a list centroids_list = centroids.toList(centroids.size()).map(lambda f: ee.Feature(f).geometry().centroid()).getInfo() # get only coordinates data = [p['coordinates'] for p in centroids_list] # file name filename = 'test.txt' # write file with open(filename, 'w+') as ...


2

The issue is that you are creating the collection based on the date, and then clipping every image with your function. (even those that don't contain your geometry .... the whole globe) Change your code with a .filterBounds(geometry) before doing the clipping. // Load the Sentinel-1 ImageCollection. var sentinel= ee.ImageCollection('COPERNICUS/S1_GRD'); //...


1

I think this might be what you are looking for? Adapted from this post. Apologies is it's a bit cumbersome. //get projection and scale var proj = sst.projection(); var scale = proj.nominalScale() // get coordinates image var latlon = ee.Image.pixelLonLat().reproject(proj); //Create a geometry object at the true center of the pixel var coords = latlon....


1

I personally solved this issue after an aid from a friend of mine. The problem is not due to Python itself but by its interpreter. So, if you're using Eclipse follow this procedure: Window > Preferences > PyDev > Editor > Code Analysis > Undefined > Undefined variable from import > Ignore This is also quite useful if you want to not show those boring ...


2

To answer your questions: As long as you have authenticated your system for using Earth Engine (i.e. earthengine authenticate) it should run. I am not sure how it behaves with a cron job though...you may want to set up a service account and use that to authenticate at the beginning of your script as described in the docs. The Earth Engine Python API comes ...


0

Currently, there is no way to export a collection of images; an export task can only generate one image, and each export task requires a separate call to the server and, more importantly, will be scheduled and run separately. (There is an export type that produces multiple images — Export.map — but it would be quite tedious and inconvenient to rearrange ...


0

My quick solution would be for one class (e.g. water): mask water pixels from classified image add Landsat DN band values create histogram from image var water = upsampled.eq(0) water = water.selfMask() Map.addLayer(water, {}, "Water") water = water.addBands(landsatComposite).select('B[1-4]')` // Pre-define some customization options. var options = {...


0

I'm experiencing a somehow similar problem. When I tried to extract Sentinel2 level 2A data for july2019 I found no data for several dates. There is a gap between the 10th and 25th of july. var sent2a=ee.ImageCollection("COPERNICUS/S2_SR") .filterDate('2019-07-10', '2019-08-28') .filterMetadata('...


2

You will need to rework the data calculated in ui.Chart.image.series() into a feature collection. Then you will add a property for each different month and you can plot each month using ui.Chart.feature.groups(). // put the data similar as presented in the chart above in a featureCollection var featsPrecipitation = ee.FeatureCollection(precipitation.map(...


1

For your particular example, you can do this: // map over the dictionary var mappedDictionary = dictionary.map(function(key, val){ return 'noData'; }); If you have non-null data in the dictionary, you could also use the val argument, see the example in the link. Link code


Top 50 recent answers are included