POST
|
I have a checkbox control as part of a dockable window in VB .net that turns a particular layer's visibility on and off in ArcMap. The initial state is set to "unchecked". But, if I load the tool into ArcMap and use it when that layer is already visible, the checkbox works in reverse (checked when the layer is off and unchecked when the layer is on). Is there any way I can check the visibility of the layer when the tool is first loaded and then set the state of the checkbox? I tried putting some code in Public Sub New() function for my dockable window, but this crashed ArcMap. Here is what I had (with 3 dots representing other code). My checkbox is named chkBasemap. In this simple example, I just assume the basemap layer I want to toggle the visibility of is always the second layer. Public Class DockWinClimateTools Public Sub New(ByVal hook As Object) ' This call is required by the Windows Form Designer. InitializeComponent() AddItems() CheckStates() Me.Hook = hook End Sub Public Sub CheckStates() Dim pMxDoc As IMxDocument = My.ArcMap.Application.Document Dim pMap As IMap = pMxDoc.FocusMap Dim baseLayer As ILayer = pMap.Layer(1) If baseLayer.Visible Then chkBasemap.Checked = True Else chkBasemap.Checked = False End If End Sub . . . End Class
... View more
06-10-2015
02:25 PM
|
0
|
0
|
2476
|
POST
|
Too bad this is a bug! I am updating several scripts from 9.3 that export metadata to an xml file and then copy the geoprocessing history to a log file. So, I am trying to export the metadata to a format that also exports the geoprocessing history, but I have yet to find an output format that retains this information. Any suggestions?
... View more
03-12-2014
07:55 AM
|
0
|
0
|
941
|
POST
|
Hi Jennifer, There are a few suggestion I have when I look at your second snippet of code: use os.path.join(pathname, filename) to create a valid output (requires "import os") use "IDW_{0}".format(COCLayer) to create the name access the Idw tool through arcpy.sa.Idw note that the output is not a parameter of IDW the result of a arcpy.sa tool is normally a raster object (in memory) use the .save methode on the object to save the raster to a location Thank you for your reply. I was persistent yesterday and found a solution. By the way, as I mentioned in my original post, I did follow the suggestions on the help pages for Exp and Idw, and unfortunately, both appear to be incorrect for ArcGIS 10.x versions. Both of them can take an output file name as a parameter. And if an output file name is not supplied, then both will write output to the workspace (in my case, a personal geodatabase) with an automatically generated name. Here is how I implemented Idw and Exp: The script arguments (inputs) remain the same. I added another variable back in, a string for the name of the final result output raster, outRaster. I added parameters for the temporary outputs for Exp and Idw which I deleted later. And, I used another raster variable, MARaster, for some math algebra output. This step was probably not necessary, but it helped me sort out the debugging process. IDWOut = geoDB + "\\IDW_temp"
outRaster = geoDB + "\\IDW_" + COCLayerBase
arcpy.Idw_sa(geoDB + "\\temp_data", COCField, IDWOut, IDWCellSize, IDWPower, IDWRadius, IDWBarrier)
arcpy.Exp_sa(IDWOut, ExpOut)
MARaster = arcpy.Raster(ExpOut) / 1000
MARaster.save(outRaster)
arcpy.Delete_management(geoDB + "\\temp_data")
arcpy.Delete_management(IDWOut)
arcpy.Delete_management(ExpOut)
... View more
03-07-2014
04:37 AM
|
0
|
0
|
440
|
POST
|
Hello, I am trying to convert some 9.3 python scripts that use the geoprocessor object gp to use arcpy instead. I am struggling with the conversion of Single Output Map Algebra (SOMA) that uses exp. Also, the script first calculated IDW on a set of points and that alone was quite a struggle to figure out since the 10.2 help for Spatial Analyst IDW does not show the correct input parameters! Add to the confusion the decision of when to use arcpy.Raster and when not to. Anyway, I am very close, but for some reason when I run arcpy.Exp_sa on my raster as such: ExpOut = arcpy.Exp_sa(IDWOut) another raster is automatically output by Exp with the same name as IDWOut, but with Exp_ at the beginning and _1 at the end. For example, if IDWOut is "IDW_PAH_filtered", then a raster called "Exp_IDW_PAH_filtered_1" is automatically created. According to the help page http://resources.arcgis.com/en/help/main/10.2/index.html#//009z0000008s000000 the output should be saved to ExpOut, but when I look at the values of that raster, I can see that they have not had the exponential applied. So confused!! Here are the actual code snippets: geoDB = sys.argv[1]
COCLayer = sys.argv[2]
COCField = sys.argv[3]
PerfLog = sys.argv[4]
IDWCellSize = sys.argv[5]
IDWPower = sys.argv[6]
IDWRadius = sys.argv[7]
IDWMask = sys.argv[8]
IDWBarrier = sys.argv[9 and IDWOut = geoDB + "\\IDW_" + COCLayer
arcpy.Idw_sa(geoDB + "\\temp_data", COCField, IDWOut, IDWCellSize, IDWPower, IDWRadius, IDWBarrier)
ExpOut = arcpy.Exp_sa(IDWOut)
IDWOut = arcpy.Raster(ExpOut) / 1000 And the temp_data is a temporary point shapefile that is created correctly by the script. I started wondering if Exp has the wrong input parameters on the help page just like Idw and maybe needs an output raster as one of the parameters, like: arcpy.Exp_sa(IDWOut, ExpOut) but when I tried that, I got an error saying "name 'ExpOut' is not defined". If anyone has any insights, I will welcome them. Yes, I know I can still use the old gp method, but I really want to avoid that. By the way, here is what it used to look like: IDWOut = geoDB + "\\IDW_temp"
outRaster = geoDB + "\\IDW_" + COCLayer
gp.Idw_sa(geoDB + "\\temp_data", COCField, IDWOut, IDWCellSize, IDWPower, IDWRadius, IDWBarrier)
inExpress = "( exp (" + IDWOut + ") ) / 1000"
gp.SingleOutputMapAlgebra_sa(inExpress, outRaster) The inputs sys.argv[] were the same. In that case, IDWOut was a temporary raster that was deleted later and the final output was outRaster, but doing something similar with arcpy was creating even more problems.
... View more
03-06-2014
10:02 AM
|
0
|
3
|
974
|
POST
|
I am running ArcGIS 10 with SP5 in Windows 7. I think it must have been some kind of out of memory error. I was able to validate the topology just fine when running on a coworker's computer that is supposed to be set up exactly like mine, so I am not sure what the real problem is.
... View more
08-07-2013
11:51 AM
|
0
|
0
|
679
|
POST
|
I am trying to validate a topology shared between a polygon dataset and a line dataset. There are 3 rules: 1) line features must be covered by the boundary of polygon features, 2) polygon feature boundary must be covered by line features, and 3) line features must not have dangles. The two datasets I am working on are each the result of a dissolve of other polygon and line datasets which also had shared topology, the rules for which I was able to validate and correct all errors for. But when I try to validate the topology for these dissolved datasets, I get the following error: "Validate Topology failed. A failure was detected inside the topology engine. [error id: 257] Cannot register as versioned on this database." I do not understand why versioning is even a problem since these datasets are part of a file geodatabase, not an SDE geodatabase. I have tried to run each rule individually, but I get the same error each time.
... View more
07-30-2013
09:32 AM
|
0
|
3
|
4437
|
POST
|
Hi. I just installed SP 1 and now an add-in tool I have that was written with VB .net is causing ArcMap to crash when I use it. I took the tool out, removed the link to the folder where it is located and restarted ArcMap with a fresh mxd, added data to it and then loaded my add-in again. I was able to use the tool twice, then I started an edit session, tried to use the tool again and it crashed ArcMap. When I opened that mxd again and tried to use the tool, it crashed ArcMap immediately. This was working fine before I installed SP1, so I think I am going to remove it. Too bad - because SP1 did fix another annoying, but less so, issue I was having with having to uncheck "Stretch topology proportionately when moving a topology element" every time I open ArcMap and want to start editing topology. Addendum: I checked the code for the add-in I am using, which I did not write, and it uses IDataStatistics. Based on Ernie's comments above, this is likely the cause of the problem I am having.
... View more
06-28-2013
09:25 AM
|
0
|
0
|
782
|
POST
|
Thank you Kim for your first suggestion! I have a similar task and was trying to write a script, but when I read your suggestion, I gave my task some more thought and realized I could do what I needed using various selections, Spatial Join, and Join by Attributes with no need for a script except to put it altogether in one place. Whew!
... View more
03-20-2013
08:47 AM
|
0
|
0
|
612
|
Online Status |
Offline
|
Date Last Visited |
09-21-2023
06:32 PM
|