|
POST
|
I have also noticed this. This is when I am using the domain for symbology. When I examine the JSON file for the feature, specifically the "types" section, the "id" and the "name" both contain the coded value. The name should contain the code's description. I always need to edit this section of the file as the publishing process fails to use the domain sort order. While doing my typical editing, I noticed that the issue with the code being used in place of the description. In my case, publishing was done with ArcMap 10.5 when I first noticed the name issue. The sort order issue has been around since 10.2.
... View more
09-17-2017
01:33 PM
|
1
|
3
|
5757
|
|
POST
|
I have been experimenting with some code that may help you. It exports attachments and saves them using a unique filename that includes the object ID from the feature layer, the object ID of the attachment, and text from a field in feature layer. import arcpy
import os
import re
origTable = r"C:\Path\To\Your.gdb\Layer"
attachTable = "{}__ATTACH".format(origTable) # if no attachTable given, append __ATTACH to origTable
nameField = "dataField" # appropriate name field in origTable
fileLocation = r"C:\Path\To\Save\Directory"
origFieldsList = ["GlobalID", "OBJECTID", nameField] # GlobalID for linking, OBJECTID for renaming, nameField for renaming
# Use list comprehension to build a dictionary from a da SearchCursor
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(origTable, origFieldsList)}
# REL_GLOBALID # 'sc_portal_map_ld_globalid_2' # GlobalID that links to origTable
with arcpy.da.SearchCursor(attachTable, ['DATA', 'ATT_NAME', 'ATTACHMENTID', 'REL_GLOBALID']) as cursor:
for item in cursor:
attachment = item[0] # attachment data
filenum = "ATT" + str(item[2]) + "_"
filename = filenum + str(item[1]) # this will be the filename if linking fails
# store the Join value of the row being updated in a keyValue variable
keyValue = item[3] # REL_GLOBALID
# verify that the keyValue is in the Dictionary
if keyValue in valueDict:
# transfer the values stored under the keyValue from the dictionary to the updated fields.
obID = valueDict[keyValue][0]
# remove invalid filename characters, replace spaces and periods, limit length
namefield = re.sub('[^0-9a-zA-Z]+', '_', valueDict[keyValue][1])[:18]
# Create a unique filename ObjectID_AttachmentID_namefield.ext
ext = filename.rsplit('.', 1)[-1] # keep extension of original file
filename = "{}_{}_{}.{}".format(obID,item[2],namefield,ext)
print "Writing: {}{}{}".format(fileLocation, os.sep, filename)
open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes())
del item
del filenum
del filename
del attachment
del valueDict
print "Done" Since you are using Portal, you may need to make some adjustments. I was working with a downloaded geodatabase from AGOL. Although it is not set up as a tool, this could be done. Hope this helps. References: How To: Batch export attachments from a feature class Turbo Charging Data Manipulation with Python Cursors and Dictionaries (Example 2 method is used here)
... View more
09-16-2017
01:40 PM
|
5
|
8
|
6622
|
|
POST
|
Tagging Python. You might get more responses. Formatting your code will also help, see: Code Formatting... the basics++
... View more
09-15-2017
04:03 PM
|
1
|
0
|
6622
|
|
POST
|
Glad that the output is showing the grouping that you want with your modification. I have added back in some of your earlier code, but I may have missed something. import arcpy
# make sure this directory exists
out = r'H:\PRISM_800m_weekly_sum\Normal_out'
for week in range(1, 5+1): # for weeks 1 to 5
for month in range(9, 11+1): # for months 9 to 11
rasterlist = [] # initialize a list for the rasters
for year in range(1981, 2016+1): # for years 1981 to 2016
rasterfile = "H:\\PRISM_800m_weekly_sum_Normal\\{}\\Week_{}_Sum{}_{}.tif".format(year, week, year, month)
# probably should add some error checking to see that file exists before adding it to rasterlist
if arcpy.Exists(rasterfile):
rasterlist.append(rasterfile) # if found, append file to the raster list
else:
print "Not found: {}".format(rasterfile)
# same indentation as "for year in..."
# rasterlist.sort() # you probably don't need to sort the list
finras1 = out + "\\Normal_Week_{}_1981_2016_{}.tif".format(week, month)
print "Processing file: {}".format(finras1)
calc1 = arcpy.sa.CellStatistics(rasterlist, statistics_type = "MEAN", ignore_nodata="DATA")
arcpy.CopyRaster_management(calc1,finras1,"","","","","","32_BIT_FLOAT")
print "Done."
Also, keep in mind what Dan Patterson said in his comments in another of your questions regarding working with rasters. Remember that indentation is important, and it is often good to have some print statements in your code to help you know where things are going right or wrong. Hope this helps.
... View more
09-15-2017
01:15 PM
|
2
|
2
|
2695
|
|
POST
|
Does the following code print a listing of your files in the proper grouping for analysis? (I'm still trying to understand your directory structure and the objective.) groupNum = 1
for week in range(1, 5+1): # for weeks 1 to 5
print "Files in group {}:".format(groupNum)
groupNum += 1
for month in range(9, 11+1): # for months 9 to 11
if month > 9:
print "Files in group {}:".format(groupNum)
groupNum += 1
for year in range(1981, 2016+1): # for years 1981 to 2016
print "\tH:\\PRISM_800m_weekly_sum_Normal\\{}\\Week_{}\\Week_{}_Sum{}_{}.tif".format(year, week, week, year, month)
If the listing is correct, then we can modify the code to do the analysis.
... View more
09-15-2017
11:36 AM
|
1
|
4
|
2695
|
|
POST
|
You might try updating the definition so that minScale is 0. But you should be able to override this setting with the visibility range when you create a map in AGOL. I've played around with this setting on one of my layers, but I haven't been able to duplicate your situation.
... View more
09-15-2017
10:14 AM
|
2
|
1
|
2517
|
|
POST
|
Hi Dumindu, I agree with Dan Patterson that you have some indentation issues with your code. I may not understand exactly what you are trying to accomplish, but it looks like you want to average the raster files for the first week (week 1) of September (month 9) for the years 1981 to 2016. Then move to the next month and eventually loop through all the weeks. This is suggested by the file you are saving to found in line 19 of your code. finras1 = out + "\\" + "Normal_Week_" + str(week) + "_1981_2016" + "_" + str(month) + ".tif"
If so, you may have your loops in the wrong order. You may want something like this: for week in range(1, 5+1): # for weeks 1 to 5
for month in range(9, 11+1): # for months 9 to 11
for year in range(1981, 2016+1): # for years 1981 to 2016
print "Week_{}_Sum{}_{}.tif".format(week, year, month)
'''
Result:
Week_1_Sum1981_9.tif
Week_1_Sum1982_9.tif
...
Week_1_Sum2015_9.tif
Week_1_Sum2016_9.tif
Week_1_Sum1981_10.tif
Week_1_Sum1982_10.tif
...
Week_1_Sum2015_10.tif
Week_1_Sum2016_10.tif
Week_1_Sum1981_11.tif
Week_1_Sum1982_11.tif
...
Week_1_Sum2015_11.tif
Week_1_Sum2016_11.tif
Week_2_Sum1981_9.tif
Week_2_Sum1982_9.tif
...
...
Week_5_Sum2015_11.tif
Week_5_Sum2016_11.tif
''' If this is the case, you may want to change the directory structure of your rasters, with the weeks folders containing the months folders which contain the years folders. This would simplify what you are trying to do with arcpy.env.workspace and arcpy.ListRasters. It would probably be helpful if you could describe the directory structure you are working with.
... View more
09-14-2017
08:58 PM
|
2
|
6
|
2695
|
|
POST
|
When you look at the layer's json file, what are the values of "minScale" and "maxScale"?
... View more
09-14-2017
09:33 AM
|
0
|
3
|
2517
|
|
POST
|
Open your map in ArcGIS Online and check the visibility settings on the layers you are having issues with. There are two settings: the zoom level for them to show up and the zoom level for them to disappear. It is the second that appears to be causing the problem. Try setting it to "room", and then resave your map and refresh it in Collector.
... View more
09-13-2017
09:43 AM
|
0
|
5
|
2517
|
|
POST
|
This might give you an idea: rasterlist = [
"Week_1_Sum1981_10_Crawford.tif",
"Week_1_Sum1982_10_Crawford.tif",
"Week_1_Sum2016_10_Crawford.tif",
"Week_2_Sum1981_10_Crawford.tif",
"Week_2_Sum2016_10_Crawford.tif",
"Week_5_Sum2016_10_Crawford.tif"
]
for year in range(1982, 1982+1): # startYear, endYear+1
for month in range(10, 10+1):
for week in range(1,1+1):
raster = "Week_{}_Sum{}_{}_Crawford.tif".format(week,year,month)
if raster in rasterlist:
print "Found: {}".format(raster)
# Output:
# Found: Week_1_Sum1982_10_Crawford.tif If you want to put all the tif files in a directory into a list you could use something like: import os, glob
rasterDir = r'C:\Path\To\Rasters'
rasterlist = list(os.path.basename(x) for x in glob.glob(rasterDir + r'\*.tif'))
print rasterlist Hope this helps.
... View more
09-12-2017
05:17 PM
|
1
|
0
|
1675
|
|
POST
|
I believe the OP is trying to show an abbreviated file list as in "Week_1_Sum1981" to "Week_1_Sum2016" (advancing by month and year). For some additional context, see his earlier question: Help to find file index based on year, month and week in Python. Perhaps walking through the directory listing using os.walk() would be an appropriate approach for his question.
... View more
09-12-2017
02:10 PM
|
0
|
0
|
1675
|
|
POST
|
In your code, you are setting: df = arcpy.mapping.ListDataFrames(mxd)[0] Then you are referencing it in the export code. This is accessing the frame in "Data View" which uses your screen's resolution. Without a data frame reference, the export code will default to "PAGE_LAYOUT" (or "Layout View") which will allow you to set the resolution. I tested the following code in ArcMap 10.5 at resolutions of 150 and 300. mxd = arcpy.mapping.MapDocument("CURRENT")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = pageNum
arcpy.mapping.ExportToJPEG(mxd, r"C:\Path\To\Page" + str(pageNum) + ".jpg", resolution=300)
del mxd
ExportToJPEG Exporting Data Driven Pages
... View more
09-09-2017
08:27 PM
|
1
|
3
|
4844
|
|
POST
|
You should not have to rename your TOC layers. The "lyr.name.lower()" converts the layer name to lower case letters, and then it is compared to a specified lower case string. If you want to save the changes you will need to use either: # save the current mxd
mxd.save()
# or save a copy
mxd.saveACopy(r"C:\Temp\Split MXD2.mxd")
... View more
09-08-2017
04:51 PM
|
1
|
0
|
1988
|
|
POST
|
Since you are making lyr.name all lower case, I would try: if lyr.name.lower() == "taxparcels1":
# and
if lyr.name.lower() == "sections":
... View more
09-08-2017
02:51 PM
|
1
|
3
|
1988
|
| 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
|