Exporting images in an image collection from GEE - google-earth-engine

Please I would like to know the best way to export image bands from an Image Collection in Google Earth Engine for use on my local machine. The image collection contains 21 elements which I would like to export as single image bands or an image composite of all 21 elements. How do I go about this please. Below is a code extract I have written. Thanks
var S1_1 = ee.ImageCollection('COPERNICUS/S1_GRD')
.filterBounds(SA)
.filterDate('2016-10-01', '2017-06-01')
.filterMetadata('transmitterReceiverPolarisation', 'equals', ['VV', 'VH'])
.filterMetadata('resolution_meters', 'equals' , 10);

You may want to see this answer which shows you how to turn an image collection into a single band image. From there, use Export.image.toDrive().

Related

Fetching images gallery of 1 product in Commerce.js

Please, tell me how can i fetch all images of 1 individual product in commerce js. Cant find anything in documentation.
So, i have a single product, but instead of uploading just 1 photo, I uploaded 20.
I can only get the very first photo to be displayed. Is there a way to list all 20? There must be a way since commercejs allows more than 1 photo to be uploaded there [thats images of my product][1]
Thanks!
[1]: https://i.stack.imgur.com/Z0eZA.png
You can use the assets list on a product object, see docs here: https://commercejs.com/docs/api/#get-product. You could filter them by is_image if you have other assets attached that aren't images.
const productImages = product.assets.filter((asset) => asset.is_image)
The image object only returns the main image, whereas assets will return the rest.

Can VNImageRequestHandler accepts MLMultiArray as an input? (Without converting to UIImage)

I have two MLModels in my app. The first one is generating an MLMultiArray output which is meant to be used as the second model input.
As I'm trying to make things as performance-best as possible. I was thinking about using VNImageRequestHandler to feed it with the first model output (MLMultiArray) and use Vision resize and rectOfIntersent to avoid converting the first input to an image, crop features, to avoid the need to convert the first output to image, do everything manually and use the regular image initializer.
Something like that:
let request = VNCoreMLRequest(model: mlModel) { (request, error) in
// handle logic?
}
request.regionOfInterest = // my region
let handler = VNImageRequestHandler(multiArray: myFirstModelOutputMultiArray)
Or I have to go through back and forth conversions? Trying to reduce processing delays.
Vision uses images (hence the name ;-) ). If you don't want to use images, you need to use the Core ML API directly.
If the output from the first model really is an image, it's easiest to change that model's output type to an image so that you get a CVPixelBuffer instead of an MLMultiArray. Then you can directly pass this CVPixelBuffer into the next model using Vision.

JMapViewer adding tiles of a region on Panel

Hi there i'm using JMapViewer to show maps in my swing app and I've successfully created a panel with map tiles on it but these map tiles are of a particular area used in demo source of Map Viewer, i'm confused about how can i show the tiles of some particular area i want. Just like Google maps i want to show some location of my country (Pakistan) in the maps and i don't know how can i do it.
Secondly, Please explain what are Layer's and Layer Group in JMapViewer? Just an idea.
Edit: how can i download tiles of Islamabad region and then add them to maps.
What i've learnt from demo is this:
private void loadMapTiles(){
map().setTileSource(new OsmTileSource.Mapnik());
map().setTileLoader(new OsmTileLoader(map()));
}
But this shows some specific area they have set to.
I've downloaded JTileDownloader but i'm confused about the url thing because i don't now where to get the url of some specific area.
Given a JMapViewer named map, something like this should display Islamabad:
Coordinate c = new Coordinate(33.7167, 73.0667);
map.setDisplayPosition(c, 10);
org.openstreetmap.gui.jmapviewer.Demo, included in the distribution, is a complete example that illustrates how to use Layer. Click the Tree Layers Visible checkbox to see the effect.
Addendum: Here's the result using MapQuest-OSM at 11x zoom; Mapnik seems to work, too. If no TileSource includes the tiles you want, you may need one of the approaches mentioned here.

