Can not visualize maps in Geemap - Google Colab - geemap

Today 07/07/2022, I am working in Geemap trough Google Colab. I have been working with some codes that have been performed OK, however, today the interactive map is not displayed.
Also I have tried with other public codes, and the issue remains. Has someone experienced this kind of problem? Thanks for help.
A sample of code is given:
rgb2 = ['B8_median','B11_median','B4_median']
# set some thresholds
rgbViz2 = {"min":0.0, "max":3000,"bands":rgb2}
collectionx = ee.ImageCollection('COPERNICUS/S2_SR').filterDate("2020-06-25","2020-09-11").filterBounds(aoi2).filter(ee.Filter.lt("CLOUDY_PIXEL_PERCENTAGE",6))
collectionrgb = collectionx.select('B8','B11','B4', 'B3','B2')
medianx = collectionrgb.reduce(ee.Reducer.median());
#Get information about the bands as a list.
bandNames = medianx.bandNames()
print('Band names: ', bandNames.getInfo())
# initialize our map
map6 = geemap.Map()
map6.centerObject(aoi2, 8)
map6.addLayer(medianx.clip(aoi2), rgbViz2, "S2")
map6.addLayerControl()
map6

Related

Maya Python Mash - How can I add a selection set using Maya Mash API (in python)

Adding the cmds.connectAttr at the end does connect the selection set in Maya in the UI, but that's all it does. It acts as it its not registering.
import maya.cmds as cmds
import MASH.api as mapi
sel = cmds.ls(sl=1, l=1, fl=1)
new_set = cmds.sets(sel, n="custom_set")
obj_name = sel[0].split(".")[0]
shape = cmds.listRelatives(obj_name, s=True, f=1)
print(shape)
shape = "pCylinderShape1" #distribute mesh
cmds.select("|pCylinder2") #main mesh MASH
#create a new MASH network
mashNetwork = mapi.Network()
mashNetwork.createNetwork(name="Custom_placement", geometry="Repro")
shape = "pCylinderShape1"
mashNetwork.meshDistribute(shape, 4)
cmds.connectAttr(new_set+".message", mashNetwork.distribute+".selectionSetMessage")
Closest answer I found was here but I am not a programmer to know what that means.
If anyone can help, I'd much appreciate it.
After a lot of investigation I did manage to find the answer from the provided link.
The code I wrote was only the first part of the solution.
hasMASHFlag = cmds.objExists('%s.mashOutFilter' % (new_set))
if not hasMASHFlag:
cmds.addAttr( new_set, longName='mashOutFilter', attributeType='bool' )
cmds.setAttr( '%s.arrangement' % (mashNetwork.distribute), 4 )
cmds.setAttr( '%s.meshType' % (mashNetwork.distribute), 7 )
Note sure is needed but I noticed when you connect a selection set by default it has an extra attribute called mashOutFilter.
The part that is needed is the .meshType that makes it work.

Google Apps Script: Use array out of spreadsheet

