|
POST
|
Heh, I do have a t in there . I'll see tomorrow what I get when I take that out. I think it's about time to give this a rest for tonight.
... View more
05-14-2015
10:59 PM
|
0
|
0
|
2487
|
|
POST
|
I haven't had much of an opportunity to test out the suggestions for pulling out the mxd name, but I have a script that runs all the way up to the MapToKML portion.
# Name: Map To KML
# Description: This script is used within a model to export the map to a KMZ file for distribution.
# Author: Coy Potts
# Parts: (1) Apply Symbology Layer File, (2) Save mxd, (3) MapToKML tool, (4) Apply Symbology Layer File
# Import system modules
import arcpy
from arcpy import env
import arcpy.mapping as map
# Part 1:
# Apply Symbology Layer File
# Set current workspace
env.workspace = r'\\company.local\dfs\dept_name\1)folder\folder\layerFiles folder'
# Set layer to apply symbology to
inputLayer = r'\\company.local\dfs\dept_name\1)folder\folder\folder\layerFile.lyr'
# Set layer that output symbology will be based on
symbologyLayer = r'DataFrame\FeatureClass'
# Apply the symbology from the symbology layer to the input layer
arcpy.ApplySymbologyFromLayer_management (inputLayer, symbologyLayer)
# Part 2:
# Save the map
# Set the map document to the current map
mxd = map.MapDocument("CURRENT")
# Save the map
mxd.save()
# Part 3:
# Map to KML tool
# Set current workspace
env.workspace = '%saveKML%'
# Set local MapToKML tool variables
inputMap = mxd
outputKML = '%outputKML%' + '.kmz'
# Execute MapToKML
arcpy.MapToKML_converstion(inputMap, outputKML)
I went ahead and set the script up to grab two variables that are within a model builder model. The saveKML is the file path to be input by the user, and the outputKML is the name of the KML file, also input by the user. Originally I set this script up in NotePad, saved as a .txt file, loaded into the ArcMap python window, saved as a .py script. From there I loaded it into a script inside my toolbox and then inserted that script within the model with the two variables. When doing it this way I got an error that said syntax error on line 2, but I couldn't figure out why. So I went and manually entered the entire script into the ArcMap python window piece by piece, and it was all working up to the point executing the MapToKML tool. Once I pressed enter after that line, it kicked back the following error: "Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\conversion.py", line 2278, in MapToKML raise e RuntimeError: Object: Error in executing tool" Everything up to that point ran just fine.
... View more
05-14-2015
10:14 PM
|
0
|
7
|
2487
|
|
POST
|
Thank you Jeff, I will note that for future reference.
... View more
05-14-2015
02:34 PM
|
0
|
0
|
3211
|
|
POST
|
Okay, that is also helpful. I'll go a little deeper into explanation. A sample file path is listed below (renaming the actual folder names for proprietary purposes): \\company.local\dfs\dept_name\gis_folder\projects\region\region-state-name-carrier\deliverables That is the full file path that I would be working with. We name the maps identically to the "region-state-name-carrier" naming convention (e.g. "NC-IL-MYHOUSE-VZW"). The mxd is saved at this stage of the file path. Once we create a KML output from the mxd, it is saved in the deliverables stage of the file path. I thought that since all file paths are identical with the exception of the "region\region-state-name-carrier" portion, I could just make static variables for "\\company.local\dfs\dept_name\gis_folder\projects\" and "\deliverables", and use the map name as the dynamic variable that will change from project to project. Essentially I need to take the map name and convert it to a string. I would take that string and strip out only the first two characters to uses as my "region", and then I would use the whole string as my "region-state-name-carrier" portion. I'll list the potential variables below for a better understanding. mapname = mxd - I haven't figured out how to do this yet. This is where I want to turn my map name into a string. region = mapname[:2] - I haven't figured this part out either, but through google I found that this is one way to strip parts of a string apart, I but it wasn't working when tried. filePath1 = r"\\company.local\dfs\dept_name\gis_folder\projects\" filePath2 = r"\deliverables" arcpy.env.workspace = filePath1 + region + mapname + filePath2 if that doesn't work I am brainstorming and thinking this might work for the workspace: workspace = filePath1 + region + mapname + filePath2 arcpy.env.workspace = workspace I'm only thinking of this because the arcpy.env.workspace function might not like concatenating the multiple variables...but I really don't know :/. Thanks for your input so far!
... View more
05-14-2015
02:33 PM
|
0
|
5
|
3211
|
|
POST
|
An additional question...what IDLE do you use to get the numbered structure next to each line of your code? I have been using the python window within ArcMap just because that's all I know to use, but I don't really like it all that much. And thank you so much for the response!
... View more
05-14-2015
01:25 PM
|
0
|
2
|
3211
|
|
POST
|
Okay, I sort of understand that. And yes, I was playing with other variations and I was getting the error saying that I couldn't mix a string and a map document, but I couldn't figure out how to translate my map document into a string like ymou do in your exaple. I'm very green when it comes to Python scripting, so I'm not sure how to correctly answer your question regarding the workspace vs. output. The tool needs to have a workspace in order to know where to save the KML, correct? An alternative, and I think it's what you are showing above, is that you simply create the variables as you show, and then set outKML to equal the concatenation of those variables. So instead of saying save this output in this workspace, you're saying that the output KML equals the entire file path. Am I understanding that correctly? In regards to the mxdname = "mystring", can you say mxdname = mxd? Or would that still have it be referencing a map document instead of turning it into a string. I'm just a little unclear on how to take my map document's name and add it into the whole folder path.
... View more
05-14-2015
01:19 PM
|
0
|
0
|
3211
|
|
POST
|
I am trying to create a script that will apply a symbology layer to the current map, save the map, export the map to KML, and then reapply the original symbology from a layer file. Apply symbology from layer file: # Import system modules import arcpy from arcpy import env # Set the current workspace env.workspace = "file path where layer files are saved" # Set layer to apply symbology to inputLayer = "layer file name" # Set layer that output symbology will be based on symbologyLayer = "feature class within map" # Apply the symbology from the symbology layer to the input layer arcpy.ApplySymbologyFromLayer_management (inputLayer, symbologyLayer) This part works fine. Save the map: # Set up map variable import arcpy.mapping as map # Set map variable to current mxd mxd = map.MapDocument("CURRENT") # Save the map document mxd.save() This part works fine. Map to KML: # Set environment settings arcpy.env.workspace = "haven't figured this part out yet" # Set Local Variables dataFrame = 'Layers' # Sets the KMZ name to be equal to the mxd outKML = mxd+'.kmz' #Execute MapToKML arcpy.MapToKML_conversion(mxd, dataFrame, outKML) This is the part that I'm having trouble with. I'm not entirely sure how to correctly construct the Map to KML portion. This script will be run on many different maps and the workspace for each map will be identical to each other with the exception of the map name. I tried to set the workspace to the following path, with no luck: arcpy.env.workspace = "folder1\folder2\folder3\" + mxd + "\folder4\folder5" But this results in this error "Parsing error SyntaxError: unexpected character after line continuation character (line 1) Apply symbology from layer file: Simply a repeat of the previous iteration of the tool with a different layer file.
... View more
05-14-2015
12:00 PM
|
0
|
34
|
14132
|
|
POST
|
I haven't done it in a few months, but before I remember publishing a service, and when I look at it in the map through ArcGIS Online, the group layers were not maintained. For instance, if I had multiple copies of the same feature class contained within multiple group layers, they will all show up together within the ArcGIS Online view. So if I have 5 copies of a feature class (titled "FeatureClass") within 5 separate group layers, I would see the example shown below: FeatureClass FeatureClass FeatureClass FeatureClass FeatureClass And so on with the other feature classes in the map.
... View more
05-06-2015
01:22 PM
|
0
|
1
|
2798
|
|
POST
|
I haven't had the opportunity to test this out just yet, but I do have a couple other quick questions. 1) It shouldn't matter if field1 isn't involved in the concatenation, right? Just so long as I add all of the fields within the parentheses in both sections? 2) I also don't think it would be an issue adding characters in the return statement, right? (e.g. field1 + "-" + field2 + "-" + field3 etc... Thanks for the information. I'll post back whenever I have the opportunity to try this out.
... View more
03-23-2015
11:22 AM
|
2
|
4
|
4850
|
|
POST
|
Hello, I am trying to create a python IF/THEN statement within a model that runs the field calculator tool. Essentially I want it to check to make sure if a cell has data entered (IS NOT NULL), and if so, calculate a concatenation of 4 other fields. Sample of what I want: IF field1 <> NULL THEN field2 = concatenation expression ELSE field1 still = NULL My python skills are very rudimentary, and I have only tested off of what I've found through googling python IF/THEN statements. I don't fully understand how to take their samples and make them work with what I need to accomplish. One of the samples that I've tried to mimic is pasted below: Expression: Reclass(!WELL_YIELD!) Expression Type: PYTHON_9.3 Code Block: def Reclass(WellYield): if (WellYield >= 0 and WellYield <= 10): return 1 elif (WellYield > 10 and WellYield <= 20): return 2 elif (WellYield > 20 and WellYield <= 30): return 3 elif (WellYield > 30): return 4
... View more
03-23-2015
10:09 AM
|
7
|
6
|
11922
|
|
POST
|
As a company, they don't know GIS, thus they don't know the options available. I think they were a little hesitant to drop the investment of three licenses for ArcGIS Standard and the ArcGIS Server Package, so we limited the "extras" that we proposed. For myself, this is my first post-grad job so I am pretty new to the GIS workforce, and definitely new to the telecommunications world. I am still learning new facets of GIS that pertain to telecommunications. When I first started my job here I enabled the transition from a sub-par in-house GIS tool that was never fully developed and virtually only allowed you to draw features that had no attribute values whatsoever to the ArcGIS Platform. I designed a template map and SDE geodatabase structure comprising of various feature classes, domain connections, and relationship classes to use for all of our work, which is still changing frequently as we throw ideas back and forth and test different methodologies. The problem that we have been having is that one particular region wants a fiber matrix (distance from each node point back to the hub) for each project. We have been doing this manually by simply selecting all segments to a node, copy selected from the table, and paste them into Excel to sum the lengths. This works, but as you can imagine, it is more time consuming than we'd like for it to be. I've researched the various Route tools in the Linear Referencing Tools toolbox, but I don't think any of them do what I need. The methods explained above do seem to be on the right track to what we need, though. I am going to research the geometric networks link you gave above. If you have any other tidbits of knowledge regarding the telecommunications realm, feel free to share them. I'm always open to new knowledge .
... View more
02-05-2015
08:39 AM
|
0
|
0
|
1239
|
|
POST
|
The cost model I refer to is an Excel workbook that takes overall footage values and runs them through various calculations to account for fiber slack and whatnot. The cost model encompasses 188 lines of key metric input data (output from ArcMap), and has about 10 tabs, so I can't even begin to explain all the calculations that are applied . Also, I just checked and we don't have the Spatial Analyst extension .
... View more
02-05-2015
07:39 AM
|
0
|
2
|
1239
|
|
POST
|
I didn't take the time to double check the data that I sent out, but when we create the data here in-house, we snap everything. My company has a reach across the entire United States, and there are certain regions who like to go at it in their own way and have contractors do the GIS work. They then send a KMZ back for us to convert to shapefile and then load into our SDE so we have a record of the data, but judging by the quality of the data, I wouldn't be surprised if they created the data in Google Earth to begin with. There are a lot of instances where there are spikes, and nodes are never snapped to the lines. I simply chose a small enough dataset to have test runs on, but I should have checked it better before attaching it. Hitting on the topic of the 1.2% discrepancy, I would only assume that that percentage could potentially grow the longer the line segment was, right? Either way, a potential of 1.2% over a 50 mile fiber network could be in the ballpark of 3,000'+, which could sway our cost model quite a bit. Agreeably, this method would work in certain instances, but we're trying to find a standard method for all networks if possible.
... View more
02-05-2015
07:34 AM
|
0
|
0
|
1441
|
|
POST
|
This does seem to do what I want, but as you say, I'm not sure if the pixelation will throw off the exact measurements. Since these values are thrown into a cost model, these values will need to be fairly accurate. In the example above, I doubt this method would create much of a concern, but I do encounter networks with upwards of 50-60 miles of fiber. If there is any sort of skewing from the pixelation, I'm sure it would be a problem with that much fiber distance. Thanks so much for the proposed method, though!
... View more
02-04-2015
02:30 PM
|
1
|
4
|
1239
|
|
POST
|
Yes, this looks pretty much like what I'm wanting. The fiber paths chosen are based on existing aerial fiber, so there is no way to alter that . Can you post a screenshot of the parameters that you used in the tool, please?
... View more
02-04-2015
02:27 PM
|
0
|
1
|
1441
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-16-2015 11:55 AM | |
| 1 | 02-04-2015 02:30 PM | |
| 2 | 03-23-2015 11:22 AM | |
| 7 | 03-23-2015 10:09 AM | |
| 3 | 03-23-2016 12:54 PM |
| Online Status |
Offline
|
| Date Last Visited |
01-28-2026
11:51 AM
|