POST
|
Hello, I am attempting my very first python add in. what I would like it to do is look at a feature class, look through the town field. when the user selects a town I want the next combo box to populate with the LABELTEXT field with all of the values in that town and when a LABELTEXT is selected zoom to that bad boy. I dont know how to get the town return into the ComboClass2 class or build the query to filter based on the town result class ComboBoxClass1(object):
"""Implementation for addin2_addin.combobox (ComboBox)"""
def __init__(self):
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWWWWWWWWWWWWWW'
self.width = 'WWWWWWWWWWWWWWWW'
def onSelChange(self, selection):
layer = arcpy.mapping.ListLayers(mxd, "block_cards", df)[0]
a = arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION", "town = '" + selection + "'")
return a
df.extent = layer.getSelectedExtent()
arcpy.RefreshActiveView()
def onFocus(self, focused):
global mxd
mxd = arcpy.mapping.MapDocument('current')
global df
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
layer = arcpy.mapping.ListLayers(mxd, "block_cards", df)[0]
arcpy.SelectLayerByAttribute_management(layer, "CLEAR_SELECTION")
self.items = []
values = [row[0] for row in arcpy.da.SearchCursor(layer, ["town"])]
for uniqueVal in sorted(set(values)):
self.items.append(uniqueVal)
class ComboBoxClass2(object):
"""Implementation for addin2_addin.combobox (ComboBox)"""
def __init__(self):
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWWWW'
self.width = 'WWWWWW'
def onSelChange(self, selection):
layer = arcpy.mapping.ListLayers(mxd, "block_cards", df)[0]
arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION", "town = '" + ComboBoxClass1.onSelChange() + "' AND LABELTEXT = '" + selection + "'" )
df.extent = layer.getSelectedExtent()
arcpy.RefreshActiveView()
def onFocus(self, focused):
global mxd
mxd = arcpy.mapping.MapDocument('current')
global df
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
layer = arcpy.mapping.ListLayers(mxd, "block_cards", df)[0]
arcpy.SelectLayerByAttribute_management(layer, "CLEAR_SELECTION")
self.items = []
values = [row[0] for row in arcpy.da.SearchCursor(layer, ["LABELTEXT"])]
for uniqueVal in sorted(set(values)):
self.items.append(uniqueVal)
... View more
06-03-2015
08:00 AM
|
0
|
0
|
2456
|
POST
|
Greetings all. its been some time since I have done some mosaicing in ArcMap and I am finding some difficulty. I have 6 rasters that I would like to merge into one file so I can serve them out as one map using geoserver. They are currently geotiffs or png's. The maps are at angles relative to one another so I am running into issues with null values. at places where the images overlap I cannot get a good result. either its white, black, or the wrong values. since the inputs are png there is an alpha of 0 or 255. can someone help me merge them together? attached is what I am getting and what I would like. Thanks! this is the result this is what I would like
... View more
04-08-2015
12:37 PM
|
0
|
1
|
3733
|
POST
|
I found a work around that works well enough. I found the problem in the feature datasets (most likely a user error but I was unable to locate it). I deleted them and everything went though fine. Easy enough to add them in later though although if the database were more complicated.
... View more
02-10-2014
07:17 AM
|
0
|
0
|
293
|
POST
|
Hello, I am having some trouble loading an XML document published from diagrammer into a blank file geodatabase. I have run the validation tool and do not have any errors or warnings. When attempting to load the XML via the wizard I get a dialogue box that just says failed to load. when I attempt it in python I get an error 001162 which says The XML file is not correctly formatted or is not a valid XML document type. I was able to load simple test schemas from diagrammer with no problem as well as the samples included I assume it is a formatting error on my part but i cant seem to find it, can someone please take a look at it. I have attached the diagrammer file for reference. Thanks! Dave
... View more
02-05-2014
12:20 PM
|
0
|
1
|
1663
|
POST
|
Thanks for the response Joe. I was thinking of using network analyst, seemed like the best tool. I have built a simple network data set that seems to work well with the toolbar. for example I can route from points to a destination and so forth. I am still getting results that don't seem to make much sense to me (I am confident this is user error) I ran a closest facility on the network and there is redundancy and lack of sharing in the result. [ATTACH=CONFIG]29628[/ATTACH]
... View more
12-05-2013
11:54 AM
|
0
|
0
|
411
|
POST
|
Hello, I am looking to solve a seeming simple problem but as this is the first time I have used spatial analyst professionally its been some time since I have dug into this extension and I can't seem to think though it. I am trying to solve a simple network. I have a set of locations (green dots) and I am attempting to find the shortest route to connect all dots to the destination (green square) with as much overlap as possible. As I said before this feels like it would be easy to solve and any help would be appreciated. [ATTACH=CONFIG]29624[/ATTACH]
... View more
12-05-2013
09:35 AM
|
0
|
3
|
1900
|
POST
|
Hello, I am running into a few errors trying to do something seemingly simple. I would like to generate a list of feature classes in a set of subfolders. If there is a specific feature class name in the list I would like to append this data to a dataset. I would like this to work for any feature class with the specific name as there will be many with the same name in different folders. I am able to list the Feature classes just fine but I cant get the syntax for finding the specific ones and appending them. This is what I have:
def main():
try:
import arcpy, sys, traceback, os, glob, shutil
arcpy.env.overwriteOutput = True
log = r'Q:\1-EMPLOYEE INBOX\David\downloads\logSurveyData.txt'
masterFolder = r"Q:\Field Data\P.M.M\TO_PAM"
outFolder = r"P:\Projects\SurveyData\DATA\Master.gdb\SMON"
dst = r'Q:\GIS\Field_Data\z_archive'
# shutil.copytree(masterFolder, dst + time.strftime('%m_%d_%y'))
#collect a list of subfolders in master folder
arcpy.env.workspace = masterFolder
arcpy.ListWorkspaces('','Folder')
subfolderLst = arcpy.ListWorkspaces('','Folder')
print subfolderLst
for subfolder in subfolderLst:
arcpy.env.workspace = subfolder
fcLst = arcpy.ListFeatureClasses()
print fcLst
for fc in fcLst("SectMon_PLSS_"):
arcpy.Append_management(fc, outFolder)
except:
print arcpy.GetMessages()
# Get the traceback object '"' + wildcard + '"'
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
# Concatenate information together concerning the error into a
# message string
pymsg = tbinfo + "\n" + str(sys.exc_type)+ ": " + str(sys.exc_value)
# Return python error messages for use with a script tool
arcpy.AddError(pymsg)
# Print Python error messages for use in Python/PythonWin
print pymsg
if __name__ == '__main__':
main()
Right now the error I am seeing is this <type 'exceptions.TypeError'>: 'list' object is not callable That being said even if the list worked I dont know if it would amend. Thanks!
... View more
02-05-2013
10:53 AM
|
0
|
2
|
438
|
POST
|
We have a solution! Here is the code:
import arcpy
from arcpy import env
import os
import time
def main():
try:
import arcpy, sys, traceback, os, glob, shutil
arcpy.env.overwriteOutput = True
log = r'Q:\1-EMPLOYEE INBOX\David\downloads\logSurveyData.txt'
masterFolder = r"Q:\GIS\Field_Data\MT"
outputFolder = r"C:\tmp\Shp_merged"
dst = r'Q:\GIS\Field_Data\z_archive\PMM'
#shutil.copytree(masterFolder, dst + time.strftime('%m_%d_%y'))
#collect a list of subfolders in master folder
arcpy.env.workspace = masterFolder
arcpy.ListWorkspaces('','Folder')
subfolderLst = arcpy.ListWorkspaces('','Folder')
print subfolderLst
for subfolder in subfolderLst:
arcpy.env.workspace = subfolder
fcLst = arcpy.ListFeatureClasses()
for fc in fcLst:
#file = fc in fcLst
filename = "'" + arcpy.env.workspace + os.sep + fc + "'"
print filename
arcpy.AddField_management(fc, 'shpname','text')
arcpy.CalculateField_management(fc, 'shpname', filename, "PYTHON" )
except:
print arcpy.GetMessages()
# Get the traceback object '"' + wildcard + '"'
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
# Concatenate information together concerning the error into a
# message string
pymsg = tbinfo + "\n" + str(sys.exc_type)+ ": " + str(sys.exc_value)
# Return python error messages for use with a script tool
arcpy.AddError(pymsg)
# Print Python error messages for use in Python/PythonWin
print pymsg
if __name__ == '__main__':
main()
Big thanks to JSkinn3
... View more
01-11-2013
09:18 AM
|
0
|
0
|
592
|
POST
|
Hi David, Add single quotes to your 'filename' variable. Try the following: for fc in fcLst:
filename = "'" + os.path.abspath(__file__) + "'"
arcpy.AddField_management(fc, 'shpname','text')
arcpy.CalculateField_management(fc, 'shpname',filename, "PYTHON" ) I have attempted this and when I do the path yielded is C:\Python26\ArcGIS10.0\Lib\idlelib\idle.pyw If I change __file__ to (fc) I get the return of P:\Scripts\scratch\CheckShot.shp' with P:\Scripts\scratch being the path to the script not the shapefile. Any thoughts? Thanks! Dave
... View more
01-04-2013
11:30 AM
|
0
|
0
|
592
|
POST
|
Why do you use __file__ in filename = os.path.abspath(__file__) ? Why not filename = os.path.abspath(fc) I also assume that the filename variable needs to be properly quoted before being passed to CalculateField arcpy.CalculateField_management(fc, 'shpname', r'"%s"' % (filename), "PYTHON" ) - that is, with double quotes (required by calculate field) surrounded by single quotes (needed to pass the double quotes as part of the string) This is returning the path to the script and the fc name. I would like the abspath of the file and the file name.
... View more
01-04-2013
08:16 AM
|
0
|
0
|
592
|
POST
|
Greetings, I have a question that I believe has a simple answer but I just can't quite find it. I am trying to calculate the absolute path of a shapefile to an attribute. so the goal is to have a "shpname" field that has the comple path e.g. C:/desktop/superfunline.shp. here is my python. def main(): try: import arcpy, sys, traceback, os, glob arcpy.env.overwriteOutput = True masterFolder = r"Q:\GIS\Field_Data\MT" outputFolder = r"C:\tmp\Shp_merged" #collect a list of subfolders in master folder arcpy.env.workspace = masterFolder arcpy.ListWorkspaces('','Folder') subfolderLst = arcpy.ListWorkspaces('','Folder') print subfolderLst for subfolder in subfolderLst: arcpy.env.workspace = subfolder fcLst = arcpy.ListFeatureClasses() for fc in fcLst: #file = fc in fcLst filename = os.path.abspath(__file__) print filename arcpy.AddField_management(fc, 'shpname','text') arcpy.CalculateField_management(fc, 'shpname',filename, "PYTHON" ) except: print arcpy.GetMessages() # Get the traceback object '"' + wildcard + '"' tb = sys.exc_info()[2] tbinfo = traceback.format_tb(tb)[0] # Concatenate information together concerning the error into a # message string pymsg = tbinfo + "\n" + str(sys.exc_type)+ ": " + str(sys.exc_value) # Return python error messages for use with a script tool arcpy.AddError(pymsg) # Print Python error messages for use in Python/PythonWin print pymsg if __name__ == '__main__': main() I am thinking the bold is where the error is occuring. the error is: ERROR 000539: <type 'exceptions.SyntaxError'>: invalid syntax (<expression>, line 1) Thanks! Dave
... View more
01-04-2013
06:42 AM
|
0
|
8
|
1253
|
POST
|
With the help of mighty MShetzer I have increased the limit and am still having the same issue. I have also brought in the same Map service into another map application and I am seeing all of the points that are in the feature class. Is there some performance settings in the flex builder application?
... View more
10-24-2012
10:26 AM
|
0
|
0
|
368
|
POST
|
Dave, What does your layer element in the main config.xml look like for this map service that is giving you this issue? Are you just reaching your max return features limit for that map service (by default it is set to 1000)? Thanks for the response. I am very new to all of this so please forgive my ignorance. In looking over the config files I see this with respect to the service I am putting the data into. <layer label="PFS Survey Pending" type="dynamic" visible="false" imageFormat="png32" alpha="1" url="http://pam.petro-fs.com/ArcGIS/rest/services/PFS/PFS_Survey_v3_Pending/MapServer"/> here is all of the config stuff for the web app I am building <?xml version="1.0" ?> - <configuration> <title>Bear Tracker</title> <logo>assets/images/logo.png</logo> - <style> <colors>0xffffff,0x333333,0x101010,0x0,0xffd700</colors> <alpha>0.8</alpha> <font name="Comic Sans MS" /> <titlefont name="Arial" /> <subtitlefont name="null" /> </style> - <!-- replace the following url with your own geometryservice --> <geometryservice url="http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" useproxy="false" /> - <widgetcontainer layout="float"> <widget icon="assets/images/i_target.png" label="Find an address" config="widgets/Locate/LocateWidget.xml" url="widgets/Locate/LocateWidget.swf" /> <widget icon="assets/images/i_draw2.png" label="Draw and Measure" config="widgets/Draw/DrawWidget.xml" url="widgets/Draw/DrawWidget.swf" /> <widget icon="assets/images/i_print.png" label="Print" config="widgets/Print/PrintWidget.xml" url="widgets/Print/PrintWidget.swf" /> <widget url="widgets/LayerList/LayerListWidget.swf" config="widgets/LayerList/LayerListWidget_1.xml" label="Layer List" icon="assets/images/i_layers.png" /> <widget url="widgets/Legend/LegendWidget.swf" config="widgets/Legend/LegendWidget_1.xml" label="Legend" icon="assets/images/Legend32.png" /> <widget url="widgets/Search/SearchWidget.swf" config="widgets/Search/SearchWidget_1.xml" label="Search" icon="assets/images/i_search.png" /> </widgetcontainer> <subtitle>Pipeline</subtitle> <widget url="widgets/Navigation/NavigationWidget.swf" config="widgets/Navigation/NavigationWidget.xml" left="10" top="50" /> <widget url="widgets/OverviewMap/OverviewMapWidget.swf" config="widgets/OverviewMap/OverviewMapWidget.xml" right="-2" bottom="-2" /> <widget url="widgets/MapSwitcher/MapSwitcherWidget.swf" config="widgets/MapSwitcher/MapSwitcherWidget.xml" right="20" top="55" /> <widget url="widgets/HeaderController/HeaderControllerWidget.swf" config="widgets/HeaderController/HeaderControllerWidget.xml" left="0" top="0" /> - <map esrilogovisible="true" openhandcursorvisible="true" scalebarvisible="true" zoomslidervisible="false" wraparound180="true" addarcgisbasemaps="true" initialextent="-11567139.31931013 6102416.403950664 -11433298.082782969 6172356.284831506" wkid="102100" top="40"> - <basemaps> <layer type="tiled" label="Imagery" icon="https://www.arcgis.com/sharing/rest/content/items/86de95d4e0244cba80f0fa2c9403a7b2/info/thumbnail/tempimagery.jpg" url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer" visible="true" /> </basemaps> - <operationallayers> <layer type="dynamic" label="PLSS SupportingData" url="http://pam.petro-fs.com/arcgis/rest/services/SupportingServices/PLSS_SupportingData/MapServer" visible="true" /> <layer type="dynamic" label="ND SupportingData v2" url="http://pam.petro-fs.com/arcgis/rest/services/SupportingServices/ND_SupportingData_v2/MapServer" visible="true" /> <layer type="feature" label="Tracts" url="http://pam.petro-fs.com/arcgis/rest/services/PFS/PFS_Survey_v3_Pending/MapServer/5" popupconfig="popups/PopUp_4.xml" mode="snapshot" visible="true" /> <layer type="feature" label="Kodiak Route Export 100312" url="http://pam.petro-fs.com/arcgis/rest/services/PFS/PFS_Survey_v3_Pending/MapServer/4" visible="true" /> <layer type="feature" label="linework" url="http://pam.petro-fs.com/arcgis/rest/services/PFS/PFS_Survey_v3_Pending/MapServer/3" visible="true" /> <layer type="feature" label="field points" url="http://pam.petro-fs.com/arcgis/rest/services/PFS/PFS_Survey_v3_Pending/MapServer/2" popupconfig="popups/PopUp_5.xml" mode="snapshot" visible="true" /> </operationallayers> </map> </configuration> I hope I am sniffing in the right spot here. Thanks
... View more
10-22-2012
09:42 AM
|
0
|
0
|
368
|
POST
|
Greetings, I have run into a little spot of bother regarding the ArcGIS viewer for Flex. I am trying to display a points layer from one of our published map services. there are roughly 3500 Features. Nearest I can tell I have set up everything correctly on the server side. the mxd behind the service is displaying all of the points I need to see and the MSD has been republished. The web all itself will only display roughly 60% of these points. when I run the search widget all of the points can be accessed. If I do a graphical search all of the points will show up with the binoculars icon. To me it looks like the features I have loaded recently (Have higher Object ID's) are not showing up. Any thoughts? Thanks, Dave
... View more
10-22-2012
07:37 AM
|
0
|
6
|
936
|
POST
|
Thank you very much. This worked like a charm. here is the final code: import os import arcpy #Workspace will be the database for export arcpy.env.workspace = r"P:\folder\rmp_2_5_2.mdb" #calculate fields arcpy.CalculateField_management ("WELL_PT", "W_STATUS", ' "STAK" ', "VB") Happy GISing, Dave
... View more
06-26-2012
08:56 AM
|
0
|
0
|
319
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|