POST
|
So, there are a couple of things to mention, not so much the question but issues that I see with the script itself. Avoid nesting loops. In terms of performance, nested loops can be processing killers if they are used within themselves. All cursor functions have SQL clauses that can be used, so having separate select by attribute query layer is unnecessary. In my personal opinion, never set functions within the main portion of a script. I typically set them above the main processes and below the imports. I would also recommend checking out arcpy geometry to get a better understanding of how to utilize feature geometries. import arcpy
from arcpy import ListFields
from arcpy.da import SearchCursor as Searching , UpdateCursor as Updating
# Retrieves records of an input layer/feature and returns a dictionary of values
def GetRecords( Layer , ["OID@"] + Fields + ['SHAPE@'] , SQLClause ):
SearchLayer = Searching( Layer , Fields )
if SQLClause is not None: SearchLayer = Searching( Layer , Fields , SQLClause )
return { row[0] : row[ 1:] for row in SearchLayer }
# Returns a list of field names
def GetFieldNames( Layer , ExcludeFields ):
fieldnames = [ field.name for field in ListFields( Layer ) ]
if type( ExcludeFields ) is list: fieldnames = list( set( fieldnames ).difference( set( ExcludeFields ) ) )
return fieldnames
# Checks the distance between two geometries
def CheckProximity( InputFeatureRecords , DistanceFeatureRecords , SetDistance ):
WithinSetLimits = { }
for IF_id , IF_Attributes in InputFeatureRecords.items():
for DF_id , DF_Attributes in DistanceFeatureRecords.items():
Point = IF_Attributes[ 0 ]
Line = DF_Attributes[ 0 ]
if Point.distanceTo( Line ) <= SetDistance: WithinSetLimits[ IF_id ] = DF_Attributes[ 0 ]
else: WithinSetLimits[ IF_id ] = "Not Within 100 Feet of Stream or River"
return WithinSetLimits
Poles = '<PoleLayer>'
Streams = '<StreamLayer>'
PoleFields = GetFieldNames( infeature , '<[ list of field names to exclude ]>' )
StreamFields = [ "Stream_ID" , "StreamPermanence" ]
PoleRecords = GetRecords( infeature , ["OID@"] + Fields + ['SHAPE@'] )
StreamRecords = GetRecords( infeature , ["OID@"] + Fields + ['SHAPE@'] )
CheckProximity( PoleRecords , StreamRecords , 100 ) The sample above isn't a solution but I just thought to provide something useful to give you a rough idea.
... View more
5 hours ago
|
0
|
1
|
28
|
IDEA
|
Here is what I have used in the past. import arcgis.gis
from arcgis.gis import GIS
from arcgis.features import FeatureLayer
import datetime
import os
gis = GIS('<Portal>',"<Username>", "<Password>")
#print("Logged into AGOL...")
source_outages_layer_item = gis.content.get("<itemID>") #Outages layer
source_layer = source_outages_layer_item.layers[0]
#print (source_layer)
Current = datetime.datetime.now()
#print (Current)
source_layer.calculate(where = "1=1", calc_expression={"field": "Now", "sqlExpression" : "CURRENT_TIMESTAMP()"})
# Update The Outage Status
source_layer.calculate(where = "Now > TimeField and Now < TimeField", calc_expression={"field": "fieldname", "sqlExpression" : "<Some Value {must match field data type }>"})
source_layer.calculate(where = "Now < TimeField", calc_expression={"field": "fieldname", "sqlExpression" : '<Some Value {must match field data type }>' })
source_layer.calculate(where = "Now > TimeField", calc_expression={"field": "v", "sqlExpression" : '<Some Value {must match field data type }>'})
# Update The Emergency Outage Timeframe
source_layer.calculate(where = 'SQL Clause', calc_expression={"field": "fieldname", "sqlExpression" : "Expression"})
#______________________Write Text File_____________________#
output_location = 'file location'
TxtFileName = ("PythonScriptLog.txt")
TxtFile_Output = os.path.join(output_location, TxtFileName)
f = open(TxtFile_Output, "w")
f.write(str(Current) + '\n' + '\n' + 'Successfully logged into AGO' + '\n' + 'Updated ' + 'Featureclass Name')
f.close() Something that I also realized later on is that you can also treat the feature service like any feature if you use the full url and have editing capabilities on the feature.
... View more
Wednesday
|
0
|
0
|
21
|
POST
|
Hi, I am merely trying to create another table within Dashboards using arcade, but I cannot seem to get the feature set to populate using multiple records. I have tested this multiple times, but I am not sure if I need to edit the feature or if there is some other way to go about it. I would greatly appreciate any help on this. var TimeFields = [
{'name': 'InspectionDate' , 'type':'esriFieldTypeDate' },
{'name': 'TimeSlot' , 'type':'esriFieldTypeString' , 'Length':10 }
]
var TimeSlots = {
'fields': TimeFields,
'geometryType': '',
'features' : []
}
var T = Today()
for( var i= 0 ; i < 24 ; i++ ){
var V = { 'InspectionDate' : T , 'TimeSlot' : Text( T , 'h:00 A') }
var F = { geometry : '' , attributes : V }
Push( TimeSlots.features , F )
T = DateAdd( T , 1 , 'hours' )
}
console( TimeSlots.features )
var FS = FeatureSet( Text( TimeSlots ) )
return FS
... View more
Wednesday
|
0
|
0
|
52
|
POST
|
Hi @EdHixson You can achieve this by setting the clip function on the map properties rather than in the map series. This will allow for you to exclude any features you choose while preserving the matching shape in the series.
... View more
08-12-2024
06:46 AM
|
2
|
1
|
139
|
POST
|
That is what your issue is. If you are looking for a perfected grid, then the grid to index is your best option. Otherwise, the subdivide polygon is the only tool that would get your polygon to divide as proportionately as possible.
... View more
08-08-2024
06:27 AM
|
0
|
1
|
211
|
POST
|
Have you tried this option? Subdivide Polygon (Data Management)—ArcGIS Pro | Documentation
... View more
08-07-2024
10:02 AM
|
0
|
3
|
230
|
IDEA
|
Hi, I think it would be a great idea to create an arcade function for creating mutli-patch features. This would enable the ability to update an existing multipatch layer/feature without needing to either recreate the feature in autocad or using some other means. I don't know if this could be implemented in the upcoming updates for pro but I am simply throwing it out there. Currently multi-point features can be created but this feels a bit cumbersome to then convert those to a multi-patch feature rather than outright creating it. Especially if users are updating buildings.
... View more
08-06-2024
01:13 PM
|
1
|
0
|
131
|
POST
|
Hi @CCWeedcontrol You can use the Grid Index Feature Tool to automatically create a grid over any feature. If this isn't what you are looking for then you might try the Fishnet tool.
... View more
08-06-2024
01:06 PM
|
1
|
1
|
269
|
IDEA
|
Hi, I noticed that there aren't any options for arcade expressions/attribute rules to update/populate using rasterized features, imagery, or dems and I was wondering if that is something that might be planned for upcoming updates to arcade. For instance, I update a feature layer representing a building that pulls elevation data from a dem and updates either the geometry or the specified field with whatever calculation I need. This would be incredibly helpful and also helps streamlining similar or more complex workflows.
... View more
08-05-2024
06:48 AM
|
0
|
0
|
141
|
POST
|
@christlmistl @ChrisFox answer is the simplest solution to your problem. I would suggest for you to also research the 'console' function which will enable you to see the result in the messages.
... View more
08-02-2024
06:49 AM
|
0
|
0
|
327
|
POST
|
Hi, I believe that there might be a potential bug regarding attribute rules and field maps. I have an editable feature service in field maps that has an attribute rule which populates information from a view table of another server sde table. The rule executes fine in pro but it does not execute in field maps. When executing in field maps, I get the following error message: 'Unable to execute attribute rule <name>. Table cannot be found. I have tried toggling "Exclude from application evaluation" to see if that would fix the issue but to no avail. Has anyone else encountered similar issues when working with views created in sde?
... View more
07-29-2024
05:53 AM
|
2
|
0
|
154
|
POST
|
Hi @SarahTaigelNRT , You can easily accomplish this using experience builder and design it so that it mimics the site you are looking to have the users use. Then you can add buttons that, when clicked on, will either show a text box that is hidden or a view with text, that will navigate like a step by step instruction. Experience Builder Hope this helps.
... View more
07-24-2024
06:38 AM
|
0
|
0
|
145
|
IDEA
|
Hi, I was wondering it would be possible to enable advanced editing/modifying of the html properties in the dashboards to enable users to flex the formatting of table designs. Or if it would be possible to implement an Excel like table in Dashboards as to create more intricate designs for the layout of tabular information. I created a calendar using the basic modifiable html that currently exists within dashboards, but it is rather tedious to constantly adjust. This table is also comprised of an arcade expression to get the days and shift values that is then referenced in the table as expression values.
... View more
07-23-2024
06:19 AM
|
3
|
0
|
182
|
POST
|
Hi, I have tried to fix the error that keeps occurring with the code that I am using below. I have tried researching and trying to find a solution but all of my attempts have yielded the same result. I would greatly appreciate any help with this arcade expression. function CalendarSE(){
var StartMDay = Date(Year(Today()),Month(Today()),1)
var LastMDay = DateAdd(StartMDay,1,'Month')
LastMDay = DateAdd(LastMDay,-1,'day')
var CS = Date(DateAdd(StartMDay,-WeekDay(StartMDay),'day'))
var CE = Date(DateAdd(LastMDay,6-WeekDay(LastMDay),'day'))
return {'Start' : CS , 'End':CE }
}
var CS = CalendarSE()['Start']
var CE = CalendarSE()['End']
var DateField = '<dateField>'
var P = Portal('<portal>')
var Item = Filter(FeatureSetByPortalItem(P,'<itemID>',0,[DateField],False),DateField + ' Between @cs AND @CE')
var DF = 'Y-MM-DD'
var Weekdays = {
'0':'Sunday',
'1':'Monday',
'2':'Tuesday',
'3':'Wednesday',
'4':'Thursday',
'5':'Friday',
'6':'Saturday'
}
var CalendarFields = []
for( var i = 0 ; i < 7 ; i++ ){
Push(CalendarFields,{'name': Weekdays[Text(i)] , 'type':'esriFieldTypeDate'})
Push(CalendarFields,{'name': Weekdays[Text(i)]+'Count' , 'type':'esriFieldTypeInteger'})
}
Console(CalendarFields)
var CalendarTable = {
'fields': CalendarFields,
'geometry' : Null,
'features' : []
}
var DCLimit = {}
for(var i = 0; i < 43; i++){
var T = DateAdd(CS,i,'days')
var CD = DateAdd(T,i+1,'days')
var Cnt = Count(Filter(Item, DateField + ' Between @T AND @CD'))
var W = Weekdays[Text(i%7)]
DCLimit[W] = Date(T)
DCLimit[W+'Count']=Cnt
if( i % 7 == 6 ){
Push( CalendarTable.features , {'attributes': DCLimit } )
DCLimit = {}
}
}
CalendarTable = Featureset( Text(CalendarTable) )
return CalendarTable Any help on this would be greatly appreciated. I would also like to know if there is a simpler way for write this than what I have now.
... View more
06-20-2024
11:21 AM
|
0
|
0
|
234
|
POST
|
Either the original or the pdfs. If you create a table using the IDs from the pdfs and then identify which ones the feature class are identical then it will help attaching the pdfs easier. If there are any ids that standout, then you know which ones might require some modification for the attachments to work properly.
... View more
06-10-2024
01:11 PM
|
0
|
0
|
414
|
Title | Kudos | Posted |
---|---|---|
2 | 08-12-2024 06:46 AM | |
1 | 08-06-2024 01:13 PM | |
1 | 08-06-2024 01:06 PM | |
2 | 07-29-2024 05:53 AM | |
3 | 07-23-2024 06:19 AM |