POST
|
My app with token authentication is very rudimentary in that I funnel all errors through a generic error handling function for everything in the app. One of the checks is to find the word "token". If it does, it assumes the token is expired, so deletes it and then sends them to the log in screen. Very basic but better than making the user refresh the app. I'm also hoping someone else has a better solution.
... View more
06-11-2021
07:37 AM
|
0
|
0
|
786
|
POST
|
It's just like querying a feature layer. You can get the url for the table item in ArcGIS Online, plug it into a QueryTask, execute the Query, then iterate over the results. Here's an example: var qTask = new QueryTask({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/SpatioTemporalAggregation/RainfallTimeSeriesDataIllinois/MapServer/8"
});
// Set the query parameters with a where clause and to return all fields.
var params = new Query({
returnGeometry: false,
where: "avg_monthly_rainfall > 100",
outFields: ["*"]
});
// executes the query and handle the resulting FeatureSet.
qTask.execute(params)
.then(function(featureSet) {
featureSet.features.forEach(function(feature) {
console.log(feature);
for (const [fieldName, fieldValue] of Object.entries(feature.attributes)) {
// Do something with the field names and field values.
console.log(`\t${fieldName}: ${fieldValue}`);
}
});
})
.catch(function (error) {
console.error("Promise rejected: ", error.message);
});
... View more
06-10-2021
08:50 AM
|
0
|
0
|
718
|
POST
|
I got this code as a solution to the post import arcpy
import openpyxl as px
def main():
wb = px.load_workbook(r"C:\Users\Hp\Desktop\Ejemplo\VINCULACION_S.xlsm", read_only=False, keep_vba=True)
ws = wb['VINCULACION_SH_NUE']
in_features = r"C:\Users\Hp\Desktop\Ejemplo\VH_Dissolve.shp"
row_num = 3
with arcpy.da.SearchCursor(
in_features,
["COLOR", "INTERNO_DE", "CLASE_DEMA", "COUNT_AREA", "SUM_AREA", "SUM_LENGTH"],
) as cursor:
for row in cursor:
ws.cell(row=row_num, column=2).value = row[0]
ws.cell(row=row_num, column=3).value = row[1]
ws.cell(row=row_num, column=4).value = row[2]
ws.cell(row=row_num, column=6).value = row[3]
ws.cell(row=row_num, column=7).value = row[4]
ws.cell(row=row_num, column=8).value = row[5]
row_num += 1
wb.save(r"C:\Users\Hp\Desktop\Ejemplo\VINCULACION_S.xlsm")
... View more
06-06-2021
05:34 PM
|
1
|
0
|
2446
|
POST
|
Hi All I came right, I hat to remove this line : event.graphic.layer.removeAll();
... View more
06-02-2021
01:23 PM
|
0
|
0
|
1287
|
POST
|
It seems that simply removing the apiKey and logging in manually allows the search widget to work normally. I'm not sure why this is happening. Hopefully someone else has an idea. EDIT: That apiKey is supposed to be private so I recommend redacting that.
... View more
06-02-2021
07:52 AM
|
1
|
0
|
437
|
POST
|
Sweet, thank you. SQL1 = "AppSubmitted >= DATE '{}'".format(from_date.strftime('%Y-%m-%d')) #'%Y-%m-%d %H:%M:%S'
SQL2 = "PNum LIKE 'RZ%' OR PNum LIKE 'OR%' OR PNum LIKE 'CR%'"
sql_expression = "({}) and ({})".format(SQL1, SQL2)
arcpy.TableToTable_conversion(table1, workspace,'tableTEST', sql_expression)
... View more
05-27-2021
10:02 AM
|
0
|
0
|
627
|
POST
|
I would also like to add that you probably want to be using "PYTHON_9.3" as the expression_type parameter for CalculateField.
... View more
05-24-2021
12:09 PM
|
0
|
0
|
850
|
POST
|
Are you able to apply this solution you found to this discussion?
... View more
05-24-2021
08:00 AM
|
1
|
0
|
972
|
POST
|
OK I posted my solution on another post... I think you all for your thoughts....it got me through this one.... I used a Select instead and then used those results to update the polygon with counts https://community.esri.com/t5/arcgis-api-for-javascript/count-points-in-polygon-and-symbolize-on-number-of-occurrences/td-p/1059845/page/2#M73258
... View more
05-24-2021
06:22 AM
|
0
|
0
|
948
|
POST
|
First off THANK YOU ALL FOR YOUR THOUGHTS AND COMMENTS They really helped steer me in the path and direction I took... OK this is what I did and its working.... Create a List of Unique types in the point Feature Class Call Function that reads this List by looping though that created unique list Each loop takes those unique value and calls another function that gets the correct field name and for that TYPE It then passes the (expression, type name and field name) to the last function which processes the data In the last function I am selecting the point records that match that TYPE value, I then create a new Point Layer that has only those records. I use that New Layer to Spatial Join, Statistics Analysis, Join Field Management, Calculate Field Management to Update the Polygon Layer with the number of occurrences for that TYPE in the Correct Field name that was set in the If Then Else I used the If Then to change the TYPE value in the Data to a value that would work as a field name...so I can update the Polygon Layer as some of the TYPE values were really long import arcpy
arcpy.env.workspace = r"E:/xxxxx/xxxx/Projects/xxx/xxx.sde"
Points = r"E:/xxxxx/xxxx/Projects/xxx/xxx.sde/Locations"
Grids = r"E:/xxxxx/xxxx/Projects/xxx/xxx.sde/Grids"
print "Started"
bList = []
expression = ""
expressionValue = ""
type= ""
rowCount = 0
uniquetypeList = []
countList = []
txt_list = ""
# COUNT NUMBER OF RECORDS FOR EACH TYPE
def getFieldName(type):
if type == "Needs Repair":
return "NeedsRepair"
elif type == "Broken":
return "Broken"
elif type == "Needs Replacement":
return "NeedsReplacement"
elif type == "Schedule Fix":
return "ScheduleFix"
else:
return "nothing"
def processTypeUpdate(expressionValue, typeValues, fieldName):
expressionValue2 = expressionValue
typeName = typeValues
fieldUpdateName = fieldName
rowCount = 0
arcpy.Delete_management('in_memory/PointsInPolys')
arcpy.Delete_management('in_memory/SS_PointsInPolys')
arcpy.Delete_management('points_lyr')
arcpy.Delete_management('points_lyr2')
arcpy.MakeFeatureLayer_management(r'E:/xxxxx/xxxx/Projects/xxx/xxx.sde/Locations_Test', 'points_lyr')
results = arcpy.SelectLayerByAttribute_management ('points_lyr', 'NEW_SELECTION', expressionValue2)
arcpy.MakeFeatureLayer_management(results, 'points_lyr2')
polygonID = "ID" ## unique polygon field name
countField = fieldUpdateName # The field name in the Grids FC to update
expression = "recalc(!FREQUENCY!)"
codeblock = """def recalc(freq):
if freq > -1:
return freq
else:
return 0"""
arcpy.SpatialJoin_analysis('points_lyr2', Grids, "in_memory/PointsInPolys")
### case field returns count per unique UID
arcpy.Statistics_analysis ("in_memory/PointsInPolys", "in_memory/SS_PointsInPolys", [[polygonID, "Count"]], polygonID)
arcpy.JoinField_management(Grids, polygonID, "in_memory/SS_PointsInPolys", polygonID, "FREQUENCY")
arcpy.CalculateField_management(Grids, countField, expression, "PYTHON", codeblock)
arcpy.DeleteField_management(Grids, "FREQUENCY")
# GET THE CODES FROM THE RESULTS OF THE SELECTION
rows = arcpy.SearchCursor('points_lyr2',"","","type_name")
for row in rows:
rowCount = rowCount + 1
typeVal = str(row.type_name)
countList.append(typeVal)
txt_list = ','.join(countList)
print "number of " + typeVal + " : " + str(rowCount)
arcpy.Delete_management('in_memory/PointsInPolys')
arcpy.Delete_management('in_memory/SS_PointsInPolys')
arcpy.Delete_management('points_lyr')
arcpy.Delete_management('points_lyr2')
# TAKE TYPE NAME AND GET THE CORRECT FIELD NAME
def processtypeNames(expressionValue, typeValues):
type= str(typeValues)
expressionValue2 = "type_name = '{}'".format(type)
# GET THE CORRECT FIELD NAME
fieldName = getFieldName(type)
if fieldName == "nothing":
print "No Value"
else:
# Call the function to actually update the Field Values
uniques2 = processtypeUpdate(expressionValue2, type, fieldName)
print "corrected field name is: " + fieldName
def uniquetypeList(uniquetypeValues):
typeList = uniquetypeValues
#print typeList
for type in typeList:
#print type
expressionValue = "type_name = '{}'".format(type)
uniques = processtypeNames(expressionValue, type)
# GET UNIQUE TYPS FROM FC CREATE LIST
for feature in arcpy.ListFeatureClasses():
#print feature
with arcpy.da.SearchCursor(Points,"type_name", sql_clause=(None,'ORDER BY type_name ASC')) as SCur:
for row in SCur:
if not row[0] in bList: # if not in list then add to list
bList.append(row[0])
type = row[0]
del SCur
uniquetype = uniquetypeList(bList)
... View more
05-24-2021
06:18 AM
|
0
|
0
|
2931
|
POST
|
Ok, so according to this question Why would a python script run fine from within ArcMap but not as a geoprocessing service? I need to do the following: arcpy.env.workspace = os.path.dirname(r"//[servername]/connections/dbconnection.sde") This call cuts off the dbconnection.sde part of the path. Not sure why this fixes the problem, but I'm now onto a different error in a different part of the code, so that's one step further than I was before.
... View more
05-23-2021
06:00 PM
|
0
|
0
|
1236
|
POST
|
Thanks John ! Also it's quite confusing the parameters names are different from those in the REST API. I was indeed missing something !
... View more
05-18-2021
01:27 AM
|
0
|
0
|
1358
|
POST
|
Hi there, The feature filters and effects can be applied on the GeoJSONLayerView as you are describing in your question. If you are not familiar with layer views and filters, please take a look at this guide doc to understand how they work. I modified the sample you referenced in your question to filter features from GeoJSONLayerView. Take a look at this test app. Hope this helps, -Undral
... View more
05-17-2021
09:13 AM
|
2
|
0
|
3149
|
POST
|
I got my code working so far with no errors, and my field list updates properly when I add or remove feature classes, but now I have a new problem. When I press the "Select All" or "Unselect All" buttons, they don't to do anything, and if I click anywhere (even in another application), all of the boxes are re-check themselves. I suspect it is because of the updateParameters section of the tool Validator, but I can't wrap my head around the logic the tool is using. No matter what my order of indentation is in the code it always wants to refresh the list. Here is my code so far: def updateParameters(self):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
if self.params[0].value:
fclist = self.params[0].valueAsText.split(";") if self.params[0].valueAsText.find(";") > -1 else [
self.params[0].valueAsText]
if ";" in fclist:
fclist.split(";")
elif "'" in fclist:
[f.strip("'") for f in fclist]
else:
[f.strip("'") for f in fclist]
if self.params[0].altered:
fieldlist = []
for each in fclist:
fieldnames = [f.name for f in arcpy.ListFields(each)]
for fields in fieldnames:
if fields not in fieldlist:
fieldlist.append(fields)
self.params[1].value = fieldlist
return
... View more
05-14-2021
08:56 AM
|
0
|
0
|
1365
|
Title | Kudos | Posted |
---|---|---|
4 | yesterday | |
1 | a week ago | |
1 | Friday | |
2 | a week ago | |
1 | a week ago |