I'm new with ArcGis WebAppbuilder.
I am building my own custom widget with which I draw a polyline on the map from the coordinates of a satellite.
I have a given starting TLE,for example:
LEMUR-2-TENNYSONLILY
1 52732U 22057A 22171.76649313 .00007639 00000+0 45185-3 0 9997
2 52732 97.5213 286.3842 0010146 168.0171 192.1302 15.11692075 3937
I use Esri's function for converting to coordinates of this TLE which gives me in output: x: 106.18417662732989, y: 6.539393499416327. these coordinates then change based on a timestamp that changes from hour to hour given a start date and an end date.
With these coordinates I use the whole point construction procedure the esri method, create an array of points, add it to the polyline with .addPath() and everything works.
let date1 = new Date(this.dt1.value);
let date2 = new Date(this.dt2.value);
let hours = Math.round(Math.abs(date1 - date2) / 36e5);
let stampa = date1;
let polylineSymbol = new SimpleLineSymbol();
let polylineSymbol2 = new SimpleLineSymbol();
let coordinate = [];
let array = new Array(2);
let arrayTest= [];
for (let i = 0; i < hours; i++) {
stampa = this.addHours(1, date1);
coordinate[i] = this.getSatelliteLocation(stampa, this.line1.value, this.line2.value);
array[i] = new Point( [coordinate[i].x , coordinate[i].y], new SpatialReference({wkid: 102113}));
// console.log(array[0])
arrayTest.push(new Point( [coordinate[i].x , coordinate[i].y ], new SpatialReference({wkid: 102113})));
}
console.log(arrayTest)
let polyline = new Polyline(new SpatialReference({wkid: 102113}))
polyline.addPath(arrayTest);
polyline = webMercatorUtils.geographicToWebMercator(polyline);
this.map.graphics.clear();
this.map.graphics.add(new Graphic(polyline, polylineSymbol2));
The problem is that it always remains limited to one portion of the map and if I try to invert the coordinates it comes off the screen.
enter image description here
I have tried testing different SpatialReference and related "wkid" but it keeps giving me the same problem.
Can you tell me if I am forgetting something?
I thank you for any reply
I am creating an interactive Maths quiz with 9 triangles generated as objects. The user selects a triangle from a drop-down list and its image and dimensions appear and a variable (thisOne) is set as the number of the triangle (1 to 9).
The user inputs their answer (the area of the triangle).
I would have thought that I could generate the correct answer with something like this
correctAnswer = ("triangle_"+ thisOne).triArea()
but it doesn't work.
My basic question is how do I access the properties or methods of an individual object in a list of objects?
Any help appreciated
<!-- ---------------- Triangle object ----------------- -->
function Triangle(triSrc, triName, triBase, triHeight, triUnits){
this.triSrc = triSrc;
this.triName = triName;
this.triBase = triBase;
this.triHeight = triHeight;
this.triArea = function(){
return triBase * triHeight /2
};
this.triUnits = triUnits;
}
var triangle_1 = new Triangle('tri_q_area_1','right angle triangle',34,20,'m2');
var triangle_2 = new Triangle('img/tri_q_area_2.png','right angle triangle',16,16,'cm2');
var triangle_3 = new Triangle('img/tri_q_area_3.png','right angle triangle',15,8,'km2');
var triangle_4 = new Triangle('img/tri_q_area_4.png','right angle triangle',15,9,'cm2');
var triangle_5 = new Triangle('img/tri_q_area_5.png','scalene', 20,12,'cm2');
var triangle_6 = new Triangle('img/tri_q_area_6.png','scalene', 200,130,'cm2');
var triangle_7 = new Triangle('img/tri_q_area_7.png','scalene', 20,16,'m2');
var triangle_8 = new Triangle('img/tri_q_area_8.png','scalene', 28,16,'km2');
var triangle_9 = new Triangle('img/tri_q_area_9.png','scalene', 54,38,'yards2');
are you ok with have a list?
<!-- ---------------- Triangle object ----------------- -->
function Triangle(triSrc, triName, triBase, triHeight, triUnits){
this.triSrc = triSrc;
this.triName = triName;
this.triBase = triBase;
this.triHeight = triHeight;
this.triArea = function(){
return triBase * triHeight /2
};
this.triUnits = triUnits;
}
var triangles [
new Triangle('tri_q_area_1','right angle triangle',34,20,'m2'),
new Triangle('img/tri_q_area_2.png','right angle triangle',16,16,'cm2'),
new Triangle('img/tri_q_area_3.png','right angle triangle',15,8,'km2'),
new Triangle('img/tri_q_area_4.png','right angle triangle',15,9,'cm2'),
new Triangle('img/tri_q_area_5.png','scalene', 20,12,'cm2'),
new Triangle('img/tri_q_area_6.png','scalene', 200,130,'cm2'),
new Triangle('img/tri_q_area_7.png','scalene', 20,16,'m2'),
new Triangle('img/tri_q_area_8.png','scalene', 28,16,'km2'),
new Triangle('img/tri_q_area_9.png','scalene', 54,38,'yards2')
];
and then do triangles[thisOne].triArea()
You should use an array for this sort of thing. Here's an example:
<!-- ---------------- Triangle object ----------------- -->
function Triangle(triSrc, triName, triBase, triHeight, triUnits){
this.triSrc = triSrc;
this.triName = triName;
this.triBase = triBase;
this.triHeight = triHeight;
this.triArea = function(){
return triBase * triHeight /2
};
this.triUnits = triUnits;
}
var triangle = []; // declare the array;
// note that i'm skipping index 0 to keep with your sample, that is not normally a smart thing to do!
// assign to indices of the array, no need to declare individual elements.
triangle[1] = new Triangle('tri_q_area_1','right angle triangle',34,20,'m2');
triangle[2] = new Triangle('img/tri_q_area_2.png','right angle triangle',16,16,'cm2');
triangle[3] = new Triangle('img/tri_q_area_3.png','right angle triangle',15,8,'km2');
triangle[4] = new Triangle('img/tri_q_area_4.png','right angle triangle',15,9,'cm2');
triangle[5] = new Triangle('img/tri_q_area_5.png','scalene', 20,12,'cm2');
triangle[6] = new Triangle('img/tri_q_area_6.png','scalene', 200,130,'cm2');
triangle[7] = new Triangle('img/tri_q_area_7.png','scalene', 20,16,'m2');
triangle[8] = new Triangle('img/tri_q_area_8.png','scalene', 28,16,'km2');
triangle[9] = new Triangle('img/tri_q_area_9.png','scalene', 54,38,'yards2');
// now you only need the index to address a specific element:
var correctIndex = 4;
var correctAnswer = triangle[correctIndex];
// visualize it in the console
console.log(correctAnswer);
There are four tiles (path:41,row:35/path:41,row:36/path:42,row:35/path:42,row:36) of LANDSAT 8 surface reflectance that cover my study area. I want to remove only images(tile) with path 42 and row 36 from this collection. How can I do that?
Here is my code:
Map.centerObject(table);
Map.addLayer(table);
var sd = '2015-01-01';//Start Date
var ed = '2016-01-01';//End Date
var suro = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterBounds(table)
.filterDate(sd,ed)
//.filter(ee.Filter.and(ee.Filter.notEquals('WRS_PATH',42),ee.Filter.notEquals('WRS_ROW',36)))
.filter(ee.Filter.lt('CLOUD_COVER', 45));
var sur = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterBounds(table)
.filterDate(sd,ed)
//.filter(ee.Filter.and(ee.Filter.notEquals('WRS_PATH',42),ee.Filter.notEquals('WRS_ROW',36)))
.filter(ee.Filter.lt('CLOUD_COVER', 45))
//Map a function to mask clouds and negative values
.map(function(img){
var idd = img.id();
// Bits 3 and 5 are cloud shadow and cloud, respectively.
var cloudShadowBitMask = 1 << 3;
var cloudsBitMask = 1 << 5;
// Get the pixel QA band.
var qa = img.select('pixel_qa');
// Both flags should be set to zero, indicating clear conditions.
var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
.and(qa.bitwiseAnd(cloudsBitMask).eq(0));
// Return the masked image, scaled to reflectance, without the QA bands.
var img2 = img.updateMask(mask).multiply(0.0001).select("B1").rename(idd);
//Mask negative values from images
var mask2 = img2.gt(0);
return img2.multiply(mask2);
})
.toBands()
.clip(table);
Map.addLayer(sur);
var imColl_sur = sur.getInfo().bands;
print(imColl_sur);
print(imColl_sur.length);
for (var i = 0; i < imColl_sur.length; i++) {
//Image Load
var im = sur.select(imColl_sur[i]["id"]);
//var id = imColl_sur[i]["id"];
//var im = ee.Image.load(id);
//Image Properties from original collection
var idl = suro.getInfo().features[i]["properties"]["LANDSAT_ID"];
var st = suro.getInfo().features[i]["properties"]["SENSING_TIME"];
var sza = (suro.getInfo().features[i]["properties"]["SOLAR_ZENITH_ANGLE"])
.toString();
//Download
Export.image.toDrive({
image: im,
description: 'L8_surReflectance_B1_'+idl.slice(10,26)
+st.slice(11,13)+st.slice(14,16)+'_'
+sza.slice(0,2)+sza.slice(3,8),
scale: 30,
region: table,
maxPixels: 1e9
});
}
Edit:
Combining filters probably works somehow, and would be more elegant.
But you can use a second approach: create a new metadata variable combining ROW and PATH, and filter based on it:
var geometry = ee.Geometry({"type":"Polygon","coordinates":[[[-98.01249999999999,41.430123208731864],[-98.01249999999999,38.809492348693325],[-92.03593749999999,38.809492348693325],[-92.03593749999999,41.430123208731864]]],"geodesic":false,"evenOdd":true})
var sd = '2015-01-01';//Start Date
var ed = '2016-01-01';//End Date
var suro = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterBounds(geometry)
.filterDate(sd,ed)
.map(function(image){
return image.set({'WRS_PATHROW':{'path':image.get('WRS_PATH'),
'row':image.get('WRS_ROW')}
})})
.filter(ee.Filter.neq('WRS_PATHROW', {'path':25, 'row':32}))
You can combine two filters with an ee.Filter.and to remove any images that have WRS_PATH=21 and WRS_ROW=32:
var filters = ee.Filter.and(
ee.Filter.neq('WRS_PATH',21),
ee.Filter.neq('WRS_ROW',32)
);
var suro = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterBounds(geometry)
.filterDate(sd,ed)
.filter(filters);
I've taken a look at all the other questions but basically, I have a long list of coordinates as a string that looks like this: "42.2723998, -81.23239 ... 42.84099, -81.3990398" which I have use javascript .split(" , "); on so that its now an array called coordinate[] of strings each holding one coordinate and then using the below code:
// create a coordinate Array
var polygonCoords = [];
// creates a new LatLng
var j = 0;
var z = j + 1;
while (z < coordinate.length) {
if ((j%2) === 0) {
var co1 = parseFloat(coordinate[z]);
//document.write(coordinate[j]);
var co2 = parseFloat(coordinate[j]);
//document.write(co2);
var newLatLng = new google.maps.LatLng(co1,co2);
polygonCoords.push(newLatLng);
} else {
var co2 = parseFloat(coordinate[z]);
var co1 = parseFloat(coordinate[j]);
var newLatLng = new google.maps.LatLng(co1,co2);
polygonCoords.push(newLatLng);
}
z++;
j++;
}
but when I print out the polygonCoords array, it always returns the longitude as 0 and I've also parsed it from a string as well using parseFloat(). Also when I explicitly return the longitude by its own, it returns the actual number. I just need it to work so that I can create an array of LatLngs that I can later use as a path for a polygon.
Ok, I've fixed it, somehow when I grabbed the longitude from the kml file, it would be in the form of 0 -81.290390... and so whenever i parsed it into float, it would recognize it as 0 instead of -81.293848. Now its done properly, and printing out the correct floats.
http://www.leemon.com/crypto/BigInt.js
I am using the leemon bigint.js library, but I am having trouble figuring out how to divide one big number by another. Here is what I have so far:
var a = str2bigInt("100",10);
var b = int2bigInt("5", 10);
var result = [];
var r = [];
divide_(a,b,result,r)
alert(bigInt2str(result,10));
but when I alert(result) the output is 0. The result should be 20? Can anybody see what I am doing wrong?
Cheers
I suppose the line
var b = int2bigInt("5", 10);
should be
var b = str2bigInt("5", 10);
The function int2bigInt expects an integer, not a string.
Apparently, this BigInt.js library expects the result arrays to already have sufficient length to store the result; using empty arrays doesn't work.
This code however works as expected:
var a = str2bigInt("100",10);
var b = int2bigInt("5", 10);
var result = new Array(2);
var r = new Array(2);
divide_(a,b,result,r);
alert(bigInt2str(result,10));