POST
|
I ended up using arcpy.da.Walk to loop through the geodatabase but ListFeatureClasses would have worked also. I was unble to figure out how to programmatically put the files names into a field that resided within a feature dataset but the feature classes that were not inside a geodatabase dataset were populated using the following toolbox: AddFileName toolbox
... View more
11-16-2017
08:40 AM
|
1
|
0
|
1326
|
POST
|
I have a file geodatabase with over 200 feature classes. I want to extract all the feature classes (including those in feature datasets) that are polygons and save/append them to a separate shapefile. Also, is there anyway to put the filename of the each of the feature classes in a field name called "Label"? For instance, if one of the files that is getting copied to the polygon shapefile is called "FredsPlace", when that gets appended to the shapefile, its label field is filled in with its name "FredsPlace". Is there a tool in ArcGIS 10.5 that already does this or am I going to have to write a python script to do this? If so, what approach would you recommend I take to accomplish this. Many thanks in advance.
... View more
11-13-2017
04:42 PM
|
0
|
4
|
2321
|
POST
|
Well that was just too awesome for words. Thank you a gajillion times.
... View more
02-02-2015
01:43 PM
|
0
|
0
|
1106
|
POST
|
How would I go about modifying script to put the file name in a separate field? I had a script that did this before merging but I keep getting [Errno 10054] An existing connection was forcibly closed by the remote host when run. I was hoping I could accomplish by modifying your script. Many thanks,
... View more
02-02-2015
11:13 AM
|
0
|
2
|
1106
|
POST
|
This worked great once I figured out I have to create the FGDB. LOL.
... View more
01-30-2015
07:15 PM
|
0
|
1
|
1106
|
POST
|
I have about 1000 shapefiles that I will be merging into one large shapefile. I am not interested in the attribute information, only the location. I was thinking I should try to condense the files before merging by stripping out all the fields except the required ones and them merging them all together, All the files should be polygons but a few non polygons may creep in so a check for file type would probably be nice. (I think I can code this requirement on my own). Right now all the files are spread out in multiple directories but I have the file names and directory path listed in a txt file. I would want to copy all these files to a single location, delete the unnecessary fields and then merge. I want to do this all at once instead of each file individually. I know how to code this individually but am unsure how to accomplish this with such a large volume of data. Ideas anyone? ver. ArcGIS 10.2.1 Advanced
... View more
01-28-2015
02:44 PM
|
0
|
10
|
5799
|
POST
|
import arcpy getShapeFile = arcpy.GetParameterAsText(0) arcpy.Buffer_analysis(getShapeFile, bufferArea_shp, "500 Meters", "FULL", "ROUND", "ALL", "") I am trying to use Tkinter to create an interface that will mimic the above python script. I do not know how to get the shapefile via navigating to it. I know I can use filename = askopenfilename() to grab a file but it is not really getting the shapefile. (may need to specify getting only file that ends in shp?) I guess what I am really trying to figure out is how can I use an interface outside of ArcMap (i.e. a standalone script) to get the parameters I need? A pointer to some sample scripts would be helpful as well. Thanks
... View more
01-02-2015
04:09 PM
|
0
|
1
|
4108
|
POST
|
Not sure I have a good answer for that other than it was requested and I thought it would be a good learning experience. I do like the idea of compartmentalizing sections of the script and calling them as needed. It would make testing the script faster when the code in question is towards the end of the process. Dan Patterson gave me some great suggestions. Now I just have to hunt down some sample scripts to help guide me along.
... View more
12-18-2014
03:03 PM
|
1
|
1
|
97
|
POST
|
I do have a template which I rename and run the script from. I realize that the geoprocessing commands such as buffering can be run as a stand alone but am under the impression that some of the actions performed with arcpy.mapping cannot (such as manipulating the layer properties in the TOC to export as pdf files, moving elements around in layout based upon map extents, turning on and off layer visibilities, etc.) I do not have the authority to post the script online but I am think I can send to one or people to review and let me know the basic scope of work required to make this a stand alone (or even a more 'tight' script) which is why in my original post I asked if there was some place I could go (or someone who was willing to help) to get this assessment done. Unfortunately the cost of getting the assessment done is on me and I am a lowly, underpaid employee (as I am sure most of us are these days.)
... View more
12-15-2014
10:27 AM
|
0
|
1
|
468
|
POST
|
The script is very lengthy, over 700 lines of code and performs several analyses using several modules including arcpy, zipfile, win32com.client, glob, shutil, os.path, and OrderedDict from collections . It will be run on computers that have ArcGIS 10.2.1 advanced licenses. I pared it down to just the commands I use and a few of the commands in the more complex functions (see below). Right now the script runs in immediate mode but I would like to be able to run it as a stand-alone script. My main concerns are the commands that manipulate the TOC, legend properties, and those exporting these as pdf files.Note: Incomplete code. This is just a sampling of the commands that may not run as stand-alone. #Arcpy Commmands that are used in script arcpy.Buffer_analysis arcpy.CopyRows_management arcpy.CreateFileGDB_management arcpy.da.SearchCursor append(row[0]) arcpy.DeleteRows_management arcpy.Delete_managementarcpy.Delete_management arcpy.Describe(CompanySite).shapeType arcpy.Dissolve_management arcpy.Frequency_analysis arcpy.GetParameterAsText(0) arcpy.ListFields arcpy.MakeFeatureLayer_management arcpy.MakeTableView_management arcpy.mapping.ListLayers(mxd, "Company Locations")[0] Lyr.visible = True arcpy.mapping.ListLayoutElements scaleBar.elementPositionX arcpy.Polygon(arcpy.Array([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]), df.spatialReference) arcpy.RefreshActiveView() arcpy.SelectLayerByLocation_management arcpy.Sort_management arcpy.Statistics_analysis arcpy.TableToDBASE_conversion arcpy.TabulateIntersection_analysis arcpy.env.overwriteOutput arcpy.mapping.ExportToPDF arcpy.mapping.Layer arcpy.mapping.ListLayers arcpy.mapping.RemoveLayer(df, lyr) int(arcpy.GetCount_management) # Setting up group layer and adding shapefiles to it. Setting order, renaming shapefiles, and visibility in # TOC also happens below to export series of pdf maps arcpy.mapping.Layer(CompanySite) CompanySite_lyr.name = "Company Location" arcpy.mapping.UpdateLayer(df,CompanySite_lyr, sourceLayer) groupLayer = arcpy.mapping.Layer groupLayer.name = "Company Locations" arcpy.mapping.AddLayer arcpy.mapping.AddLayerToGroup df.extent df.scale title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "MAPTITLE")[0] title.text = CompanySite + "\n" + mapFile mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] # Other non arcpy commands used in script os.path.splitext while os.path.exists shutil.rmtree os.makedirs # this is run in a function after buffer analysis results run_excel_macros # opens dbf output in excel and formats excel files to import into word document. xlApp = win32com.client.DispatchEx('Excel.Application') xlsPath = os.path.expanduser wb = xlApp.Workbooks.Open(Filename=xlsPath) wb.Application.DisplayAlerts = False xlApp.Run wb.Close xlApp.Quit() xlApp = None zipfile.ZipFile("D:\\Templates\\wordTemplate.docx") report = zipfile.ZipFile(myDir + "\\Report.docx", "a") # This section takes the variables derived from analyses and modified text based on results and # replaces it with variables imbedded in Word template: Commands used to do this are as follows: with open(template.extract("word/document.xml", myDir + "\\")) as tempXmlFile: tempXml = tempXmlFile.read() for key in replaceText.keys(): tempXml = tempXml.replace(str(key), str(replaceText.get(key))) with open(myDir + "\\temp.xml", "w+") as tempXmlFile: tempXmlFile.write(tempXml) for file in template.filelist: if not file.filename == "word/document.xml": report.writestr(file.filename, template.read(file)) report.write(rmyDir + "\\temp.xml", "word/document.xml") # Runs word macro to format Word document and import excel tables word = win32com.client.Dispatch('Word.Application') doc = word.Documents.Open(myDir + "\\Report.docx") word.Run("formattingMacros") Any and all guidance greatly appreciated.
... View more
12-11-2014
10:48 AM
|
0
|
7
|
468
|
POST
|
I would like to rewrite a script that is executed in ArcMap as a standalone script. I was told it cannot be done as some of the commands are only available in ArcMap. I am fairly new to both languages and am at a loss as to where to go from here. I was hoping there was a place or person who does this kind of thing for a very nominal fee (I am on a very tight budget-my own personal expense, not a company's). I would not need it to be rewritten but pointers would help.I would like to send them the script and have them assess the effort and possibly give me a few pointers to get me going in the right direction.I am sorry if this is not the right forum. I just don't know where else to get the help. To facilitate this as a discussion, perhaps the old python/GIS gurus could let us newbies know of the different forums out there and the purposes of each. Maybe there is a place where seasoned programmers are available to offer this kind of assistance. Thanks in advance.
... View more
12-10-2014
08:34 PM
|
0
|
11
|
2939
|
Title | Kudos | Posted |
---|---|---|
1 | 11-16-2017 08:40 AM | |
1 | 12-18-2014 03:03 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|