|
POST
|
Try: mon = today + datetime.timedelta(days=-today.weekday())
print mon.strftime("%Y/%m/%d")
... View more
09-12-2018
03:33 PM
|
1
|
0
|
1463
|
|
POST
|
I use AGOL, so the navigation might be a little different with Server. I log into my account and go to the Content section and select the Feature Layer in question. On the Overview tab, in the Layer's section, click on the layer name (or click the Service URL). Near the top of the next page, there will be a link for the JSON that will take you to the json data. With AGOL it looks like this: Near the bottom of the json, there is a section called types. You should see something like: "types" : [
{
"id" : "0",
"name" : "0",
"domains" :
{
"FieldName" : {"type" : "inherited"}
},
"templates" : [
{
"name" : "0",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"FieldName" : "0"
}
}
}
]
},
{
"id" : "1",
"name" : "1",
"domains" :
{
"FieldName" : {"type" : "inherited"}
},
"templates" : [
{
"name" : "1",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"FieldName" : "1"
}
}
}
]
},
{
... etc ...
}
], You can copy the section and edit it in something like notepad. You will need to add the description where it says 'name' (lines 4, 11, 24, 31, etc.) to the file by replacing the code value like this: "types" : [
{
"id" : "0",
"name" : "Fallen tree",
"domains" :
{
"FieldName" : {"type" : "inherited"}
},
"templates" : [
{
"name" : "Fallen tree",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"FieldName" : "0"
}
}
}
]
},
{
"id" : "1",
"name" : "Water Backup",
"domains" :
{
"FieldName" : {"type" : "inherited"}
},
"templates" : [
{
"name" : "Water Backup",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"FieldName" : "1"
}
}
}
]
},
{
... etc ...
}
], Start the whole types section with an opening { and drop the comma after the last square bracket and close with a }. Check it for valid json with jsonlint.com. If it checks, you can go into the admin section and update the json file. For AGOL the admin address looks something like ('admin' between rest and services): https : // services.arcgis.com/<xxxyyyzzz>/arcgis/rest/admin/services/<feature>/FeatureServer/0 I would practice this on a test copy of your feature and have a backup copy of your feature until you are comfortable with the process. Let me know if you have additional questions. I have also reported this issue to ESRI. Perhaps they will have a better solution.
... View more
09-11-2018
05:12 PM
|
0
|
5
|
6468
|
|
POST
|
I've run into the same issue, as have others. My workaround is posted in this thread: Domains do not appear in Collector after updating in AGOL. It involves correcting the types section of the layer's json file. The id should be the coded value and the name should be the description. Hope this helps.
... View more
09-10-2018
04:41 PM
|
0
|
1
|
6467
|
|
POST
|
With a python toolbox, perhaps if isLicensed() returns false if os.environ['username'] is not in a list, table or file, you might be able to limit who uses the tool. Just a thought.
... View more
09-10-2018
09:58 AM
|
3
|
2
|
1929
|
|
POST
|
What code have you tried with the onMouseDownMap? Just 'pass'? Don't know if something like this would work, but have you tried saving the onMouseDownMap x, y, button and shift data in an array, and then checking the array when onLine is triggered?
... View more
09-09-2018
03:46 PM
|
0
|
0
|
3368
|
|
POST
|
There is an example of onMouseDownMap on this page: How To: Capture map coordinates with a mouse click using Python
... View more
09-09-2018
02:38 PM
|
0
|
0
|
3368
|
|
POST
|
Sounds like a job for numpy array: FeatureClassToNumPyArray. Right, Dan Patterson?
... View more
09-07-2018
12:33 PM
|
0
|
0
|
3974
|
|
POST
|
Here's the script that I use. It does read information from the parent table to get the Object ID along with the attachment's ID to use in renaming the photo. import arcpy, os
masterFC = r'C:\Path\to\file.gdb\feature'
masterFlds = [ 'GlobalID', 'OBJECTID' ]
relatedTbl = r'C:\Path\to\file.gdb\feature__ATTACH' # two underscores
relatedFlds = ['REL_GLOBALID', 'ATTACHMENTID', 'DATA', 'CONTENT_TYPE']
saveLocation = r'C:\Path\to\save\attachments'
# Use list comprehension to build a dictionary from a da SearchCursor: { 'GlobalID': (OJECTID,), .... }
masterDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(masterFC, masterFlds)}
# print masterDict
with arcpy.da.SearchCursor(relatedTbl, relatedFlds) as cursor:
for item in cursor:
# item[3] is Content Type
if item[3] == 'image/jpeg': # process only images; where clause can also be used to limit results
# item[0] is related GlobalID; take first item in masterDict tuple with that key
f1 = masterDict[item[0]][0] # this is the ObjectID of parent record
f2 = item[1] # this is the Attachment ID
# make new filename
fileName = "ATT_{}_{}.jpg".format(f1, f2)
# print filename
# save the image to the desired location
saveName = os.path.join(saveLocation, fileName)
f = open(saveName, 'wb').write(item[2].tobytes())
del cursor
del item If there is a short text item in the parent feature that would also be good to have (an id code field, or tree species, for example), the code could be easily modified to include that information in the file name. # change line 4 to add field
masterFlds = [ 'GlobalID', 'OBJECTID', 'TreeSpecies' ] # field names, not alias
# dictionary would be { 'GlobalID': (ObjectID, 'TreeSpecies',), ...etc... }
# lines 23-25
f2 = item[1] # this is the Attachment ID
f3 = masterDict[item[0]][1] # tree species (if format is appropriate for file name)
# make new filename
fileName = "ATT_{}_{}_{}.jpg".format(f1, f2, f3) While this is not a "script tool", it can be made into one. Hope this helps.
... View more
09-07-2018
11:32 AM
|
0
|
0
|
2398
|
|
POST
|
If the photos were saved as an attachment, there should be linking information in the attachment table. It should contain the point's object an global IDs. I use a Python script to export photos which grabs the associated IDs and uses it to rename photos so the link is retained in the file name.
... View more
09-05-2018
04:54 PM
|
0
|
0
|
2398
|
|
POST
|
Following up on Curtis Price's .tif.xml file tip, something like the following might let you process the metadata: import xml.etree.ElementTree as ET
import glob, os, re
os.chdir(r'C:\Tif\Directory\Path)
for filename in glob.glob('*.tif.xml'):
# print(filename)
tree = ET.parse(filename)
for info in tree.findall('dataIdInfo'):
file = [info.find('idCitation/resTitle').text if info.find('idCitation/resTitle') is not None else ''][0] # file
purpose = [info.find('idPurp').text if info.find('idPurp') is not None else ''][0] # purpose
abstract = [info.find('idAbs').text if info.find('idAbs') is not None else '<span>'][0]
# abstract is inside span tag, this removes the html tags, leaving any text
cleanr = re.compile('<.*?>')
abstract = re.sub(cleanr, '', abstract)
keywords = []
for kw in tree.findall('dataIdInfo/searchKeys/keyword'):
keywords.append(kw.text) # keywords
print 'File: {} \tPurpose: {} \tAbstract: {} \tKeywords: {}'.format(file, purpose, abstract,', '.join(keywords)) You will need to adjust the code to pick up the desired xml tags.
... View more
09-04-2018
10:53 PM
|
1
|
0
|
4031
|
|
POST
|
I suspect your smtp server is wanting authorization. This page https://www.authsmtp.com/python/index.html has a summary of the steps. See also: POP, IMAP, and SMTP settings for Outlook.com. EDIT: In the thread you mentioned, Jake Skinner shared a link (How to Send Emails with Gmail using Python) which also describes the authorization process.
... View more
09-04-2018
12:32 PM
|
1
|
0
|
6941
|
|
POST
|
And something like this should also work: selection = arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION",
where_clause="Field = 'Something'")
result = arcpy.GetCount_management(selection)
count = int(result.getOutput(0))
if count:
print count
arcpy.CopyFeatures.......
See: Get Count You could use GetCount to count items in the layer before and after the selection and if selection is less than the original count and greater than zero then do the copy.
... View more
08-31-2018
08:33 PM
|
1
|
0
|
1466
|
|
POST
|
Tkinter is also an option. For destop 10.6: import Tkinter, tkFileDialog
root = Tkinter.Tk()
root.withdraw()
file_path = tkFileDialog.askopenfilename()
print file_path Using Joshua's suggestion inside ArcMap (at the bottom of the page he referenced): import pythonaddins
import os
class MyValidator(object):
def __str__(self):
return "Text files(*.txt)"
def __call__(self, filename):
if os.path.isfile(filename) and filename.lower().endswith(".txt"):
return True
return False
filename = pythonaddins.OpenDialog(r"C:\Path", filter=MyValidator())
... View more
08-31-2018
10:42 AM
|
2
|
0
|
6900
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-27-2016 02:23 PM | |
| 1 | 09-09-2017 08:27 PM | |
| 2 | 08-20-2020 06:15 PM | |
| 1 | 10-21-2021 09:15 PM | |
| 1 | 07-19-2018 12:33 PM |
| Online Status |
Offline
|
| Date Last Visited |
02-12-2026
07:13 PM
|