Hi,
I wrote a python tool using pythonaddins in ArcGIS 10.1. The tool works perfectly on ArcGIS 10.1 and 10.2. But I am unable to run the tool on ArcGIS 10.3.
Here is my python code snippet:
def onMouseDownMap(self, x, y, button, shift):
#setup workspace location
arcpy.env.workspace = r"" + self.inFile
#list all rasters
rasters = arcpy.ListRasters("*", "TIF")
#CSV file
csv_file = arcpy.env.workspace + "\output.csv"
#define output rows list
rows = []
#define output layers list
layers = []
#loop through all raster files and get cell values
for raster in rasters:
result = arcpy.GetCellValue_management(raster, "{} {}".format(x, y), "1").getOutput(0)
layers.append("{}".format(raster))
rows.append("{}".format(result))
#open the csv file and append values for each click on the raster map
with open(csv_file, 'a') as outcsv:
#configure writer to write standard csv file
writer = csv.writer(outcsv, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL, lineterminator='\n')
#print x, y in csv
writer.writerow(['x', 'y'])
#print x, y location in csv
writer.writerow([str(x), str(y)])
#print Layer, Value in csv
writer.writerow(['Layer', 'Value'])
#get row length
rowlen = len(rows)
#loop through the rows and print output to csv
for i in range(0, rowlen):
writer.writerow([layers, rows])
And here is my config.xml file look like:
<ESRI.Configuration xmlns="http://schemas.esri.com/Desktop/AddIns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>GetRasterCellValue</Name>
<AddInID>{c509440b-c55e-46bb-b443-a61a2b824da2}</AddInID>
<Description>A python addins tool to get cell value of raster files</Description>
<Version>0.1</Version>
<Image>Images\Other.png</Image>
<Author>Yamin Noor</Author>
<Company>XYZ</Company>
<Date>06/08/2015</Date>
<Targets>
<Target name="Desktop" version="10.1" />
</Targets>
<AddIn language="PYTHON" library="GetRasterCellValue_addin.py" namespace="GetRasterCellValue_addin">
<ArcMap>
<Commands>
<Tool caption="GRCV" category="GetRasterCellValue" class="GRCV" id="GetRasterCellValue_addin.GRCV_1" image="Images\Other.png" message="Get Raster Cell Value" tip="Use this tool to get raster cell value">
<Help heading="Get Raster Cell Value">Get Raster Cell Value</Help>
</Tool>
</Commands>
<Extensions></Extensions>
<Toolbars>
<Toolbar caption="GRCV" category="GetRasterCellValue" id="GetRasterCellValue_addin.GRCV" showInitially="true">
<Items>
<Tool refID="GetRasterCellValue_addin.GRCV_1" />
</Items>
</Toolbar>
</Toolbars>
<Menus></Menus>
</ArcMap>
</AddIn>
</ESRI.Configuration>
I am not sure if changing the target version (to 10.3) in config.xml would make any difference. i.e
<Target name="Desktop" version="10.1" />
Thanks
Yamin
Message was edited by: Yamin Noor