|
POST
|
Hello, I have been trying to solve this problem and contacting to Esri Costumer Service in that issue. They told me tool works fine, they do not have any problem. I have been very frustrated I tried other people's computer at the office and the results were as I explained above and do not understand that how it does work fine for ESRI folks . I am using 10.2.1 in office and I tried the script in 10.1 ( in home computer) and some reason the results in 10.1 were correct. It turned out the problem stems from ArcGIS version and have no idea want is going on... Can any one try the script for me if they have ArcGIS 10.2 version or later ? Below I attached a rar it has the sample data. 1. Open LayerToKML rar in C:\Temp 2. Open the lyr file in the arcmap and make sure it is not broken, if so open the shp and save the shp as layer (overwrite the layername). 3. Then by using Python IDLE ( under All programs-ARCGIS) open the test script and run module It will run the inside Outputs and could you please send those to me with a rar file. I would greatly appreciate that.
... View more
09-10-2014
11:00 PM
|
0
|
7
|
1925
|
|
POST
|
import os Path=r'C.......' list=([m for m in os.listdir(Path) if m.endswith('.lyr') and os.path.isfile(os.path.join(Path, m))])
... View more
09-09-2014
11:17 PM
|
2
|
0
|
1387
|
|
POST
|
I had a similar problem. I had a style file and I could not use it with python. To make Legend appear you need to include a empty legend on the mxd. Therefore, no legend items comes up. To apply style, I could not find any tool but I used ApplySymbologyFromLayer. What you need to do is you need to arrange your sembology layer as you want and then you need to indicate label expression (Field name that your sembology need to use) the line below (lyr1.labelClasses[0].expression = LabelExpression) Here a script that I used to make a tool. After getting label name as text you need to get it to be brackets [] import arcpy,os symbologyLayer=arcpy.GetParameterAsText(2) LabelExpression=arcpy.GetParameterAsText(1) try: for idx, item in enumerate(LabelExpression.split()): if 'VISIBLE'==item: num=idx arcpy.AddWarning(LabelExpression.split()[idx-1]) LabelExpression="["+LabelExpression.split()[num-1]+"]" except: arcpy.AddError("Choose only one field name for label expession") K_shp=arcpy.GetParameterAsText(0) add_legend= arcpy.GetParameterAsText(3) LayerName=os.path.split(K_shp)[1][:-4]+"_lyr" mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] arcpy.MakeFeatureLayer_management(K_shp,LayerName) lyr1= arcpy.mapping.Layer(LayerName) arcpy.ApplySymbologyFromLayer_management (lyr1, symbologyLayer) lyr1.labelClasses[0].expression = LabelExpression lyr1.showLabels = True arcpy.RefreshActiveView() arcpy.mapping.AddLayer(df, lyr1, "BOTTOM") if add_legend=='true': #styleItem = arcpy.mapping.ListStyleItems("USER_STYLE", "Legend Items", "NewDefaultLegendStyle")[0] legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT", "Legend")[0] #legend.updateItem(lyr1, styleItem) legend.autoAdd = True del mxd
... View more
09-04-2014
11:12 PM
|
0
|
0
|
634
|
|
POST
|
Hi I think problem is related to your "adr" path , I tried one of my sde connection and it works. Try to copy your path location from catalog location after browsing your path.
... View more
09-03-2014
06:03 AM
|
0
|
0
|
488
|
|
POST
|
Actually, I think the question is about adding legend by using model builder to automate the process instead of doing it manually.. not sure how to add legend in model builder but you can create legend items after adding symbology in arcpy.. If you have any idea about how to add legend with model or script, I can also utilize from that..
... View more
09-01-2014
04:29 AM
|
0
|
0
|
1247
|
|
POST
|
Hi to all, In case, if someone have similar problem, I would like to let how I solved the problem related to the problem above. Unfortunately I could not find any solution on how to extract style directly in arcpy. But if you create a layer with your style file and use that layer with apply ApplySymbologyFromLayer_management, that will work too..
... View more
09-01-2014
02:51 AM
|
0
|
0
|
756
|
|
POST
|
Ok I created tool and here how you do it. This is the tool view below Here the script for it import arcpy,os symbologyLayer=arcpy.GetParameterAsText(2) LabelExpression=arcpy.GetParameterAsText(1) try: for idx, item in enumerate(LabelExpression.split()): if 'VISIBLE'==item: num=idx arcpy.AddWarning(LabelExpression.split()[idx-1]) LabelExpression="["+LabelExpression.split()[num-1]+"]" except: arcpy.AddError("Choose only one field name for label expession") K_shp=arcpy.GetParameterAsText(0) add_legend= arcpy.GetParameterAsText(3) LayerName=os.path.split(K_shp)[1][:-4]+"_lyr" mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] arcpy.MakeFeatureLayer_management(K_shp,LayerName) lyr1= arcpy.mapping.Layer(LayerName) arcpy.ApplySymbologyFromLayer_management (lyr1, symbologyLayer) lyr1.labelClasses[0].expression = LabelExpression lyr1.showLabels = True arcpy.RefreshActiveView() arcpy.mapping.AddLayer(df, lyr1, "BOTTOM") if add_legend=='true': #styleItem = arcpy.mapping.ListStyleItems("USER_STYLE", "Legend Items", "NewDefaultLegendStyle")[0] legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT", "Legend")[0] #legend.updateItem(lyr1, styleItem) legend.autoAdd = True del mxd Above is the tool parameters you need to arrange.. Only thing that I could not figure out how to add legend itself with arcpy, so you need to manully create and empty legend before you run the script.
... View more
09-01-2014
02:09 AM
|
0
|
0
|
1247
|
|
POST
|
If I understood correctly, you want to add legend with model builder.Apply Symbology From Layer extracts Symbology from a layer ( which is a layer you prepared before) to another layer which does not have symbology. As far as I know , there is no tool to include legend in model builder but you could create a script "to add legend" in python and make a tool with that script. Then you can add it to your model. Here same code you can use to create layer from shp and add sybology. import arcpy symbologyLayer=r"C:\.....\sembology.lyr" # if you want to assign same layer format all the time this can be a path to your symbology LabelExpression="[Fieldyouwantolabelwith]" #if you want label you can make it parameter if not you do not have to use this label parts K_shp= arcpy.GetParameterAsText(0) ### your shp file you want to assign symbology ## those above will be your parameters mxd = arcpy.mapping.MapDocument(r"C:\......\my.mxd") #or mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] arcpy.MakeFeatureLayer_management(K_shp,"Layername") lyr1= arcpy.mapping.Layer("Layername") arcpy.ApplySymbologyFromLayer_management (lyr1, symbologyLayer) lyr1.labelClasses[0].expression = LabelExpression lyr1.showLabels = True legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT", "Legend")[0] legend.autoAdd = True arcpy.RefreshActiveView() arcpy.mapping.AddLayer(df, lyr1, "BOTTOM")
... View more
09-01-2014
12:35 AM
|
0
|
1
|
1247
|
|
POST
|
Hello, We are using .style file in symbology of points and I would like to automate this process in python but I cannot find any example how to assign .style file with arcpy. Only thing I could find close to what I am looking for is ApplySymbologyFromLayer_management but I think it uses .lyr extensions to obtain the symbols. I would greatly appreciate if anyone could give me an idea Thank you so much
... View more
08-21-2014
06:51 AM
|
0
|
2
|
3423
|
|
POST
|
Hi, I can also suggest Programming ArcGIS 10.1 with Python Cook Book from Eric Pimpler
... View more
08-20-2014
12:42 AM
|
1
|
0
|
2600
|
|
POST
|
You may want to check your match option in your spatial join maybe, the option you select is not giving any result.
... View more
08-19-2014
12:27 AM
|
0
|
0
|
467
|
|
POST
|
Hello, I would like to add a comment here, I think it is true that ArcGIS will convert automatically to the coordinates if the coordinate system is not created with custom coordinates transformation. For instance we work with projected coordinates of wgs84 and we also have ED50 with custom parameters. If I convert same point to kmz in both coordinates, they will have more than 100m difference on the google earth map . For our case we always need to transform data from any projected ED50 to other arcgis defined coordinates before converting to kmz.
... View more
08-18-2014
11:35 PM
|
0
|
0
|
1027
|
|
POST
|
Hello, Thanks for your advice, unfortunately, this was not the problem, I saved file with "RELATIVE" but still second runs appears in arctic ocean.. I cannot figure out what is happening., seems like something related to LayertoKML tool
... View more
08-18-2014
10:44 PM
|
0
|
0
|
1925
|
|
POST
|
Hello, Thanks for your interest on my post, I am still trying to solve this problem but no luck, I attached a simple script and sample data for you to try. You need to change the path of the data before running. I also add results that I obtained. The first results kmz called testdata0 is in correct location but others appears on arctic ocean.. Not sure what is going on.. Thank you so much.. Naime
... View more
08-18-2014
01:20 AM
|
0
|
2
|
1925
|
|
POST
|
Hello, I am trying to convert some layers, to kml in python IDLE. I used arcpy.LayerToKML_conversion . In ArcMap it works fine and you can convert each layer to kml without any problem.However when I use it in python script, only first runing result of tool creates the correct location in kml file and all other layers run inside "for loop" appear in 0 N and 0 S Geographic Coordinates. It is so weird, I checked the layers (.lyr files) in ArcMap,they are all in correct location. If I close IDLE and only run one file it works, without closing the idle second attempt of running same script with same data will give in 90° N and 180° EGeographic Coordinates. I would greatly appreciate if someone tries this tool in python and let me know what they get. Thank you so much, Naime
... View more
08-17-2014
10:53 PM
|
0
|
15
|
7617
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 04-15-2015 05:37 AM | |
| 1 | 02-12-2015 11:22 PM | |
| 1 | 10-05-2013 10:38 AM | |
| 2 | 09-09-2014 11:17 PM | |
| 1 | 08-20-2014 12:42 AM |
| Online Status |
Offline
|
| Date Last Visited |
12-28-2022
12:26 PM
|