What format input geometry needs to have to be able search by geometry/bbox? - arcgis

I'm trying to filter data here, by specific USA state - https://hydro.nationalmap.gov/arcgis/rest/services/nhd/MapServer/12/query
However, I'm not sure how to use the "Input Geometry" field (in which format geometry needs to be).
Could someone send me an example with polygon applied as a one filter AND in Where there will be "FCODE"=46006 filter as well?

For input geometry you need to provide a valid geometry object in JSON format, as specified by ESRI: enter link description here
Within the JSON you can specify type of geometry (point, poly etc) as well as spatial reference in wkid or wkt format.
{
"xmin": -109.55,
"ymin": 25.76,
"xmax": -86.39,
"ymax": 49.94,
"spatialReference": {
"wkid": 4326
}
}
Finally, the ArcGIS REST API documentation explains what other parameters to pass to your HTTP GET verb to specify the 'where' clause.
Here is an example call to your service: https://hydro.nationalmap.gov/arcgis/rest/services/nhd/MapServer/12/query?where=FCODE=46006&geometry={
"xmin": -180,
"ymin": -90,
"xmax": 180,
"ymax": 90,
"spatialReference": {
"wkid": 4326
}
}&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&units=esriSRUnit_Foot&outFields=*&returnGeometry=true&returnTrueCurves=false&returnIdsOnly=false&returnCountOnly=false&f=pjson

Related

Google Sheets API Chart - change a given datapoint fillcolor

In Google Sheets API, when using a chart shape, how can I colour a given datapoint a custom RGB? In the image below I have changed the color of 3 random datapoints. Is this possible?
It is possible to change the color and use a custom RGB color. If you already have the chart created, all you need to do is to use the batchUpdate method, and when creating the request include updateChartSpecRequest, then you'll need to select the type of chart that you are updating. In your case, based on the screenshot it would be basicChart, then from the chart, you want to update the series since those are the ones that generate the columns, and you can modify the color parameter there according to the official documentation.
Depending on what you want to end up doing, the structure of the request may end up being similar to this:
Request:
'request' : [
{
"updateChartSpec": {
"chartId": integer,
"spec": {
"basicChart": {
"series": [
{
"color": {
{
"red": number,
"green": number,
"blue": number,
"alpha": number
}
},
}
]
},
}
},
}
]
Note:
If you want to do it upon creation, instead of using updateChartSpec you would want to use addChart.
References:
updateChartSpecRequest
Color
BasicChartSeries
BasicChartSpec
addChart

Is it possible to get the data table column names in Vega-lite as an array?

Is there a Vega/Vega-lite equivalent of pandas' df.columns?
I would like to get an array with all column names in Vega-lite. For this dataset:
{"data": { "values" : [{"a":4, "b":5},{"a":6, "b":7}] }}
I would like to get an array ["a","b"]. This would be extremely helpful when using the fold transform with large datasets.
Here is one way to get a Vega dataset fieldnames using Vega API.
In Vega spec, add signal declaration, e.g.:
"signals":[
{"name": "signal_data_table_fieldnames"
}
In javacript, use Vega view API methods signal and data to retrieve the first record of the dataset table and obtain the fieldnames as an array with javascript Object.keys()
When using the view.signal, the Vega API method can both get and set the internal Vega signal value. The updated signal value can be used anywhere within the Vega spec.
Vega API docs for signal and data methods:
https://vega.github.io/vega/docs/signals/
https://vega.github.io/vega/docs/api/view/#signals
https://vega.github.io/vega/docs/api/view/#data-and-scales
Example code using
https://vega.github.io/vega/usage/
with bar chart example
https://vega.github.io/vega/examples/bar-chart/ :
var view;
fetch('https://vega.github.io/vega/examples/bar-chart.vg.json')
.then(res => res.json())
.then(spec => render(spec))
.catch(err => console.error(err));
function render(spec) {
view = new vega.View(vega.parse(spec), {
renderer: 'canvas', // renderer (canvas or svg)
container: '#view', // parent DOM container
hover: true // enable hover processing
});
return view.runAsync();
}
// Vega API
view.signal("signal_data_table_fieldnames", Object.keys(view.data("table")[0]));
console.log(view.signal("signal_data_table_fieldnames"));

Root.Js: how to pass parameters to THttpServer?

I am using root.js and querying a fixed TH2I via JavaScript
<script type='text/javascript'>
var histo;
JSROOT.httpRequest("https://subdomain.doamin.xx/root/Objects/subfolder/histo/root.json", 'object')
.then(obj => {
histo = JSROOT.parse(obj);
histo.fName = "2D";
JSROOT.redraw('object_draw', histo, "lego2");
console.log(obj)
})
</script>
At the backend I am doing (in Python):
serv = ROOT.THttpServer("http:8080")
serv.CreateServerThread()
histo = ROOT.TH2I('h1', '', 320, 0, 320, 320, 0, 320)
histo.SetName("histo")
histo.SetBinContent(40, 50, 5)
serv.Register("subfolder", histo)
Now I want to pass parameters to the THttpServer to generate dynamical histograms e.g. by parsing the filename of a (non root) data file as data source.
The documentation of THttpServer::RegisterCommand() mentioned parameters, corresponding I did:
hpx = Hpx()
serv.RegisterCommand('/test', '/hpx/.notify(arg1%,\'arg2%\')')
where Hpx is some class providing a notify function taking 2 parameters.
I tried call this by
https://subdomain.doamin.xx/root/Objects/test/root.json?arg1=1&arg2=2
But Hpx::notify is not getting called.
There is also the kind post_data in JSROOT.httpRequest but then the THttpServer should not return (JSon) data.
One should use cmd.json request. root.json returns JSON representation of requested object.
You can find more details in THttpServer documentation
For the future - please submit question about ROOT framework to ROOT forum.
See ROOT forum.
self.__serv.RegisterCommand('/Folder/Start', TPython::Exec("do_something(\'%arg1%\')")') # for strings
self.__serv.RegisterCommand('/Folder/Start', 'TPython::Exec("do_something(%arg1%)")') # for integers / floats
def do somethings(arg1) needs to be outside the class.

Creating custom fragment in Cumulocity

Is it possible to create custom fragment as below?
"custom_Position": {
"alt": 67,
"lng": 6.15173,
"lat": 51.211977,
"place":"xxxx"
}
Most of the default fragments like c8y_Position can also be extended. So you can do something like this.
"c8y_Position": {
"alt": 67,
"lng": 6.15173,
"lat": 51.211977,
"place":"xxxx"
}
Then the default map widget still works (of course it won't show the place).
But in general as said already you can add fragments in any shape you want. This is also true for the other data APIs like measurements, events, etc.
A device can add any custom fragment they want in the managed object. The only drawback is that the widgets (the map widget for example in your case) will not work out of the box with your new fragment.

How can I use REST url as data in Vega-lite

I have this REST API that returns tabular data in the following way:
{"data": [{"el1": 8, "el2": 9}, {"el1": 3, "el2": 4}]}
I would like to use el1 and el2 in a Vega-lite chart. How should I refer to the elements in the array?
From the documentation here:
(JSON only) The JSON property containing the desired data. This parameter can be used when the loaded JSON file may have surrounding structure or meta-data. For example
"property": "values.features"
is equivalent to retrieving json.values.features from the loaded JSON object.
It seems that you can try to specify the "property" property (punny, eh) on the format. Something like this:
"data": {
"url": <your url here>,
"format": {
"type": "json",
"property": "data"
},
}
Disclaimer: I haven't actually tested this but it looks to be supported (: