POST
|
TypeError Traceback (most recent call last)
Input In [143], in <cell line: 20>()
21 tabSet = tab.query(where='1=1')
22 for row in tabSet:
---> 23 print (row['itemId'])
TypeError: 'Feature' object is not subscriptable
... View more
10-25-2022
12:16 PM
|
0
|
2
|
1169
|
POST
|
Edit: this is a hosted Notebook on our AGOL org I can't believe I cannot see any examples in the docs on simply accessing attributes of a hosted AGOL table/service, prbly just missing the obvious here. I can get to all attributes of "features" but I'm unsure how to go about getting a specific attribute for each feature but had to actually apply a query to get the list object. import time, os
from datetime import datetime, timedelta
from arcgis.gis import GIS
gis = GIS("home")
from arcgis.features import FeatureLayer
from arcgis.features import FeatureLayerCollection
t = time.localtime()
last_date_time = datetime.utcnow() - timedelta(days = 18)
timestamp = last_date_time.strftime("%Y-%m-%d %H:%M:%S")
#timestamp = '2022-10-02 15:00:00 PM'
sunsetTabId = '5cf39cfa77694131821ec89cc1bf0150'
sunsetTabItem = gis.content.get(sunsetTabId)
fields=['itemIdToProcess','daysToKeep']
for tab in sunsetTabItem.tables:
tabSet = tab.query(where='OBJECTID>0')
print (tab.properties.name)
for row in tabSet.features:
print (row) This iterates over the "tabSet.features" object and I can print each row but unsure how to get at each "itemId" value each iteration. {"attributes": {"OBJECTID": 1, "itemId": "416c10d63b78464798abc3c10e70c71b", "daysToKeep": 10}}
{"attributes": {"OBJECTID": 2, "itemId": "105f5c3e534744da9df8a0d8953fffc2", "daysToKeep": 5}}
{"attributes": {"OBJECTID": 3, "itemId": null, "daysToKeep": 1}}
{"attributes": {"OBJECTID": 4, "itemId": null, "daysToKeep": 1}}
{"attributes": {"OBJECTID": 5, "itemId": null, "daysToKeep": 1}}
{"attributes": {"OBJECTID": 6, "itemId": null, "daysToKeep": 1}}
{"attributes": {"OBJECTID": 7, "itemId": null, "daysToKeep": 1}}
{"attributes": {"OBJECTID": 8, "itemId": null, "daysToKeep": 1}}
{"attributes": {"OBJECTID": 9, "itemId": null, "daysToKeep": 1}}
{"attributes": {"OBJECTID": 10, "itemId": null, "daysToKeep": 1}}
{"attributes": {"OBJECTID": 11, "itemId": null, "daysToKeep": 1}} But I cannot get "itemId"? I've tried several combinations of things like: for row in qResult.features:
print (row.attributes.itemId) But gives AttributeError: 'dict' object has no attribute 'itemId'
... View more
10-25-2022
11:46 AM
|
1
|
5
|
1189
|
POST
|
Edit: Perhaps this lists the relationships... "FeatureServer/relationships" Do you know where can I locate the relationship info/details in the service layer (cardinality, role, keyField, etc)? I can only see a basic list of the relationships for each of the service layers but I just get a basic list:
... View more
10-11-2022
05:38 AM
|
0
|
1
|
1308
|
POST
|
ArcGIS Server 10.8 SDE Geodatabase Feature Classes Is there any way to remove relationships on a published server via the REST admin page using deleteFromDefinition request? Feature/Map service published with feature classes that participate in relationships persist thru to the published service. I supposed we could create another set of the feature classes that do not have relationships to use for publishing, but it's not preferred and looking for alternatives. I did make an attempt to run this from the deleteFromDefinition task of the feature service in question but it didn't delete them. {"relationships" : [
{
"id" : 0
},
{
"id" : 1
},
{
"id" : 2
},
{
"id" : 3
},
{
"id" : 4
},
{
"id" : 5
}
]
} Thanks!
... View more
10-10-2022
12:13 PM
|
0
|
6
|
1504
|
POST
|
My personal preference would be to create a GP tool (python) to perform the conversion, publish it as a GP Service and make requests to it from your web application (whatever form that may be). Just build it off the Layer To KML tool and publish it out as a GP service. You can run thru the gauntlet of possible Javscript solutions but I don't believe there's any ESRI Javascript api options available. You would probably need to format any input as GeoJSON first then perhaps need to hit other api's that could do the conversion for you (some are free but may have frequency limits on the number of requests). It looks like there'a generateKML option available on Enterprise services? Not sure about that tho.
... View more
08-08-2022
01:40 PM
|
1
|
2
|
2862
|
POST
|
One idea/option is to publish the Tool you've created as a new Geoprocessing Service onto your ArcGIS Server site, at that point it's just a REST endpoint that you can execute from just about anything that has web access. We do this in some of our WAB widgets with the javascript api's Geoprocessor task
... View more
08-08-2022
11:22 AM
|
0
|
1
|
955
|
POST
|
Super generic, I know but thought I'd see if anyone has run into this. We have a custom print service that use .mxd source templates (v10.8.1) and a custom widget that prepares the webmap_as_JSON input parameter. The mxd has an empty legend associated with the data frame and all seems to work except for 1 minor issue: the polygon patch in the legend does not print the outline, only the fill shows up. Before I get too deep into posting code, just wondering if anyone has run into this! Thanks, j Here's the execute task's Web_Map_As_JSON parameter in the request to the print service. It's the "Selected Applications" that should be one I'm interested in: {
"mapOptions": {
"showAttribution": true,
"extent": {
"xmin": -8979745.169338416,
"ymin": 3157283.911112111,
"xmax": -8943055.395761583,
"ymax": 3175189.284987889,
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
},
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
},
"scale": 72223.819286
},
"operationalLayers": [
{
"id": "layer3",
"title": "layer3",
"opacity": 1,
"minScale": 0,
"maxScale": 0,
"url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"
},
{
"id": "layer2",
"title": "layer2",
"opacity": 1,
"minScale": 0,
"maxScale": 0,
"url": "https://blahblahblah/Transportation/MapServer"
},
{
"id": "Selected Application",
"opacity": 1,
"minScale": 0,
"maxScale": 0,
"featureCollection": {
"layers": [
{
"layerDefinition": {
"name": "Selected Application",
"geometryType": "esriGeometryPolygon",
"drawingInfo": {
"renderer": {
"type": "simple",
"label": "Application",
"symbol": {
"color": [
255,
170,
0,
255
],
"outline": {
"color": [
255,
170,
0,
255
],
"width": 1.875,
"type": "esriSLS",
"style": "esriSLSSolid"
},
"type": "esriSFS",
"style": "esriSFSBackwardDiagonal"
}
}
}
},
"featureSet": {
"geometryType": "esriGeometryPolygon",
"features": [
{
"geometry": {
"rings": [
[
[
-8961855.5314,
3165742.8092
],
[
-8961856.1841,
3164886.830600001
],
[
-8961855.5314,
3165742.8092
]
],
[
[
-8960040.978,
3170422.6761999987
],
[
-8960040.7589,
3170422.4426000006
],
[
-8960040.978,
3170422.6761999987
]
]
],
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
}
}
]
}
}
]
}
},
{
"id": "printOutlineLayer",
"opacity": 1,
"minScale": 0,
"maxScale": 0,
"featureCollection": {
"layers": [
{
"layerDefinition": {
"name": "polygonLayer",
"geometryType": "esriGeometryPolygon"
},
"featureSet": {
"geometryType": "esriGeometryPolygon",
"features": [
{
"geometry": {
"rings": [
[
[
-8964510.31413835,
3158627.702797455
],
[
-8964510.31413835,
3158965.5257343827
],
[
-8958290.25096165,
3158965.5257343827
],
[
-8958290.25096165,
3158627.702797455
],
[
-8964510.31413835,
3158627.702797455
]
]
],
"spatialReference": {
"wkid": 102100
}
},
"symbol": {
"color": [
255,
0,
0,
204
],
"type": "esriSFS",
"style": "esriSFSSolid"
}
},
{
"geometry": {
"rings": [
[
[
-8968726.374969315,
3159006.816093703
],
[
-8954074.190130685,
3159006.816093703
],
[
-8954074.190130685,
3173466.3800062975
],
[
-8968726.374969315,
3173466.3800062975
],
[
-8968726.374969315,
3159006.816093703
]
]
],
"spatialReference": {
"wkid": 102100
}
},
"symbol": {
"color": [
255,
0,
0,
102
],
"outline": {
"color": [
255,
0,
0,
255
],
"width": 3.75,
"type": "esriSLS",
"style": "esriSLSSolid"
},
"type": "esriSFS",
"style": "esriSFSNull"
}
}
]
}
},
{
"layerDefinition": {
"name": "textLayer",
"geometryType": "esriGeometryPoint"
},
"featureSet": {
"geometryType": "esriGeometryPoint",
"features": [
{
"geometry": {
"x": -8961400.28255,
"y": 3158796.6142659187,
"spatialReference": {
"wkid": 102100
}
},
"symbol": {
"color": [
0,
0,
0,
255
],
"type": "esriTS",
"verticalAlignment": "middle",
"horizontalAlignment": "center",
"angle": 0,
"xoffset": 0,
"yoffset": 0,
"text": "Pan or Zoom the map to adjust this print area.",
"rotated": false,
"kerning": true,
"font": {
"size": 12,
"style": "italic",
"decoration": "none",
"weight": "normal",
"family": "Arial"
}
}
}
]
}
}
]
}
},
{
"id": "Canal Center Line",
"title": "Canal Center Line",
"opacity": 1,
"minScale": 0,
"maxScale": 0,
"layerDefinition": {
"drawingInfo": {
"renderer": {
"type": "simple",
"symbol": {
"color": [
17,
0,
148,
255
],
"width": 0.75,
"type": "esriSLS",
"style": "esriSLSSolid"
}
}
}
},
"url": "https://blahblahblah/MapServer/7"
}
],
"exportOptions": {
"outputSize": [
800,
1100
],
"dpi": 96
},
"layoutOptions": {
"customTextElements": [
{
"county": "blah"
},
{
"appNo": "blah"
},
{
"str": "blah"
},
{
"exhibitno": "blah"
},
{
"permitno": "blah"
},
{
"projname": "blah"
}
],
"scaleBarOptions": {},
"legendOptions": {
"operationalLayers": [
{
"id": "Facilities Layer"
},
{
"id": "Selected Application"
}
]
}
}
}
... View more
08-01-2022
01:09 PM
|
0
|
0
|
313
|
POST
|
I must have put that in just about every place except where you suggest. LOL --- thank you, this resolves the issue (although not sure if it resolves the issue that I consistently struggle with scope). Much appreciated!
... View more
06-14-2022
06:18 AM
|
0
|
0
|
501
|
POST
|
Having some difficulty with a seemingly simple scope issue that I am struggling to understand. Someone will probably be able to quickly identify what I'm missing here! I have a function that calculates planar area and calculates an acreage value with the geometry of a graphic as the input parameter. In that process I intended to set "this.acrevalue" and have it set and available later on in other functions of a button click event. However, it's always null BUT I can see that the correct acreage value is being calculated. saveDataBtnClick() function is a button in the html of the widget that I hoped to somehow use the getAcreageValueFromPolygon() function to get the acreage value before submitting a applyEdit() on the feature service. getAcreageValueFromPolygon: function (geom) {
projection.load().then(function (evt) {
const inSpatialReference = new SpatialReference({ wkid: 102100 });
const spSpatialReference = new SpatialReference({ wkid: 2881 });
const poly = new Polygon(geom, inSpatialReference);
var geoT = projection.getTransformation(inSpatialReference, spSpatialReference)
const projectedPoly = projection.project(poly, spSpatialReference);
var areasAndLengthParams = new AreasAndLengthsParameters();
areasAndLengthParams.areaUnit = esri.tasks.GeometryService.UNIT_ACRES;
areasAndLengthParams.lengthUnit = GeometryService.UNIT_FOOT;
areasAndLengthParams.polygons = projectedPoly;
var geometryService = new GeometryService("https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
geometryService.on("areas-and-lengths-complete", outputAreaAndLength);
geometryService.simplify([projectedPoly], function (simplifiedGeometries) {
areasAndLengthParams.polygons = simplifiedGeometries;
geometryService.areasAndLengths(areasAndLengthParams);
});
}.bind(this))
function outputAreaAndLength(evtObj) {
var result = evtObj.result;
this.acrevalue = result.areas[0].toFixed(3)
}
},
saveDataBtnClick: function () {
var e = document.getElementById("layerTypeSelections");
//use config to reference services and specific service layers
this.serverSideScratchLayer = new FeatureLayer(this.config.applicationFeatureLayer + "/" + lyrNum, { outFields: ["*"] });
var features = this.unionedGraphic2.geometry
if (features) {
this.getAcreageValueFromPolygon(this.unionedGraphic2.geometry); //set the acreagae value and have it available for saving in applyEdits
var spAcres = this.acrevalue;
attr["TRMT_ACRES"] = spAcres;
var fYear = '1901'
attr['FISCAL_YEAR'] = fYear
this.unionedGraphic2["attributes"] = this.attr
this.serverSideScratchLayer.applyEdits([this.unionedGraphic2], [], this.attr, lang.hitch(this, function (add) {
if (add.length > 0) {
if (add[0].objectId) {
console.log('Add successful with objectid: ' + add[0].objectId);
this.uploadOID = add[0].objectId
}
}
}).bind(this));
}
},
... View more
06-13-2022
01:47 PM
|
0
|
2
|
541
|
POST
|
Solved with client-side esri/geometry/projection projection.load().then(function (evt) {
const inSpatialReference = new SpatialReference({ wkid: 102100 });
const spSpatialReference = new SpatialReference({ wkid: 2881 });
const point = new Point(f.features[i].geometry, inSpatialReference);
var geoT = projection.getTransformation(inSpatialReference, spSpatialReference)
const projectedPoint = projection.project(point, spSpatialReference);
this.facObj.x = Math.round(projectedPoint.x);
this.facObj.y = Math.round(projectedPoint.y);
... View more
06-08-2022
11:39 AM
|
0
|
0
|
418
|
POST
|
Edit: I am open to any solution -- simple is better, GeometryService/Engine whatever works. Back again, lots of interesting requirements lately! This time I'm attempting to get the x/y values of point geometry in 102100/3857 as planar coordinates (wkid 2881). Is there a simplified projectAs() function in the ESRI Javascript 3.x? I've been attempting to implement projection but not having success with the overcoming errors with the geoTransformation. layer.layerObject.queryFeatures(query, function (f) {
const inSpatialReference = new SpatialReference({ wkid: 102100 });
const spSpatialReference = new SpatialReference({ wkid: 2881 });
var geoT = projection.getTransformations(inSpatialReference, spSpatialReference)
for (var i in f['features']) {
var facObj = Object.assign({}, f.features[i]['attributes']);
const point = new Point(f.features[i].geometry, inSpatialReference);
const projectedPoint = projection.project(point, spSpatialReference, geoT);
facObj.x = projectedPoint.x
facObj.y = projectedPoint.y I have a facObj that I just need to apply the xy planar coordinate values.
... View more
05-31-2022
10:38 AM
|
0
|
1
|
451
|
POST
|
heck of an idea! Thanks! var heightVal = this.map.height * 0.80
panel.setPosition({ top: 75, left: 10, width: 350, height: heightVal, margin: 10, index: 0 }); No errors, the onOpen: function(){} just never gets fired at all. I'm sure it has something to do with the Widget Life Cycle but I haven't fully investigated that yet.
... View more
05-27-2022
08:33 AM
|
0
|
0
|
731
|
POST
|
Edit: someone solved with suggestion to use this.map.height * 0.80 to get a percent value. Is there any way to specify a percentage for the height/width property? panel.setPosition({ top: 120, left: 10, width: 350, height: 80%, margin: 10, index: 0 });
... View more
05-27-2022
07:49 AM
|
0
|
0
|
586
|
POST
|
Thanks Brian and Robert of course! That does in fact work to alter the size of the widget. Is there any way to specify a percent size instead of just integer value? Something like instead of 600 can set it so 80%? panel.setPosition({ top: 120, left: 10, width: 650, height: 600, margin: 10, index: 0 }); This only worked in the startup: function () {} for my widget. I tried to implement onOpen(){} but it doesn't fire when I close/open the widget. Full solution: _resizeWidget: function (widgetName) {
var wm = WidgetManager.getInstance();
var pm = PanelManager.getInstance();
var myWidget = null;
arrayUtils.some(wm.appConfig.widgetPool.widgets, function (aWidget) {
if (aWidget.name === widgetName) {
myWidget = aWidget;
}
});
if (myWidget) {
var controller = wm.getWidgetsByName("AnchorBarController");
var pos = {
relativeTo: map,
left: 277,
top: 225,
width: 600,
height: 820
};
if (controller.length > 0) {
pm.showPanel(myWidget).then(lang.hitch(this, function (panel) {
//panel.setPosition({ top: 120, left: 10, width: 350, height: 80%, margin: 10, index: 0 });
panel.setPosition({ top: 120, left: 10, width: 650, height: 600, margin: 10, index: 0 });
pm.normalizePanel(panel);
}));
} else {
pm.showPanel(myWidget);
}
}
},
onOpen: function () {
this._resizeWidget("Pega WU Tool"); //doesn't ever fire
},
startup: function () {
//resize widget to specs
this._resizeWidget("Pega WU Tool");
}
... View more
05-27-2022
07:44 AM
|
0
|
0
|
739
|
Title | Kudos | Posted |
---|---|---|
1 | 10-25-2022 11:46 AM | |
1 | 08-08-2022 01:40 PM | |
1 | 02-15-2019 08:21 AM | |
2 | 08-14-2023 07:14 AM | |
1 | 07-10-2023 01:25 PM |
Online Status |
Offline
|
Date Last Visited |
08-19-2024
09:15 PM
|