I try to use Google Script Apps (instead of VBA which I am more used to) and managed now to create a loop over different spreadsheets (and not only different sheets in one document) using the forEach function.
(I tried with a for (r=1;r=lastRow; r++) but I did not manage).
It is working now defining the array for the sheetnames manually:
var SheetList = ["17DCu1nyyX4a6zCkkT3RfBSfo-ghoc2fXEX8chlVMv5k", "1rRGQHs_JShPSBIGFCdG6AqXM967JFhdlfQ92cf5ISL8", "1pFDyXgYmvC5gnN5AU5xJ8vGiihwtubcbG2n4LPhPACQ", "1mK_X4Q7ysJQTt8NZoZASBE5zuUllPmmWSJsxu5Dnu9Y", "1FpjIGWTG5_6MMYJF72wvoiBRp_Xlt5BDpzvSZKcsU"]
And then for information the loop:
SheetList.forEach(function(r) {
var thisSpreadsheet = SpreadsheetApp.openById(r)
var thisData = thisSpreadsheet.getSheetByName('Actions').getDataRange()
var values = thisData.getValues();
var toWorksheet = targetSpreadsheetID.getSheetByName(targetWorksheetName);
var last = toWorksheet.getLastRow ()+ 1
var toRange = toWorksheet.getRange(last, 1, thisData.getNumRows(), thisData.getNumColumns())
toRange.setValues(values);
})
Now I want to create the definition of the array "automatically" out of the spreadsheet 'List' where all spreadsheets which I want to loop are listed in column C.
I tried several ideas, but always failed.
Most optimistic ones were:
var SheetList = targetSpreadsheetID.getSheetByName('List').getRange(2,3,lastRow-2,3).getValues()
And I also tried with the array-function:
var sheetList=Array.apply(targetSpreadsheetID.getSheetByName('List').getRange(2,3,lastRow-2,3))
but all without success.
It should be possible normally in more or less one single line to import the array from the speadsheet to the Google apps scripts?
I would very much appreciate if someone could please give me a hint where my mistake is.
Thank you very much.
Maria
I still did not manage to put the array as I wanted it initially, but now I found a workable solution with the For Loop which I want to share here in case someone is looking for a similar solution (and then finds at least my workaround ;) )
for (i=2; i<lastRow;i++){
var SheetList = targetSpreadsheetID.getSheetByName('List').getRange(i,3).getValues()
Logger.log(SheetList);
var thisSpreadsheet = SpreadsheetApp.openById(SheetList);
... // the rest identical to loop above...
Don't hesitate to add your comments or advice anyhow, but I will mark the question as closed.
Thanks a lot.
Maria

TF 2 - Keras - Merging two seperately trained models to a new ensemble model

Newbie here ;)
I need your help ;)
I have following problem:
I want to merge two TF 2.0 - Keras Models into a new Model.
Expect for example a ResNet50V2 without the head, and retrained on new data - saved weights are provided and loaded:
resnet50v2 = ResNet50V2(weights='imagenet', include_top=False)
#model.summary()
last_layer = resnet50v2.output
x = GlobalAveragePooling2D()(last_layer)
x = Dense(768, activation='relu', name='img_dense_768')(x)
out = Dense(NUM_CLASS, activation='softmax', name='img_output_layer')(x)
resnet50v2 = Model(inputs=resnet50v2.input, outputs=out)
resnet50v2.load_weights(pathToImageModel)
Expect for example a Bert Network retrained on new data - saved weights are provided, in the same way as shown before.
Now I want to skip the last softmax layer from the two models and "merge" them into a new Model.
So I took the layer before the last layer, which names I know:
model_image_output = model_image.get_layer('img_dense_768').output
model_bert_output = model_bert.get_layer('bert_output_layer_768').output
I built two new models with these informations:
model_img = Model(model_image.inputs, model_image_output)
model_bert = Model(model_bert.inputs, model_bert_output)
So now I want to concatenate the outputs of the two models into a new one and add a new "head"
concatenate = Concatenate()([model_img.output,model_bert.output])
x = Dense(512, activation = 'relu')(concatenate)
x = Dropout(0.4)(x)
output = Dense(NUM_CLASS, activation='softmax', name='final_multimodal_output')(x)
model_concat = Model([model_image.input, model_bert.input])
So far so good, model code seemed to be valid but then my knowledge ends.
The main questions are:
Also if the last softmax layers are skipped, the loaded weights should be still available or ?
The new concatened model wants to be build, ok but this ends in this error message, which I only partially understand:
NotImplementedError: When subclassing the Model class, you should implement a call method.
Is there another way to create for example the whole ensemble network and load only the pretrained parts of it and leave the rest beeing trainable?
Am I missing something? I never did subclassing the model class? If so, it was not intended XD
May I ask kindly for some hints ?
Thanks in advance!!
Kind regards ragitagha
UPDATE:
So to find my mistake more quickly and provide the solution in a more precise way:
I had to change the lines
concatenate = Concatenate()([model_img.output,model_bert.output])
x = Dense(512, activation = 'relu')(concatenate)
x = Dropout(0.4)(x)
output = Dense(NUM_CLASS, activation='softmax', name='final_multimodal_output')(x)
model_concat = Model([model_image.input, model_bert.input])
to:
concatenate = Concatenate()([model_img.output,model_bert.output])
x = Dense(512, activation = 'relu')(concatenate)
x = Dropout(0.4)(x)
output = Dense(NUM_CLASS, activation='softmax', name='final_multimodal_output')(x)
model_concat = Model([model_image.input, model_bert.input], output)