Create new JPG image thumbnail if original file has changed

I have a simple PHP script using imagecreatefromjpeg to create a thumbnail version of original and save it to a new folder. To speed parsing (all done in the back end prior to upload to static site) I am using file_exist before the creation to check it exists and show - if not create new and show. This works fine but if the original image changes the script does not generate as the thumbnail image exists in it's old form.
I guess I need to use MD5 test but as a n00b not sure how to test if the resulting thumbnail version would be different from the existing as produced by the main image.
Current Logic:
if thumb exist == do nothing,
if thumb does not exist == create it
Additional logic
if thumb will change due to change in original == create it,
if thumb will stay the same == do nothing
The existing PHP is very poor and clobbered together so happy for any pointers from a fresh (expert) view.
Thanks, John
You want to check the time the file was modified.
http://php.net/manual/en/function.filemtime.php
if the original file's timestamp is newer than the thumbnail's timestamp, then make a new thumbnail.
Thanks guys - not sure if that will work if the original image was created previously but only just being used eg stock images that are on file elsewhere and then dragged into the /images/ folder to replace existing image but with the same filename.. does the timestamp show the date dragged or when it was created?
If you move the files, the modified timestamp does not change.
If you copy the files, the copies are created by the copy action.
When you create a file, its Date Modified timestamp is the same as its Date Created timestamp.
So if your drag is copying the files, then the modified timestamp is the timestamp of the moment that the files were copied.
It should be enough to compare the last modification date of the thumb and the original image. if the original image is newer than the thumb, you should recreate it.
In simple terms, say we have an image that is a 200x200 image filled with red and only red (so yeah a red square). We create 80x80 thumbnails. If the original image changes but is still just the same red filled square, the thumbnail will not change.
The thing is that in order to detect this you will need to create the thumbnail or apply advanced image comparison techniques, that you may as well save it.
You can however use MD5 to create a one-on-one map from original to thumbnail, by naming the thumbnails as the MD5 hash of the original. The drawback of this approach is that you will need a way to remove unused thumbnails when their originals are no longer used.
To use this approach use something like:
<?php
$thumbname = md5_file($bigimage_path);
if( !file_exists("images/thumbs/$thumbname.jpg") )
{
create_thumb($bigimage_path, $thumbname);
}
?>
This will accomplish that if you have the exact same big image as different filenames, they will all map to the same thumbnail.

Is it possible to resize a SpriteAsset without adding it to the display list?

I have an embedded image asset (with a scale9 grid), and I'm trying to get the bitmapdata when it's resized, but I can't seem to do this without adding it to the display list.
I try this:
spriteAsset.setActualSize(w,h);
spriteAsset.width = w;
bmd.draw(spriteAsset);
But when I then draw out the bitmapdata with graphics.beginBitmapFill(), I just get the original un-stretched image.
Any pointers? Or do I need to take 9 separate BitmapData images and make 9 separate bitmap fills?
Cheers,
-Josh
My experience taking BitmapData.draw() snapshots of scale9 assets has been that the scale9 is discarded, even if the asset has been added to the display list. This is a bug as far as I'm concerned, I don't know if it's been reported.
Aside from the scale9 disappointment, don't forget that BitmapData.draw can take a matrix parameter. By default it's null, meaning the identity matrix (no scale, rotation, etc). To take a snapshot of a transformed asset, you need to provide its transformation matrix...
bmd.draw(spriteAsset, spriteAsset.transform.matrix)
(Haven't double checked this stuff sorry, so ymmv.)
Danjp's solution is good, but if you want to resize the bitmap data itself, try using a scale matrix, ie:
var scaledBitmapData:BitmapData = new BitmapData(newWidth, newHeight);
var scaleMatrix:Matrix = new Matrix();
scaleMatrix.scale(scaleFactor, scaleFactor);
scaledBitmapData.draw(bitmap, scaleMatrix);

Resources