POST
|
I am not quite sure what filters you are looking to apply but there are ways to set different kinds of filters using the filter widget in Web App Builder dashboard layout. I don't know about Dashboards itself since I primarily use Web App Builder when creating dashboards.
... View more
07-14-2021
10:12 AM
|
0
|
1
|
2822
|
POST
|
Hi, Usually the workspace is set to whatever the database is since that is where the edit session usually occurs, then you can specify the feature class(s) that you want to edit in that workspace. import arcpy
arcpy.env.OverwriteWorkspace = True
workspace = r'database.sde' # or database.gdb
walk = arcpy.da.Walk(workspace, datatype="FeatureClass")
fcs = []
edit = arcpy.da.Editor(workspace)
edit.startEditing(False, True)
edit.startOperation()
for dirpath, dirnames, filenames in walk:
for filename in filenames:
fcs.append(os.path.join(dirpath, filename))
for fc in fcs:
geometryType = arcpy.Describe(fc).shapeType
fcsname = os.path.basename(fc)
name = os.path.splitext(fcsname)
y = name[1].lstrip('.')
print (y)
#Insert code here#
edit.stopOperation()
edit.stopEditing(True) This is what I typically do when editing a database. Hope this helps.
... View more
07-14-2021
09:25 AM
|
0
|
0
|
2379
|
POST
|
So you can modify the model to achieve this as well. You can create points from lines using Create lines from points while using model iterators in tandem to create separate point feature classes for each set of lines based on that criteria. From there you can use the create points along line tool to then get the territories between the sightings. Or you can create a custom shape based on the length of the lines using a similar process above if there are coincidental points within the given criteria, and use that shape to create a single point from that shape. So The other bigger question is, like David was saying: "Also recommend figuring out what you envisage the territory to look like, as this will affect the logical steps in the model.", how do you want to derive the territory?
... View more
07-14-2021
08:56 AM
|
0
|
0
|
556
|
POST
|
Hi freddys94, So there are a couple of ways to achieve what you are looking to do. Option 1: Run scripts automatically via Windows Task Scheduler: With this method you can easily create a python script, schedule the script to run using a .bat file, and set the dates and times for it to run. Here is a link that gives an breakdown on how to schedule scripts to run using Windows Task Scheduler. Automate Python Scripts Option 2: Create a custom tool using model builder or a custom python script tool: You can create a custom tool using either model builder or python. With modelbuilder, you can use the various tools to create territory points based on the criteria, and then run the tool whenever needed. With the python script tool, you write a python script and set the parameters like any other geoprocessing tool based on the inputs and outputs. Neither option isn't automated, but they could be used to cut down the time needed to do any manual process. Modelbuilder There isn't a drag and drop instance where you can plug in an algorithm and things just run automatically. But the options that I gave should help out with what you are trying to accomplish.
... View more
07-14-2021
04:42 AM
|
0
|
1
|
587
|
POST
|
Thanks BlakeTehrune for the advice. I didn't think to clearly write out the specifics of each line of code. I usually try to group it all under a simplified title of sorts to show what each snippet of code does. As for the python formatting, I extended the indentation to 8 instead of 4, even though I know 4 is the standard, but I did that to see if there were any slight indentation issues since I was running into that issue for several lines of my code. And I greatly appreciate the example. I have been churning on this for the past several days now, and I just couldn't find a solution or come up with one. I still don't fully understand some of the intricacies of python and so I am still learning what is possible and what isn't. I am also trying to learn and understand areas of python, such as "+=" and how something like this is implemented.
... View more
07-09-2021
12:17 PM
|
0
|
1
|
1019
|
POST
|
Hi, So I have come across a challenging situation where I have multiple attribute values, and I want to create nested dictionaries based on certain attributes. So for instance: {Pipe Diameter: {Pipe Material A: Total length for diameter and material, Pipe Material B: Total length for diameter and material} import arcpy
import math
import time
#import pandas as pd
import sys
import os
in_fcs = feature class name
workspace = feature class
fcs = []
walk = arcpy.da.Walk(workspace, datatype="FeatureClass")
for dirpath, dirnames, filenames in walk:
for filename in filenames:
#Get feature class name
fcsname = os.path.basename(filename)
name = os.path.splitext(fcsname)
y = name[1].lstrip('.')
if y in in_fcs:
#print y
fcs.append(os.path.join(dirpath, filename))
for fc in fcs:
geometryType = arcpy.Describe(fc).shapeType
#print (geometryType)
fc_fields = []
important_fields = ['OBJECTID', Field A, Field B, FIeld C, Field D]
important_FAvalues = [List of important attribute values in field A]
important_FBvalues = [List of important attribute values in field B]
fcsname = os.path.basename(fc)
name = os.path.splitext(fcsname)
y = name[1].lstrip('.')
print ('\n',y)
i = 0
t = 0
#v = {}
d = {}
allfields = arcpy.ListFields(fc)
for field in allfields:
if field.name in important_fields:
#print (field.name)
fc_fields.append(field.name)
fcFields_len = len(fc_fields)
fc_fields_wLength = fc_fields + ['SHAPE@LENGTH']
ImpA = fc_fields_wLength.index(important_fields[1])
ImpB = fc_fields_wLength.index(important_fields[2]) or fc_fields_wLength.index(important_fields[3])
ImpC = fc_fields_wLength.index(important_fields[4])
ImpD = fc_fields_wLength.index(important_fields[5])
with arcpy.da.SearchCursor(fc, fc_fields_wLength) as scur:
for s in scur:
if s[ImpA] in important_FAvalues and s[ImpB] in important_FBvalues:
i = i + 1
t = t + s[-1]
if s[ImpC] is None:
#d[s[ImpC]] = {s[ImpD]:s[-1]}
pass
elif s[ImpC] is not None:
if int(s[ImpC]) >= 8 and int(s[ImpC]) <= 42:
#d = {}
d[s[ImpC]] = {}
for a, b in d.items():
if a == s[ImpC]:
for e, f in b.items():
if e == s[ImpD]:
f = f + s[-1]
d[s[ImpC]][s[ImpD]] = f
else:
d[s[ImpC]][s[ImpD]] = s[-1]
#print (round(t, 2))
print (d) So I am unclear on how to accomplish this, but if anyone could help me with this I would greatly appreciate it.
... View more
07-09-2021
09:35 AM
|
0
|
3
|
1034
|
POST
|
Hi David, I updated the post to include a snippet of the code. Let me know if this is a supplemental amount of information to work with.
... View more
07-07-2021
12:38 PM
|
0
|
0
|
529
|
POST
|
Thanks BlakeTerhune for the help. I haven't seen this method before nor did I even know about it. I will definitely have to give this a try when I get around to it. This would be extremely helpful for making general script tools rather than having to script something specific all the time.
... View more
07-07-2021
10:47 AM
|
0
|
0
|
894
|
POST
|
Hi, So I have a unique situation where I have a pipe feature class with attributes of any given diameter, and I want to create a dictionary where the key for each diameter of pipe greater than a set diameter, and append dictionaries of pipe materials and overall lengths for each material. I have something scripted that gets me fairly close, but for some reason it keeps updating the unique key for the diameter and not appending additional dictionaries to that key. for fc in listed_fcs:
geometryType = arcpy.Describe(fc).shapeType
#print (geometryType)
fc_fields = []
important_fields = [list of specific fields]
important_FAvalues = [list of important attributes in field A]
important_FBvalues = [list of important attributes in field B]
fcsname = os.path.basename(fc)
name = os.path.splitext(fcsname)
y = name[1].lstrip('.')
print ('\n',y)
i = 0
t = 0
d = {}
v = {}
#counts = arcpy.GetCount_management(fc)
#______________Loop through databases that are not stormwater__________#
if y not in [fc list]:
allfields = arcpy.ListFields(fc)
for field in allfields:
if field.name in important_fields:
#print (field.name)
fc_fields.append(field.name)
fcFields_len = len(fc_fields)
#_____________Loop through two set fcs____________#
if y in [specified list of fcs]:
fc_fields_wLength = fc_fields + ['SHAPE@LENGTH']
ImpA = fc_fields_wLength.index(important_fields[1])
ImpB = fc_fields_wLength.index(important_fields[2]) or fc_fields_wLength.index(important_fields[3])
ImpD = fc_fields_wLength.index(important_fields[4])
ImpE = fc_fields_wLength.index(important_fields[5])
with arcpy.da.SearchCursor(fc, fc_fields_wLength) as scur:
for s in scur:
if s[ImpA] in important_FAvalues and s[ImpB] in important_FBvalues:
i = i + 1
t = t + s[-1]
m = 0
if y not in [waterin_fcs[3], water_upper[3]] :
if s[ImpD] is None:
#d[s[ImpD]] = {s[ImpE]:m + s[-1]}
pass
elif s[ImpD] is not None:
if int(s[ImpD]) >= 8 and int(s[ImpD]) <= 42:
m = m + s[-1]
v[s[ImpE]] = (m)
else:
if s[ImpD] is None:
#d[s[ImpD]] = {s[ImpE]:m + s[-1]}
pass
elif s[ImpD] is not None:
if s[ImpD] >= 2.5:
m = m + s[-1]
v[s[ImpE]] = (m) This is a small snippet of the actual code. The actual code itself is increasingly too long to post. So is there a way to script this so that for each unique pipe diameter, I get all of the materials of that pipe plus the total distances, and append that dictionary(s) to the dictionary for the pipe diameter? I would greatly appreciate it if anyone could assist me with this. I have spent several hours trying to figure it out but I can't seem to.
... View more
07-07-2021
10:29 AM
|
0
|
2
|
592
|
POST
|
Thanks Jeff for sending me this sample code. This is a lot closer to what I was looking for. I completely forgot that I could have used the ().index method to auto-identify the rows without the needing to specify the index manually.
... View more
07-07-2021
04:43 AM
|
0
|
0
|
908
|
POST
|
Hi, I was wondering if there is a way to write a script where a list of fields can be self indexing for the search or update cursor? The reason for this is because I am trying to set up a script tool in such a manner that regardless of the order of the fields, the script will be intelligent enough to identify those fields and then be able search through the attributes with those fields without the need for manually indexing. I have a list of important attributes as well as the fields in which those values reside, but I would write the script to self index and search for those specific values. I figured enumerating the list of fields and creating a dictionary for the enumerated values is a start, but figuring out how to go from there is a bit tricky for me at the moment. So I wanted to reach out and see if anyone has ever attempted this, and if so, how did you write it.
... View more
07-02-2021
09:24 AM
|
0
|
5
|
1006
|
POST
|
Sorry Dan, I must have misunderstood. In any case I finally realized where I was going wrong, and I was able to easily correct the issue.
... View more
06-23-2021
01:03 PM
|
0
|
0
|
177
|
POST
|
Thanks forestknutsen1. We use SQL databases so anything Oracle related I wouldn't be able to use. Thank you though for the offer, I will let you know if we end up utilizing something related to Oracle where that kind of script would come in handy.
... View more
06-23-2021
01:02 PM
|
0
|
0
|
1671
|
POST
|
Thanks Dan, I also tried using the field name as well and the result was still the same. So I tried using the shape@length for the featureclass(s) to see if the result would be different but the result didn't change. I am under the impression that the issue perhaps lies in the database itself and its permissions, but one of our dbas is looking into it.
... View more
06-21-2021
01:03 PM
|
0
|
2
|
1724
|
POST
|
Thanks Dan, Does the shape field also read the length field as well? I just need the length field for a report that the script prints out with details on the specified feature classes with their total combined lengths for each record and print a text file of those total lengths.
... View more
06-21-2021
08:20 AM
|
0
|
4
|
1735
|
Title | Kudos | Posted |
---|---|---|
1 | a week ago | |
2 | a week ago | |
4 | 2 weeks ago | |
1 | 3 weeks ago | |
1 | 3 weeks ago |