How to make a directory on iphone using codenameone?

This sounds like a ridiculous question but I cannot for the life of me make a directory on ios using codenameone. Has anyone done it ? Here is what I try (some dumb tests some not so dumb, im getting desperate here):
FileSystemStorage fs = FileSystemStorage.getInstance();
fs.mkdir("ZZZTESTA");
fs.mkdir("ZZZTESTB");
String testpath = fs.getAppHomePath()+"/xxxtesta";
fs.mkdir(testpath);
String testpathb = fs.getAppHomePath()+"xxxtestb";
fs.mkdir(testpathb);
String testpathC = fs.getAppHomePath()+"xxxtest/";
fs.mkdir(testpathC);
String nativetest = fs.toNativePath(testpathb);
fs.mkdir(nativetest);
String nativetestb = fs.toNativePath(testpathC);
fs.mkdir(nativetestb);
I have done all kinds of experiments but ALWAYS I get : Failed to create directory xxxxx.. I will fly to your location and shower you with gifts if you can help :)
These would work:
String testpathb = fs.getAppHomePath()+"xxxtestb";
fs.mkdir(testpathb);
String testpathC = fs.getAppHomePath()+"xxxtest/";
fs.mkdir(testpathC);

Need to figure out how to use DeepZoomTools.dll to create DZI

I am not familiar with .NET coding.
However, I must create DZI sliced image assets on a shared server and am told that I can instantiate and use DeepZoomTools.dll.
Can someone show me a very simple DZI creation script that demonstrates the proper .NET coding technique? I can embellish as needed, I'm sure, but don't know where to start.
Assuming I have a jpg, how does a script simply slice it up and save it?
I can imagine it's only a few lines of code. The server is running IIS 7.5.
If anyone has a simple example, I'd be most appreciative.
Thanks
I don't know myself, but you might ask in the OpenSeadragon community:
https://github.com/openseadragon/openseadragon/issues
Someone there might know.
Does it have to be DeepZoomTools.dll? There are a number of other options for creating DZI files. Here are a few:
http://openseadragon.github.io/examples/creating-zooming-images/
Example of building a Seadragon Image from multiple images.
In this, the "clsCanvas" objects and collection can pretty much be ignored, it was an object internal to my code that was generating the images with GDI+, then putting them on disk. The code below just shows how to get a bunch of images from file and assemble them into a zoomable collection. Hope this helps someone :-).
CollectionCreator cc = new CollectionCreator();
// set default values that make sense for conversion options
cc.ServerFormat = ServerFormats.Default;
cc.TileFormat = ImageFormat.Jpg;
cc.TileSize = 256;
cc.ImageQuality = 0.92;
cc.TileOverlap = 0;
// the max level should always correspond to the log base 2 of the tilesize, unless otherwise specified
cc.MaxLevel = (int)Math.Log(cc.TileSize, 2);
List<Microsoft.DeepZoomTools.Image> aoImages = new List<Microsoft.DeepZoomTools.Image>();
double fLeftShift = 0;
foreach (clsCanvas oCanvas in aoCanvases)
{
//viewport width as a function of this canvas, so the width of this canvas is 1
double fThisImgWidth = oCanvas.MyImageWidth - 1; //the -1 creates a 1px overlap, hides the seam between images.
double fTotalViewportWidth = fTotalImageWidth / fThisImgWidth;
double fMyLeftEdgeInViewportUnits = -fLeftShift / fThisImgWidth; ; //please don't ask me why this is a negative numeber
double fMyTopInViewportUnits = -fTotalViewportWidth * 0.3;
fLeftShift += fThisImgWidth;
Microsoft.DeepZoomTools.Image oImg = new Microsoft.DeepZoomTools.Image(oCanvas.MyFileName.Replace("_Out_Tile",""));
oImg.ViewportWidth = fTotalViewportWidth;
oImg.ViewportOrigin = new System.Windows.Point(fMyLeftEdgeInViewportUnits, fMyTopInViewportUnits);
aoImages.Add(oImg);
}
// create a list of all the images to include in the collection
cc.Create(aoImages, sMasterOutFile);

Resources