|
POST
|
You want to use InsertLayer. Give that a try and post back with any problems you have.
... View more
05-07-2014
05:06 AM
|
0
|
0
|
1043
|
|
POST
|
Thanks. If I understand correctly (always questionable), I think that's the direction I'm going. Not a finished product below, but where I'm heading... import arcpy
import pythonaddins
lstChanged = []
fc = r"C:\path\to\layer\Lots"
field = "OBJECTID"
class CheckSelectionChange(object):
"""Implementation for PyAddInWizard_addin.ext1 (Extension)"""
def __init__(self):
# For performance considerations, please remove all unused methods in this class.
self.enabled = True
def onEditorSelectionChanged(self):
fc = r"C:\Users\gkeith\Documents\Projects\Laurie\LaurieTest.gdb\Lots"
field = "OBJECTID"
with arcpy.SearchCursor(fc, field) as row:
if row.field in lstChanged:
lstChanged.pop(row.field) # this may be unnecessary, but will try it
else:
lstChanged.append(row.field)
class CreateLotNum(object):
"""Implementation for PyAddInWizard_addin.btn1 (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self): # button event handler
lstDoubleCheck = []
with arcpy.SearchCursor(fc, field) as row:
lstDoubleCheck.append(row.field)
# plan to check lstDoubleCheck, all currently selected parcels, against lstChanged, any that were listed in onEditor...
... View more
05-06-2014
12:25 PM
|
0
|
0
|
2762
|
|
POST
|
At a guess, I'd say that you don't have your paths set up correctly. That's what the error for line 1, import sys suggests. Python can't find the sys module.
... View more
05-06-2014
11:51 AM
|
0
|
0
|
1019
|
|
POST
|
Thanks Wayne, you're correct. Listen for selection change, determine if the item is selected or deselected, and add or drop it from the list respectively. It's trivial to number at that point, but getting to that point is the problem. There's a tool in the parcel fabric and/or local government model that does something similar when drawing a line through the lots, but we're not there yet. I also need to allow the user to set the starting number. Python add-in extensions have an event onEditorSelectionChanged(self), but I can't find any documentation on how to use it properly.What I really need is a property like isSelected I could check. One option might be to forget selection and create two buttons, a start and a stop, with each click after start incrementing by one until the user clicks stop. Not sure if I can hijack the cursor to do that though. I'll take a look at your method. Thanks again.
... View more
05-06-2014
11:05 AM
|
0
|
0
|
2762
|
|
POST
|
I'm trying to create a python addin that will fill a list with the objectids of features in the order they're selected. This is so I can then add incremental numbers to them in that order. Trying to automate lot numbering, basically. The order of the objectids themselves doesn't necessarily correspond to lot order, so can't just sort them. The idea is that the user would select the features, then click a button to add the lot numbers. I can add numbers using Chris Fox's UniqueIDSort script, but there's no existing field to sort on. Main problem is retrieving the objectid when the script hasn't run yet. Tried using onEditorSelectioChanged() under Extensions, which presumably could just listen for the event and build the list, but don't see documentation on how to check if a feature has been selected or unselected. Any help much appreciated.
... View more
05-06-2014
09:18 AM
|
0
|
10
|
7679
|
|
POST
|
Not sure this will work, but look into Create Fishnet. This can create lines that you could use to split the polygon. Part I'm not sure of is how to guarantee 730 cells. You might be able to divide the area of the polygon by 730 to get cell height & width, but if the fishnet is created on the extent of the polygon rather than the feature itself this might not work.
... View more
05-06-2014
08:31 AM
|
0
|
0
|
3536
|
|
POST
|
Other options include PyScripter (my favorite), Notepad ++, ConText, etc.
... View more
05-06-2014
07:51 AM
|
0
|
0
|
1070
|
|
POST
|
Maybe this belongs in the geodatabase forum, apologize if so. I see that ESRI now just ships the Local Government model as an xml file instead of a copy of the gdb w/sample data. Then ESRI says to use X-Ray for ArcCatalog to create the gdb. This would be fine, except X-Ray appears to require Excel. Our department got rid of MS Office as a cost saving move, and now we use Libre as a free open source alternative. X-Ray does not appear to like that, throws an error, although LibreOffice Calc can read and write xls files. My guess is that X-Ray is looking for Excel.exe. Is there a way to use something like Libre instead of calc, or does it have to have Excel itself? Thanks.
... View more
05-06-2014
04:29 AM
|
0
|
2
|
1485
|
|
POST
|
Are these individual points or a multi-point feature? If multi-point, explode them first. If you have them selected in an edit session, the Delete key should get rid of them, no need to clip. Clipping would require a separate shapefile for the clipping feature.
... View more
05-05-2014
10:43 AM
|
0
|
0
|
1200
|
|
POST
|
It might be easier to georeference the tif to the points. Not familiar with the British National Grid, but it sounds like although you may have projected the points, their values are still in their original system (GCS?). So if your coordinates are 51.5 N 0.4 W, your point will be 51.5 meters N, 0.4 meters W of whatever the origin point is for the BNG (assuming its unit is meters). If all your points seem bunched up into a small area, this is most likely the cause. Did you define a projection as well as project the points? One quick fix that may work is to create a feature dataset in a file gdb, set its coordinate system to BNG, and import your points into that.
... View more
05-05-2014
06:09 AM
|
0
|
0
|
842
|
|
POST
|
You can also do a slow double click on the layer name in the TOC so that the name is highlighted in a box and enter a new name, similar to renaming a file in Windows Explorer. You can also change the symbology labels under the Label heading on the Symbology tab. You could change the actual name of the shapefile or feature class, but that will break existing links in the map. You can reset those, of course.
... View more
05-05-2014
04:30 AM
|
1
|
0
|
30098
|
|
POST
|
Well, then in your loop you might want to first build a list of the non-zero values and calculate on those. Here's a very untested quick conceptual method. Think of it as pseudo-code.
for row in rows:
validlist = []
if row.A <> 0: validlist.append(row.A) # trying to think of a way to loop this part, drawing a blank
if row.B <> 0: validlist.append(row.B)
if row.C <> 0: validlist.append(row.C)
.
.
.
if row.N <> 0: validlist.append(row.N)
result = validlist[0] * Ln(1/validlist[0])
for i in range(1, len(validlist) + 1):
result += validlist * Ln(1/validlist)
... View more
05-02-2014
11:11 AM
|
0
|
0
|
1857
|
|
POST
|
Is there a way to tell if a layer is in a group layer? I was writing out the datasource for layers in a map, which worked fine, but can't tell if a layer is in a group or not. Can test whether a layer is a group layer or a feature class. Some layers are in group layers, some not. Some in group layers in group layers. This isn't a big deal, but would be nice to format the output in a directory tree style. Thanks.
... View more
05-01-2014
05:57 AM
|
0
|
4
|
5400
|
|
POST
|
Two methods, depending on whether you want to skip the calculation altogether if any value is zero, or if you want to calculate any non-zero values, skipping only zeros. If you have a lot of values to calculate, there's probably a better way, but this will work for your example. edit: also, you marked your own post as answered (green check mark). Use that for whoever best answered your question. Other forum members may not read your post, assuming it's been solved.
# Method 1
for row in rows:
if A == 0 or B == 0 or C == 0: # you may actually want row.A, etc, here, or row[0], row[1]. Second method is if you use arcpy.da
continue # this will skip this row in the for loop
else:
# do your calculations
# Method 2
for row in rows:
if A == 0 and B != 0 and C != 0:
# calculate only B and C
elif A != 0 and B != 0 and C == 0:
# calculate only A and B
elif: # and so on, for as many combinations as you have
... View more
05-01-2014
04:09 AM
|
0
|
0
|
1857
|
| Title | Kudos | Posted |
|---|---|---|
| 6 | 08-22-2019 07:41 AM | |
| 1 | 05-05-2014 04:30 AM | |
| 1 | 08-15-2018 06:23 AM | |
| 3 | 08-06-2018 07:31 AM | |
| 1 | 03-30-2012 08:38 AM |
| Online Status |
Offline
|
| Date Last Visited |
12-12-2021
01:00 PM
|