POST
|
I'm using the Surface Difference tool in 3D Analyst for the first time and it is producing some unexpected results. I'm comparing the surfaces of two TINs which are identical in structure, but with different Z values. I'm using the tool to create a raster off the value differences between the two TINs, and this raster is doing something strange at the boundary edge (see attached image). Both rasters have values (see Identify image) so I do not understand why the difference raster has NoData. Anyone seen this issue before? Any ideas how to resolve it? Thanks.
... View more
07-26-2017
02:22 AM
|
0
|
0
|
598
|
POST
|
Yeah - I think this is what I'm going to have to do. I don't particularly want to create an additional dataset but I can't seem to avoid this when using the Dissolve tool.
... View more
06-03-2016
05:24 AM
|
0
|
0
|
417
|
POST
|
Hello all, I've used DDP many times and they are great, however I want to use them in a different way for a current project and I'm stumped. I have 28 individual polygon features, which I have grouped into 14 groups. I say "grouped"; I have a field called TA_GROUP which has group names. I want the DDP to index on the groups, not the individual features. When I try to create DDP with the Groups as the index attribute, I get the full 28 maps, instead of the 14 groups. The TA_GROUP field is in a text file which I've joined to the main dataset, but I don't see this being the issue. As such, I don't want to dissolve the dataset as it is used elsewhere, hence why I did the join instead of adding a field to the dataset. I also don't want to create a copy the dataset solely for this purpose as that increasesversion control and storage space issues. Does anyone have any ideas how DDP can index multiple features based on a common attribute, without fundamentally altering the dataset? Thanks.
... View more
06-03-2016
03:00 AM
|
0
|
2
|
3510
|
POST
|
Solution: import arcpy
# Reference current MXD and dataframe.
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
# Layer file symbology to be imported.
in_symbology_layer = arcpy.mapping.Layer(r"C:\LayerStyles\LayerFile.lyr")
# Layer to receive imported symbology.
all_layers = arcpy.mapping.ListLayers(mxd)
for layer in all_layers:
arcpy.ApplySymbologyFromLayer_management(layer, in_symbology_layer)
# Refreshes Table of Contents.
arcpy.RefreshTOC() Thanks to all those who contributed. DK
... View more
03-15-2016
04:16 AM
|
0
|
0
|
1067
|
POST
|
So far I have got the following code to work on a single, specified layer: import arcpy
# Reference current MXD and dataframe.
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
layers = arcpy.mapping.ListLayers(mxd)
# Layer file symbology to be imported is in.
in_symbology_layer = arcpy.mapping.Layer(r"C:\LayerStyles\LayerFile.lyr")
# Layer to receive imported symbology.
in_layer = arcpy.mapping.ListLayers(mxd, "09-03-2016 00_00_00", df)[0]
arcpy.ApplySymbologyFromLayer_management(in_layer,in_symbology_layer)
# Refreshes Table of Contents.
arcpy.RefreshTOC() ...but what I would like is to apply this code to multiple layers, e.g. layers in a Group Layer, rather than a uniquely specified layer, e.g. "09-03-2016 00_00_00". Thanks, DK
... View more
03-14-2016
10:30 AM
|
0
|
1
|
1067
|
POST
|
My apologies if my original post was unclear. The code I posted was my attempt based on other pieces of code I know work. I want to apply the symbology that is stored in a layer file to all layers I currently have open in ArcMap in a Group Layer. They are all polygon files and all have the same fields so there is no error in that regard. Thanks, DK
... View more
03-14-2016
09:51 AM
|
0
|
0
|
1067
|
POST
|
Hi, I have multiple layers in ArcMap that I want to import a symbology for from a layer file. The code I have is as follows: import arcpy
from arcpy import env
# Reference current MXD and dataframe.
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
layers = arcpy.mapping.ListLayers(mxd,"",df)
# Layer file symbology to be imported is in.
in_symbology_layer = arcpy.mapping.Layer("C:\LayerStyles\LayerFile.lyr")
# Layer to receive imported symbology.
in_layer = arcpy.mapping.ListLayers(mxd, "", df)[0]
# For loop to import symbology to all layers in current MXD.
for lyr in layers:
try:
arcpy.ApplySymbologyFromLayer_management(in_layer,in_symbology_layer)
except:
print "Failed to import symbology for: " +lyr.name
# Refreshes Table of Contents.
arcpy.RefreshTOC() The code seems to work in parts, as the output I get is: "Failed to import symbology for: Layer1 "Failed to import symbology for: Layer2 "Failed to import symbology for: Layer3..." For loops are my Achilles Heel so any assistance would be greatly appreciated! Thanks, DK
... View more
03-14-2016
08:39 AM
|
0
|
10
|
4277
|
POST
|
Thanks to both for the feedback. Can I ask why the fields are only referenced in the expression line and not in the codeblock? I'm currently teaching myself Python so I haven't covered all the theory yet! Also, as I have ~50 shapefiles to apply this code to, I've run Freddie's code in Field Calculator which worked well (I've added some extra elif's at the end to cover all possibilities. However, when I copy the successful code as a Python snippet from the Results window, amend the shapefile name and run again, I get a similar syntax issue as before. The code I'm trying to run from the Python snippet is below: arcpy.CalculateField_management("New Group Layer/09-03-2016 02_00_00","DIR","winddir(!DIR!, !V!, !U!)","PYTHON_9.3","import math /ndef winddir(DIR, V, U): /n if V > 0: /n return (180/math.pi) * math.atan(U/V) + 180 /n elif U < 0 and V < 0: /n return (180/math.pi) * math.atan(U/V) /n elif U > 0 and V < 0: /n return (180/math.pi) * math.atan(U/V) + 360 /n elif V == 0 and U > 0: /n return 270 /n elif V == 0 and U < 0: /n return 90/n elif U == 0 and V > 0: /n return 180 /n elif U == 0 and V < 0: /n return 0 /n elif U == 0 and V == 0: /n return 0") I've only changed one digit in the file name from the Python snippet (01_00_00 to 02_00_00) in the above code and I'm getting the following error: Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 3354, in CalculateField raise e ExecuteError: ERROR 000989: Python syntax error: Parsing error SyntaxError: invalid syntax (line 1) Thanks again for your assistance. DK
... View more
03-14-2016
02:19 AM
|
1
|
6
|
1481
|
POST
|
Hello all, I am trying to convert a nested IF statement from Excel into Python via the Field Calculator in ArcMap. The data is wind data which has two fields: U and V; and the calculation is to be entered in the DIR field. These are vectors can be applied with triganometry to create wind direction in degrees. In Excel, the DIR field has the following formula: =IF(D2>0,((180/PI())*ATAN(C2/D2)+180),IF(AND(C2<0,D2<0),((180/PI())*ATAN(C2/D2)),IF(AND(C2>0,D2<0),((180/PI())*ATAN(C2/D2)+360),IF(AND(D2=0,C2>0),270,IF(AND(D2=0,C2<0),90,0))))) ...where column C is the U field and column D is the V field. I've been playing all day with this and so far, I have the following: codeblock: def winddir(DIR):
if !V! > 0:
!DIR! = ((180/math.pi)*math.atan(!U!/!V!)+180)
elif !U! < 0 and !V! < 0:
!DIR! = ((180/math.pi)*math.atan(!U!/!V!))
elif !U! > 0 and V < 0:
!DIR! = ((180/math.pi)*math.atan(!U!/!V!)+360)
elif !V! == 0 and !U! > 0:
!DIR! = 270
elif !V! == 0 and !U! < 0:
!DIR! = 90 DIR = winddir(DIR) I keep getting the generic error: ERROR 000989: Python syntax error: Parsing error SyntaxError: invalid syntax (line 2) I'm really pulling my hair out with this as I've tried tweaking the syntax but I cannot resolve it. Any assistance would be greatly appreciated. Thanks, DK
... View more
03-11-2016
07:00 AM
|
3
|
11
|
7317
|
POST
|
Hi, I don't think that's the answer to my particular problem. My variable is a user-defined string which I want to insert to the beginning of the grid file name. I've attached a diagram to try to illustrate better (the only input which is not shown is the input polygon shapefile). When I run this I get a generic Error 9999 model failure. Since my original post I have changed Location to LOC and this has sorted out the number of characters issue, so I must be missing something as the model was treating the entire %LOCATION%_sm_10k string as the file name, which is obviously over 13 characters. I'd rather not change to a TIF as this needs to be in grid format, and now that it runs the number of characters isn't an issue. Thanks for all your help thus far.
... View more
11-18-2015
03:42 AM
|
0
|
0
|
626
|
POST
|
Hi folks, I'm playing with a ModelBuilder tool that I want to use in-line variables to specify the location, e.g. %Location%_sm_10k is my desired output file name. However as this is a grid, it cannot be more than 13 characters. When I run the tool, I'm getting the error that the file name is more than 13 characters. However when I enter 'drum' as the variable, that would make 11 characters. Even if I enter 'd' as the location, I get the same error (#000161), so I can only assume it is picking up %Location% as part of the file name? I'm a bit lost! Any help would be greatly appreciated!
... View more
11-17-2015
09:29 AM
|
0
|
4
|
3777
|
POST
|
A couple things, VBScript does not allow you to explicitly declare any data types; all variables are implicitly Variant. Statements like Dim x as String should be removed or simplified to Dim x. If you want to execute only one statement when a condition is true, you can write the code on one line, otherwise each statement needs to be on a new line ie If....Then statement elseif....Then statement else statement end if
Dim temp
If [OBJECTID] =1 Then
temp = "Very Destructive"
elseif [OBJECTID] = 2 Then
temp = "Destructive"
elseif [OBJECTID] =3 Then
temp = "Damaging"
else temp ="Nothing"
end if
Excellent Chris, this works perfectly. Thanks very much. DK P.S. Any idea why elseif is one work but end if is two?
... View more
03-12-2013
08:16 PM
|
0
|
0
|
1177
|
POST
|
Darrock, Did you also make the other changes I suggested not just the quotes? Regards Anthony P.S. not sure what version of arcmap your are using but I have just found this article: http://support.esri.com/en/knowledgebase/techarticles/detail/25207 Yeah I've tried various combinations suggested. I'm using v10.1 SP1; I'll attempt something in Python.
... View more
03-11-2013
04:08 PM
|
0
|
0
|
1177
|
POST
|
What is your data type for the Workspace parameter in ModelBuilder? Did you set it to Workspace? You can set it to Feature Dataset from there. I didn't know you could/had to set data types. Thanks! DK
... View more
03-11-2013
04:05 PM
|
0
|
0
|
603
|
POST
|
Try using double speech marks around your text, and a space between your end and if on your last line, also the last else if only needs to be an else statement, plus the objectid field is numeric so you don't need the values in speech marks. DIM temp as String IF [OBJECTID] = 1 THEN temp = "Very Destructive" ELSEIF [OBJECTID] = 2 THEN temp = "Destructive" ELSE [OBJECTID] = 3 THEN temp = "Damaging" END IF I had tried various double quote and single quote methods but still receiving the same error. N.B. This doesn't have to be written in VB; if anyone knows how to write this in Python then please comment. Thanks, DK
... View more
03-11-2013
03:24 PM
|
0
|
0
|
1177
|
Title | Kudos | Posted |
---|---|---|
3 | 03-11-2016 07:00 AM | |
1 | 03-14-2016 02:19 AM |
Online Status |
Offline
|
Date Last Visited |
10-24-2023
10:37 AM
|