POST
|
You can do this dynamically with something called a label expression. An example label expression would look something like: Right ( [Field], 3 ) The picture shows how to get to the Label expression window from the 'Label' tab; although the expression shown in the graphic will need to be updated to something similar as the code example above.
... View more
08-29-2011
03:22 PM
|
0
|
0
|
1126
|
POST
|
I am just starting to learn about python and building a GUI. I don't know anything about VB so I can't offer any valid pointers there, but... one thing I am exploring is the tkinter module. A nice tkinter tutorial or explanation. There is also the option to keep your GUI within the ArcGIS environment by turning your Python Scripts (that are using arcpy) into ArcGIS Tools. Some python tool creation resources from the ArcGIS resource centre: http://downloads2.esri.com/Gallery/downloads/61B0578E-1422-2418-A01D-D62CAFD635C9.zip (10.1 mb) http://downloads2.esri.com/Gallery/downloads/E659B66B-1422-2418-A052-93CC5699FF65.zip (17.7 mb) The above contain mxd's, data and pdfs to follow along.
... View more
08-29-2011
03:13 PM
|
0
|
0
|
198
|
POST
|
You can do all of this in ArcGIS - here are some options: 1.) Make sure your subdiv. lines are converted to polygons (this tool requires the mighty arcinfo...) if they aren't already and I would recommend storing them as a feature class inside of a geodatabase. (This is because the [AREA] field is added and calculated automatically) 2.) You can now use a label expression to both label more than one field at once AND display the [AREA] in whatever units you desire: example: [FIELD1] & " - " & [FIELD2] & vbNewLine & Round ( ([Shape.area] * 0.0002471054), 2 ) & " acres" ...where [Shape.area] is in square metres and converted to Acres - rounded to the second decimal place 3.) As for freezing your dataframe, either apply a fixed scale to stop the zooming but this does not stop the panning. The most effective way I have found is to position your dataframe where you like in the layout, then apply a bookmark to save the current extent, scale and geographic location of the active dataframe. Bookmarks allow you to go back to where you once were and it retains the scale and position (centre of map). Extent will be determined by width and height of dataframe in the layout if it is set to a fixed scale and not to 'automatic'.
... View more
08-25-2011
09:32 AM
|
0
|
0
|
299
|
POST
|
Sorry I'm a little late to the club. I just posted the script I wrote earlier this year. Simple but does a good job. There is much room for improvement, appreciate any feedback. Hopefully it helps you out. http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=D8ED73DF-1422-2418-7F74-A6DCBEA9A2EB Great job. This is very handy indeed! Update on my little corrupt mxds: the things could not be saved with any mxd doctors so a little copy and pasting of the layouts was done into a new blank mxd then the scripts run fine.
... View more
08-22-2011
08:04 AM
|
0
|
0
|
203
|
POST
|
Let's try recreating the MXD. That will work, but it may not be feasible given the production method used for these mxd's... I can for example, copy and paste all page layout elements (dataframes, scalebars, images, north arrows and legends with a Ctrl+A, Ctrl+C then a Ctrl+V) successfully into a new blank mxd. But their position and size are lost, sometimes larger or smaller depending on the viewing scale in my layout view. I cannot let this happen, because now I have to go and match the size and position of EVERY layout element to the old values. (I tried grouping everything and then batch re-sizing this single object but some objects don't maintain their respective positions) Making sure both mxd's are 1:1 in layout mode will help get rid of some of the scaling issue... Reference scales are kept, but the map extent changes. The formatting in my legends are lost too, they paste fine and at first - visually they are correct, but when I save and close then re-open the mxd, they default to a "default legend" will ALL the layers in my TOC present, with default symbol/patch properties and export to PDF as such. My formatting and styles are not kept in the legend... I have to copy and paste the actual dataframes because they contain annotation groups that need to be carried over. I would like to batch export these because it takes me half a working day just to open > export map > close > open next map... Any thoughts on if I should be 'upgrading' to 9.3.1? I really enjoy the new look and feel of v10 but some of these minor hiccups cut deep into my day(s) and confuse me especially when I am trying to learn more about arcgis python scripting. This reminds me of the time when I was younger and went to the hospital to get my cast removed. I was terrified of the doctor with that vibrating saw thingy. "It won't even cut through paper she says", and places a piece of paper on the bench and turns the saw on at which point it cuts through cleanly. "Bad example", is all she said and quickly went to work on removing my cast...
... View more
08-02-2011
03:42 PM
|
0
|
0
|
692
|
POST
|
Does your data within your MXDs resides within an SDE geodatabase? If so, can you try this script on an MXD that contains data from a File or Personal geodatabase? EDIT: Forgot to say that my 'rocp' mxds do have data from shapefiles, gdb, and an sde. I created some new/blank mxds that all exported fine: Shapefiles.mxd FileGDB.mxd SDE.mxd All3.mxd Its my "rocp" mxds that fail! They were from 9.3.1 so I opened one and saved it as a copy to version 10; still failed. " rel="nofollow" target="_blank">http://www.youtube.com/watch?v=S8iclZrdp2A[/video]
... View more
07-28-2011
11:19 AM
|
0
|
0
|
692
|
POST
|
Thanks for all your help. This script started from the simplest form as taken from the bottom of this page: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/ExportToPDF/00s300000027000000/ import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_1_17x11.mxd")
print 'Exporting PDF...'
arcpy.mapping.ExportToPDF(mxd, r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_1_17x11.pdf")
print 'Done exporting!'
del mxd The above fails with my original error: An existing connection was forcibly closed by the remote host. My license level is ArcView (local) and occasionally I use an ArcEditor concurrent-use when needed. This is running on a fresh install of windows 7 and arcgis 10 sp2. Not tested with sp1 or no sp installed. Windows 7 firewall is turned off. EDIT: I have tried using all forms of path names from the help: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Setting_paths_to_data_in_Python/002z0000000r000000/
... View more
07-28-2011
10:26 AM
|
0
|
0
|
692
|
POST
|
I specified 'baseF = os.getcwd()' first and then added the baseF variable to the glob module, 'mxdLst = glob.glob(baseF + '\\' + '*.mxd')'. Thanks for the simplification! It throws the old error where the connection was closed... But when I make the following change (surround in double quotes): inMxd = arcpy.mapping.MapDocument('\"' + mxds + '\"') #Make current mxd in loop the mapdocument or (surround in double quotes with 'r' prefix) inMxd = arcpy.mapping.MapDocument('r\"' + mxds + '\"') #Make current mxd in loop the mapdocument I get the invalid mxd name error from pyscripter (it crashed in IDLE): [ATTACH]7948[/ATTACH] Looks like the part in red shows it is NOT passing the os.path.isfile(mxd) check/test. Side question: When I use the 'str' command in the script is it not necessary to import the 'string' module?
... View more
07-27-2011
10:35 AM
|
0
|
0
|
692
|
POST
|
Woohoo, new error. The script below: #Import python modules
import os, sys, string, glob, arcpy.mapping
#Set local variables
mxdLst = glob.glob('*.mxd')
mxdCnt = len(mxdLst)
####
#Place script in same folder as MXDs to get 'current working directory'
####
baseF = os.getcwd()
#Print how many mxd's found
print '\n' + 'Found ' + str(mxdCnt) + ' MXDs for exporting to PDF...'
print 'Directory: ' + baseF + '\n'
#For loop to process each mxd into a PDF
for mxds in mxdLst:
#outPDF = mxds.replace('mxd', 'pdf') #Replace 'mxd' extension with 'pdf'
#print 'Exporting ' + mxds + ' -> ' + outPDF
mxd = 'r' + '\"' + baseF + '\\' + mxds + '\"' #mxd with fullpathname
#inMxd = arcpy.mapping.MapDocument(mxd) #Make current mxd in loop the mapdocument
#arcpy.mapping.ExportToPDF(inMxd, outPDF) #Export mapdocument to pdf
#print 'Done exporting: ' + outPDF
print mxd
del mxds Outputs: Found 5 mxds for PDF exporting...
Directory: C:\Users\is0009\Desktop\temp
r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_1_17x11.mxd"
r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_2_17x11.mxd"
r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_3_17x11.mxd"
r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_4_17x11.mxd"
r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_5_17x11.mxd" ...where I am trying to pass the above 'string' as my MapDocument. But when I modify the script to then use that string: #Import python modules
import os, sys, string, glob, arcpy.mapping
#Set local variables
mxdLst = glob.glob('*.mxd')
mxdCnt = len(mxdLst)
####
#Place script in same folder as MXDs to get 'current working directory'
####
baseF = os.getcwd()
#Print how many mxd's found
print '\n' + 'Found ' + str(mxdCnt) + ' MXDs for exporting to PDF...'
print 'Directory: ' + baseF + '\n'
#For loop to process each mxd into a PDF
for mxds in mxdLst:
outPDF = mxds.replace('mxd', 'pdf') #Replace 'mxd' extension with 'pdf'
print 'Exporting ' + mxds + ' -> ' + outPDF
mxd = 'r' + '\"' + baseF + '\\' + mxds + '\"' #mxd with fullpathname
inMxd = arcpy.mapping.MapDocument(mxd) #Make current mxd in loop the mapdocument
arcpy.mapping.ExportToPDF(inMxd, outPDF) #Export mapdocument to pdf
print 'Done exporting: ' + outPDF
#print mxd
del mxds Results in the following error from IDLE now: Found 5 MXDs for exporting to PDF...
Directory: C:\Users\is0009\Desktop\temp
Exporting Rural_OCP_map_1_17x11.mxd -> Rural_OCP_map_1_17x11.pdf
Traceback (most recent call last):
File "C:\Users\is0009\Desktop\temp\mxdloop.py", line 23, in <module>
inMxd = arcpy.mapping.MapDocument(mxd) #Make current mxd in loop the mapdocument
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\mixins.py", line 443, in __init__
assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(89004, "Invalid MXD filename")
AssertionError: Invalid MXD filename. What is it that is making my MXD name invalid? Is it because I am not handling the slashes in the filepath name correctly and they are considered invalid characters?
... View more
07-26-2011
03:13 PM
|
0
|
0
|
692
|
POST
|
I wrote a small python script that exports all mxd's in a folder to PDF's, but I get the following error in PyScripter and I don't know why...: [ATTACH]7866[/ATTACH] The python interpreter has whole bunch of red in it: Found 5 mxds for PDF exporting...
Directory: C:\Users\is0009\Desktop\temp
Exporting Rural_OCP_map_1_17x11.mxd to:
C:\Users\is0009\Desktop\temp\Rural_OCP_map_1_17x11.pdf
Traceback (most recent call last):
File "<string>", line 70, in execInThread
File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\netref.py", line 123, in __call__
File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\netref.py", line 45, in syncreq
File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\protocol.py", line 343, in sync_request
File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\protocol.py", line 305, in serve
File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\protocol.py", line 265, in _recv
File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\channel.py", line 36, in recv
File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\stream.py", line 105, in read
EOFError: [Errno 10054] An existing connection was forcibly closed by the remote host Below is my script that I am trying: The script is placed in a folder with a bunch of mxds. #Import python modules
import os, sys, string, glob, arcpy
from arcpy import mapping
#Set local variables
mxdLst = glob.glob('*.mxd')
mxdCnt = len(mxdLst)
####
#Place script in same folder as MXDs to get 'current working directory'
####
baseF = os.getcwd()
#Print how many mxd's found
print '\n' + 'Found ' + str(mxdCnt) + ' mxds for PDF exporting...'
print 'Directory: ' + str(baseF) + '\n'
#Loop to process each mxd into a PDF
for mxds in mxdLst:
PDFr = mxds.replace('mxd', 'pdf') #Replace 'mxd' extension with 'pdf'
print 'Exporting ' + str(mxds) + ' to:' + '\n' + str(baseF) + '\\' + str(PDFr) #Print current mxd exporting and output pdf name...
inMxd = arcpy.mapping.MapDocument(mxds) #Make current mxd in loop the mapdocument
arcpy.mapping.ExportToPDF(inMxd, PDFr) #Export mapdocument to pdf
print 'Done exporting: ' + str(PDFr)
del mxds
... View more
07-20-2011
02:22 PM
|
0
|
13
|
1942
|
POST
|
What would the expression be if I wanted to label both fields but tell it not to label second field if values are the same? I went over a way how to compare two fields for matching values in a label expression over on the Cartotalk. There is another method mentioned in there, but using the StrComp function you would need to make a small change to the expression: Function FindLabel ( [F1], [F2] )
intComp = StrComp( [F1], [F2], vbTextCompare )
if intComp = -1 Then
FindLabel = [F1] & " - " & [F2]
Else
FindLabel = [F1]
End if
End Function Results: [ATTACH]7784[/ATTACH]
... View more
07-14-2011
02:19 PM
|
0
|
0
|
419
|
POST
|
...What would the expression be if I wanted to label both fields but tell it not to label second field if values are the same?... Check out this similar thread from the Cartotalk forum to compare two fields for matching records with some options for a label expression. Function FindLabel ( [F1], [F2] )
intComp = StrComp( [F1], [F2], vbTextCompare )
if intComp = -1 Then
FindLabel = [F1]
Else
FindLabel = [F1] & " - " & [F2]
End if
End Function Results: [ATTACH]7782[/ATTACH] In the expression the logic is: if they match, label only [F1], but if they do not match, label [F1] and [F2]
... View more
07-14-2011
02:07 PM
|
0
|
0
|
419
|
POST
|
After the Union, I made a new field in the Union output called 'DissolveID' and calculated it as Round(Shape_Area, 4). I then ran my Union polygons through Dissolve using 'DissolveID' as the dissolve field and my unique Id as a COUNT and the value as a SUM. I have done this a couple of times in the past, but have used a different UID which is a concatenation of the X and Y values (centroid of the polygons). To add to the methods mentioned above here are some existing forums (lots in the arch. forums): Note the method which you use to generate your centroids because in some instances overlaps occur where they should not. Spaghetti and Meatball Method (haven't tried this one yet) Sum of Overlapping Areas
... View more
06-24-2011
02:14 PM
|
1
|
0
|
1511
|
POST
|
Is there a way to clip a raster with a polygon but keep the outer portion? (ie, to create a donut?) Thanks A maybe not so quick solution... Convert the polygon to a raster with the same extent of your raster. But make the areas of the polygon equal to NoData and all other areas outside the polygon equal to 0 or some other valid integer. Then use those as the input in the extract my mask. The polygon area, which has been set to NoData will 'mask out' these portions on the output raster. I would be interested to know if there was a tool that could automatically do this (I am thinking a checkmark somewhere...) The above would fit nicely in a small model or python script so it can be ran over and over again in the future if needed.
... View more
06-20-2011
01:29 PM
|
1
|
0
|
2707
|
POST
|
Any other ideas? I'm having the same issue. Arc10, trying to label features for a specific shapefile, tried multiple fields - none will display... I've also tried to label other shapefiles in the same project - none are working. If I click on "View Unplaced Labels" they show up in red. If I "Convert labels to Annotation" nothing happens (except it turns off the label features option) So you are using the regular label engine and not the Maplex correct? This seems to suggest that other features labels and features have weighting applied that is affecting the placement of your other labels. You may have to just open the Labels tab for every layer that has labels turned on and press the Label Placement button. Toggle the 'place overlapping labels' and play with the options in the Label and Feature weight pulldown menus. If those labels are not the culprit, try turning off an annotation group if one has been built 'in-the-map'. Open that data frame's properties and go to the Annotation Groups tab.
... View more
05-20-2011
03:00 PM
|
0
|
0
|
601
|
Title | Kudos | Posted |
---|---|---|
1 | 03-20-2012 12:45 PM | |
1 | 09-08-2010 12:42 PM | |
1 | 07-27-2012 12:12 PM | |
3 | 09-03-2010 01:59 PM | |
1 | 06-24-2011 02:14 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|