|
POST
|
Hi, Although not using RGB for all rasters and a neutral grey for feature classes, I was able to solve my symbology issue. desc = arcpy.Describe(data) mxd_new = arcpy.mapping.MapDocument(mxd_out) df = arcpy.mapping.ListDataFrames(mxd_new, '*')[0] try: lyrFile = arcpy.mapping.Layer(data) if desc.dataType == 'RasterDataset': layerType = arcpy.management.MakeRasterLayer result = layerType(lyrFile, 'temp_layer') layer_object = result.getOutput(0) arcpy.mapping.AddLayer(df, layer_object) else: result = arcpy.management.MakeFeatureLayer(lyrFile, 'temp_layer') layer_object = result.getOutput(0) arcpy.mapping.AddLayer(df, layer_object) This is the key to changing the symbology and adding it to the dataframe before exporting to thumbnail format. Regards, Craig
... View more
06-18-2013
03:23 PM
|
0
|
0
|
662
|
|
POST
|
Hi All, Ended up only needing one line of code to capture my error files as suggested. try: val = desc.SpatialReference.name except: Whole code to perform my error checking: import arcpy, sys, traceback, os from arcpy import env env.workspace = <your workspace> log = r'D:\Temp\error.log' contents = [] print 'Starting' if arcpy.Exists(log): arcpy.Delete_management(log) for dirpath, dirnames, datatypes in arcpy.da.Walk(env.workspace): contents.append(os.path.join(dirpath)) for item in contents: if arcpy.Exists(item): arcpy.env.workspace = item featureType = ['Coverage', 'Raster', 'Feature'] for type in featureType: datasetList = arcpy.ListDatasets("*", type) for dataset in datasetList: data = item + "\\" + dataset desc = arcpy.Describe(data) print data + ' : ' + desc.dataType try: val = desc.SpatialReference.name except: arcpy.ExecuteError arcpy.AddError(arcpy.GetMessage(2)) f=open(log, 'at') f.write(data + '\n') f.close() ## tb = sys.exc_info()[2] ## tbinfo = traceback.format_tb(tb)[0] ## f=open(log, 'at') ## f.write(data + '\n') ## f.close() print 'Done' Trying to describe the spatial reference would cause an error on corrupted files allowing them to be recorded for checking. Tried using 'continue' but didn't seem to work, so leaving it out, the script runs regardless. I was experimenting with ExecuteError and Traceback. Both will work. (OS Windows 7, ArcGIS 10.1 SP1). Regards, Craig
... View more
06-16-2013
03:28 PM
|
0
|
0
|
1562
|
|
POST
|
Hi All, I am developing a script to load layers into a dataframe for exporting to make thumbnails. I would like rasters to appear in RGB symbology and feature classes a neutral grey colour. How do I code so when each data type loads, it will default to my two preferred symbology options? Regards, Craig
... View more
06-12-2013
07:42 PM
|
0
|
1
|
2538
|
|
POST
|
Hi All, I am developing a script that walks a directory and sub-folders listing coverages, rasters and feature classes. Running successfully until it hits files that exist but not structured correctly / corrupted to be able to perform a describe function on. I would like to capture these error files into a log file to check on them later, but have my script run to completition. I have the following trying to capture error related files: try: <my code> except arcpy.ExecuteError: arcpy.AddError(arcpy.GetMessage(2)) f=open(r'D:\Temp\error.log', 'a') f.write(item + "\\" + fileset) f.close() item represents path (e.g. "C:\Temp") and fileset is the file name (e.g. "data.shp"). Not sure what is happening as this seems to work elsewhere on the web I have seen referenced. When I do a desc.SpatialReference.name will usually halt the script with the problem file. I just need coding to detect problem spatial datasets, list them for later checking and move on. Regards, Craig
... View more
05-30-2013
08:33 PM
|
0
|
2
|
2004
|
|
POST
|
Hi All, I know arcpy can be used to make thumbnails from MXDs, but what about using feature classes or rasters? I have thousands of feature classes / rasters that I need to make thumbnails for and don't want to have to manually do this within ArcCatalog one at a time. Any thoughts on how to achieve this? I have code to already list the spatial datasets, just need coding to generate thumbnails that will be incorporated into metadata documents. Regards, Craig
... View more
05-28-2013
02:53 PM
|
0
|
2
|
4691
|
|
POST
|
Code works a treat. Arek's code for dictionaries was the clincher. Regards, Craig
... View more
05-19-2013
07:27 PM
|
0
|
0
|
1159
|
|
POST
|
Code is working nicely that Arek supplied, but I think I need to clarify a bit more. Column1 / Column3 1000 : PlaceA 1000 : PlaceA 1005 : PlaceA 1005 : PlaceA 1009 : PlaceB 1009 : PlaceB After running the dictionary code I found similar named places in Column 3 but with different codes in Column 1. This was something I wasn't aware of until now. I will need to distinguish between same name using different codes. I could not get the original definition query code to work: 'fldCode in (%s)' % map_dict[str(fldName)].join(', ') so substituted with: queryStr = "\"" + fldCode + "\" = " + str(row[1]) My complete code follows, but needs further work to achieve my desired output. import arcpy fc = r"D:\Locations.gdb\Places" fldName = "Place_Name" # Column 3 = row[0] fldCode = "Place_Code" # Column 1 = row[1] map_dict = {} with arcpy.da.SearchCursor(fc, (fldName, fldCode)) as collector: uniqueValues = sorted(set(collector)) if not row[0] in map_dict.keys(): map_dict[row[0]] = [] if not row[1] in map_dict[row[0]]: map_dict[row[0]].append(row[1]) queryStr = "\"" + fldCode + "\" = " + str(row[1]) mxd = arcpy.mapping.MapDocument(r"D:\Places.mxd") elm = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT")[0] elm.text = "Place: " + row[0] df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] for lyr in arcpy.mapping.ListLayers(mxd, "", df): if lyr.name == "Places": if lyr.supports("DEFINITIONQUERY"): lyr.definitionQuery = queryStr arcpy.RefreshActiveView() arcpy.mapping.ExportToPDF(mxd, r"D:\Places\Output" + "\\" + row[0] + "_" + row[1] + ".pdf") del mxd I am trying to make map outputs that will only show places based on their unique code values. I think I may have what I need now, but will notify forum if issues remaining. Will investigate dictionaries further. Regards, Craig
... View more
05-19-2013
04:12 PM
|
0
|
0
|
1159
|
|
POST
|
Hi All, The situation: 1 FC / 3 related columns / definitionQuery on one field has ' as part of field name for only some records which is causing problems Column 1 = numeric code Coumns 2 and 3 = text (both have troublesome ' when it comes to definition query) I want to use Column 1 value that relates to Column 3, use Column 1 value for definition query to get around ' issues, but then need value of Column 3 for layout text element. How do I get a unique listing of the related column 1 and 3 and then seperate their values for two subsequent operations? I am thinking da.SearchCursor but unsure how to get fields in, make unique values and seperate values. Thankyou in advance. Using ArcGIS 10.1 Regards, Craig
... View more
05-16-2013
04:58 PM
|
0
|
3
|
1703
|
|
POST
|
Only noticed PageID as a variable as I quickly scanned over code. Good tip on correct referencing of it. Very difficult to troubleshoot other peoples problems with limited information and feedback. Would be good to know if a solution was found.
... View more
04-10-2013
02:32 PM
|
0
|
0
|
1974
|
|
POST
|
Solution to problem in three easy steps. 1) Using original regular reference grid, use 'Feature to Point' tool with 'Inside' option checked to get centroid of grid cell. 2) Using 'Editor', move your points to the relevant corner of your grid. 3) Using the ESRI IGL Font22 a number of triangles are available either to use as is, or to rotate accordingly (although all four corner orientations are available) to symbolise data. You will need to fiddle with the positioning of points and sizing of triangles to make data fit accordingly. I found that by moving centroids by 90% relative to distance from centre to either edge and setting symbol to size 20 managed to get the desired result. Hope this helps and reduces amount of work. Regards, Craig
... View more
04-09-2013
07:59 PM
|
0
|
0
|
3456
|
|
POST
|
Maybe use a python script to iterate your polygons and establish xy corner coordinates, create a point file, symbolise using rotated triangles with an offset (this will depend on size of triangle symbol). Maybe offset the whole point shapefile once you have sorted out your symbol sizing. This would require a regular grid to have triangles placed in a corner. Just a thought. Regards, Craig
... View more
04-09-2013
02:36 PM
|
0
|
0
|
3456
|
|
POST
|
Not sure, but you have a variable pageID, but then don't use it in code. I have substituted into code to make it look like:
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = pageNum
pageID = mxd.dataDrivenPages.getPageIDFromName("PARCEL_NO")
arcpy.mapping.ExportToJPEG(mxd, r"P:\Township Maps\Bloomingdale\JPEG" + "\" + pageID + ".jpeg", resolution=100)
del mxd
I also added an additional "\" to folder jpeg images under JPEG folder. You were trying to append new file to JPEG folder name. Regards, Craig
... View more
04-07-2013
03:34 PM
|
0
|
0
|
1974
|
|
POST
|
Hi All, Ended up making my own simple symbol to orientate people facing signage placed in different positions with different orientations. Was hoping something already existed and may have been a standard or widely utilised. Simple overhead depiction of a head (circle) in front of signage (rectangular box). Circle and rectangle will be incorporated into a style and rotated according to signage placements. [ATTACH=CONFIG]22197[/ATTACH] Regards, Craig
... View more
02-26-2013
05:11 PM
|
0
|
0
|
988
|
|
POST
|
Try using model builder and one of the iterate functions to list and iterate MXD files in a workspace / directory and export to PDF. If you have subfolders have a look into the arcpy Walk function to do recursive searches for MXD files. Regards, Craig
... View more
02-25-2013
12:01 PM
|
0
|
0
|
3306
|
|
POST
|
Hi All, I am looking for ideas on 1) a symbol that exists or 2) one that I might make, to represent how an information sign relates to a person looking at it to orientate themselves to their surroundings. We have several signs placed around my place of work so that people and find there ways to buildings. What is happening is that some people when facing the signs (they are marked with a 'you are here' identifier) don't realise that some buildings may be to their left or right because the map is orientated with north to the top but the sign is erected facing east and the person viewing is facing west. I don't want to re-orient the map/dataframe, so looking for ideas on symbols that others may have seen or created and willing to share. Regards, Craig
... View more
02-17-2013
06:38 PM
|
0
|
2
|
1525
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-22-2014 03:26 PM | |
| 1 | 11-03-2022 03:28 PM | |
| 1 | 05-24-2021 05:01 PM | |
| 1 | 12-02-2019 02:46 PM | |
| 3 | 11-01-2020 07:20 PM |
| Online Status |
Offline
|
| Date Last Visited |
06-04-2025
09:55 PM
|