POST
|
I have looked everywhere in the API to try to find a way to delete the entire legend from a dataframe using Arcpy, but I have not been able to find the correct method. Could someone point me in the right direction? arcpy.mapping doesn't let you add or subtract elements from your layout. The help files suggest that if you have an element that you don't wish to display on the output, change the location of the element to be off the page using the .elementPositionX property.
... View more
06-25-2013
02:01 PM
|
0
|
0
|
275
|
POST
|
Hi folks I'm having issues troubleshooting an error message while trying to set my buffer parameters. The intention is to create a selection criteria on an ArcGIS Map to generate areas that are 1000 feet around any major roads. I have already defined roads as a variable, and the following is the tool parameter that I'm trying to input, which sets the optional dissolve parameter to ALL , so that overlapping buffers are dissolved: buffer = arcpy.Buffer_analysis(roads, "in_memory/buffer", "1000 Feet", "", "", "ALL") Now I keep getting an error message with the word buffer highlighted but I don't know what's wrong. Also, as I type the word buffer in the IDLE screen it turns purple. Does this mean it has some kind of internal definition or something? I think buffer is a key word and you can't use it for layer names. Can you try "in_memory/buffer_roads" ?
... View more
06-25-2013
01:56 PM
|
0
|
0
|
456
|
POST
|
OK, so I'm new at writing scripts. I take alot of pride in my work when I finish the script. So recently, one of my coworkers took one of my scripts and rewrote it to fit his needs. Should I be happy about this?????? I'm not used to people taking my work. Is that what we do with our scripts? Share them I guess?? I generously share my code with anyone who wants it. And when I borrow code, I typically keep the "Author:" line at the top as the original author and add an "Amended by:" name and date, and depending on the severity of the change, a note on what changes were made. People should be polite and respectful when they borrow your code, and you can request attribution. But I don't think it's a requirement.
... View more
06-25-2013
01:51 PM
|
0
|
0
|
391
|
POST
|
David, While this is the reverse of what you want, I think it should be able to give you some ideas. I will need to do the same as you soon, but just havn't had the opportunity to do so just yet. I think you will need get the properties of the DataFrame to convert from page units to preferred projected coordinates. http://gis.stackexchange.com/questions/21514/convert-point-xy-to-page-units-xy-using-arcpy Here's what I discovered when using the onMouseDown and onMouseDownMap in a Python add-in. The function onMouseDown will return a set of pixel values showing the coordinates of where you clicked, measured in pixels from the upper left of the map display window. The function onMouseDownMap is sensitive to your current view. If you are in data view, it returns coordinates in the map's coordinate system. If you are in layout view, it returns coordinates in page units - but only allows you to click inside the data frame element. The fix is as suggested by James (Thanks!!). Convert the page coordinates to map coordinates. To do this, I find the lower left page X coordinate and the click point X value and subtract the two. That's how far over from the edge of the data frame I clicked in inches. Then (for feet) divide by twelve and multiply by the scale of the map. That's the distance in map units I am from the edge of the data frame. Then I find the data frame's minimum X value in map units and add the calculated distance. Repeat for Y. Here's the code for a tool in my add-in that lets you click in the map while in layout view and select a feature from a layer called "Cadastre". class Sel_Property(object):
"""Implementation for Notifications_addin.selectproperty (Tool)"""
def __init__(self):
self.enabled = False
self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.
def onMouseDownMap(self, x, y, button, shift):
thisMap = arcpy.mapping.MapDocument("CURRENT")
data_frame = arcpy.mapping.ListDataFrames(thisMap)[0]
page_x = x
page_y = y
"""Convert page coordinates to projected coordinates"""
#get the data frame dimensions in page units
df_page_w = data_frame.elementWidth
df_page_h = data_frame.elementHeight
df_page_x_min = data_frame.elementPositionX
df_page_y_min = data_frame.elementPositionY
df_page_x_max = df_page_w + df_page_x_min
df_page_y_max = df_page_h + df_page_y_min
#get the data frame projected coordinates
df_min_x = data_frame.extent.XMin
df_min_y = data_frame.extent.YMin
df_max_x = data_frame.extent.XMax
df_max_y = data_frame.extent.YMax
df_proj_w = data_frame.extent.width
df_proj_h = data_frame.extent.height
#ensure the coordinates are in the dataframe
if page_x < df_page_x_min or page_x > df_page_x_max:
raise ValueError ('X coordinate is not within map portion of the page.')
if page_y < df_page_y_min or page_y > df_page_y_max:
raise ValueError ('Y coordinate is not within map portion of the page.')
#scale the projected coordinates to map units from the lower left of the data frame
scale = data_frame.scale/12 # converting scale factor to feet per inch
map_x = df_min_x + ((page_x - df_page_x_min)*scale)
map_y = df_min_y + ((page_y - df_page_y_min)*scale)
# pythonaddins.MessageBox("Coordiantes are" + str(map_x) + " and " + str(map_y),"Title")
pointGeom = arcpy.PointGeometry(arcpy.Point(map_x,map_y), thisMap.activeDataFrame.spatialReference)
layers = arcpy.mapping.ListLayers(thisMap)
for lyr in layers:
if lyr.name == "Cadastre":
arcpy.SelectLayerByLocation_management(lyr,"INTERSECT",pointGeom)
thisMap.activeView = "PAGE_LAYOUT"
arcpy.RefreshActiveView()
data_frame.zoomToSelectedFeatures()
data_frame.scale = data_frame.scale * 5.2
... View more
06-25-2013
11:17 AM
|
2
|
0
|
325
|
POST
|
I'm getting the code to work for onMouseDownMap, but while in layout view the value I'm getting back is still in page coordinates and not map coordinates ... unless I go to the data view. Then I get map coordinates. Is this how it's supposed to work, or is there a was to focus the data frame and get map coordinates. class Sel_Property(object):
"""Implementation for Notifications_addin.selectproperty (Tool)"""
def __init__(self):
self.enabled = True
self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" ...
def onMouseDownMap(self, x, y, button, shift):
pythonaddins.MessageBox("Your mouse clicked at " + str(x) + " , " + str(y),"My Coordinates:")
... View more
06-25-2013
08:46 AM
|
0
|
0
|
325
|
POST
|
Is there a way to add separators to a Python Add-in toolbar? I have a combo box, a tool, and a button showing a caption only, and the tool gets lost in the middle. I need a visual separation. Short of that, is there a way to have a tool show both the caption and the icon? It seems that you can show one or the other, but not both.
... View more
06-24-2013
07:57 AM
|
0
|
1
|
3671
|
POST
|
I've create an example, example-toolbox.pyt that hopefully clarifies (also as a Github Gist😞 You'll then have two categories within your toolbox: Export and Import, Import will contain one item and Export will contain two. cheers, Shaun Aha! I found three references to adding the self.category but none said that it goes in the individual tool class rather than the toolbox class. Perfectly understandable now. Thanks!!
... View more
06-11-2013
04:52 AM
|
0
|
0
|
1295
|
POST
|
Can someone post an example of how to configure and use the toolsets in a Python Toolbox? The help barely mentions that this is even an option, and the only code example I can find is to set: self.category = ???Toolset Name??? but when you have: self.tools = [tool1, tool2] I just get the regular tools listed in the toolbox without a toolset. How do you tell it to put the tools into the category?
... View more
06-10-2013
12:40 PM
|
0
|
4
|
5207
|
POST
|
Can you paste a full traceback? Did you find a solution? One of my students asked me to help solve this, and I'd look like the hero if I can come up with the answer (or if y'all did and I can steal it!).
... View more
10-05-2011
12:59 PM
|
0
|
0
|
900
|
POST
|
Eric - your problem is that the model with the iterator can only be called the one time, and will return only one value back to the calling model. It's not a steady back-and-forth thing where the iterator returns a vlaue to the calling model for each run. So here's what you do. Create a model that will prompt the user for a new feature class name - and have it use the field scheme from an existing FC that would be used in the merge. Then call the iterating model ... but at the end of that model run the append command and append the results to the FC that the user created. In the sub-model, the results of each iteration are appended to the FC as they are derived. When it's done, it will return to the calling model and end. Check out this books for more on ModelBuilder: http://esripress.esri.com/display/index.cfm?fuseaction=display&websiteID=195&moduleID=0 It has a LOT of good info on using iterators and interacting with feature classes. David Allen
... View more
08-29-2011
10:28 AM
|
0
|
0
|
2257
|
POST
|
I am new to ModelBuilder and was just wondering if "Select by Location" and/or "Select By Attributes" can be incorporated into a model? Thank you Sounds like you need this new ModelBuilder book: http://esripress.esri.com/display/index.cfm?fuseaction=display&websiteID=195&moduleID=0
... View more
08-29-2011
10:02 AM
|
0
|
0
|
227
|
POST
|
Ours are basically the same. Stored in a SQL Server table. I add the table to an ArcMap document through an OLE-DB connection and use the "Display XY Events" to convert the table to a featureclass in the document. Then just publish the document in ArcGIS Server and use the Query Widget to view it. It would be nice to have an AVL widget based on the Query Widget that included the ability to follow a particular vehicle, i.e. keep the map centered on the vehicle while it moved. Also a button to zoom to the extent of all vehicles would be handy. Or a cell phone tracking widget!!! Then we wouldn't need additional hardware in the trucks! David Allen
... View more
03-07-2011
10:03 AM
|
0
|
0
|
383
|
POST
|
Well that was the answer - the web server wouldn't send a jpg file out, but it has no trouble with a gif. So I changed the format of the images and they work fine now.
... View more
03-04-2011
11:36 AM
|
0
|
0
|
414
|
POST
|
David, It looks like your production machine does not have access to the images. Are they in a virtual directory that is restricted in some way? That's a good thought. Let me go take a look, and maybe get the server guys involved. Thanks!
... View more
03-04-2011
10:16 AM
|
0
|
0
|
414
|
POST
|
I'm having an odd issue. When I run my application from the flash builder program to test it, the Identify widget is displaying information about my location in a pop-up box that points to the feature. It includes all the fields as well as a little picture that's associated with the feature. See Sign1.gif attached. When I compile this and view it through a web browser, none of this information is displayed with the feature. See Sign2.gif attached. Any idea what's going on? David Allen
... View more
03-03-2011
05:36 AM
|
0
|
0
|
414
|
Title | Kudos | Posted |
---|---|---|
1 | 03-06-2017 09:30 AM | |
1 | 06-11-2019 01:32 PM | |
7 | 07-16-2020 12:21 PM | |
1 | 03-10-2020 11:09 AM | |
1 | 04-22-2019 09:21 AM |
Online Status |
Offline
|
Date Last Visited |
02-15-2023
07:12 PM
|