Excellent! It is great that you have written out a plan, many people don't and then get hopelessly lost... It definitely looks possible.Right now we'll get step 1 partly working, just printing to screen. Once that is good we can put the data in a useful data structure, rather than just printing it.I think James' suggestion, of using Pandas, is good. I haven't used it myself, but I think it works pretty well with time data and plotting functions. So there is something else you will need to look up and have a play with...Do you intend to only ever assess one meter at a time? You have a few options, but for now we may as well keep part 1 collecting all the data, and between part 1 and part 2 define the one METER NUMBER to make the graph of.
import arcpy from arcpy import env env.overwriteOutput = 1 env.workspace = r"C:\temp\python\test.gdb" table = "Meters" arcpy.TableSelect_analysis(table, r"in_memory\table_sel", "METER_NUMBER = " + arcpy.GetParameterAsText(0)) out_graph_name = arcpy.GetParameterAsText(0) out_graph_pdf = r"C:\Temp\python\Userdata" + "\\" + arcpy.GetParameterAsText(0) + ".pdf" input_template = r"C:\Temp\Python\UserData\KW Demand.grf" #grf file previously saved input_data = r"in_memory\table_sel" # Create the graph graph = arcpy.Graph() # Add a vertical bar series to the graph graph.addSeriesBarVertical(input_data, "KW_DEMAND") # Specify the title of the left axis graph.graphAxis[0].title = "KW Demand" # Specify the title of the bottom axis graph.graphAxis[2].title = "Meter Number" # Specify the title of the Graph graph.graphPropsGeneral.title = "KW Demand by Meter" # Output a graph, which is created in-memory arcpy.MakeGraph_management(input_template, graph, out_graph_name) # Save the graph as an image arcpy.SaveGraph_management(out_graph_name, out_graph_pdf, "MAINTAIN_ASPECT_RATIO", 600, 375)
I think I should include an example of the data that I am using to better explain what I am trying to accomplishAttached: Example.xlsxThis is also in a File Geodatabase as a Geodatabase TableThis table is composed of around 9500 meter records (METER NUMBER)1) Go through the table and find METER NUMBER record with the billing period, KWH and KW Demand rows attached.2) Extract/export/select a unique METER NUMBER with the data attached (billing period, KWH and KW Demand)3) Take the data and build a graph showing the Billing Period along the "X" Axis, KWH and KW Demand along the "Y" Axis4) Export the graph to a .PDF with the METER NUMBER as the file nameFrom there I can use the Attachments Geoprocessing tool to take the .PDF and attach it to the Meter Location in the .MXDLong Term Goal is to create a One-Touch custom Button to select a specific METER NUMBER to create a graph described above and automatically create a .PDF. I know this sounds like a huge project - and want to learn how to build it piece by piece to eventually accomplish the Long Term Goal.Thanks for your help in advanced
Having a hard time getting multiple fields to show up.I have about (4) fields that I need to show: TWACs_NUMBER PERIOD_ENDS KWH_USAGE KW_DEMANDSo Far - I can get the "TWACs_NUMBER to "print" to the screen - but I need all of these fields to "print" so I can sort them by TWACs NUMBER
Stacy- Thank you for the ideas. I have playing around with the SearchCursor in Python and so far all I am getting it to do is to "Print" to the screen. What else would I have to do to extract this data out?
FeatClassArray = [] fc = r"H:\Documents\ArcGIS\Default.gdb\MyFeatureClass" fields = [f.name for f in arcpy.ListFields(fc)] with arcpy.da.SearchCursor(fc, fields) as cursor: for row in cursor: FeatClassArray.append(row) df = DataFrame(FeatClassArray) #now use the df with matplotlib functionality to build your plots/graphs
This can definitely be done in Python, but you will have to learn a lot!Here are a few bits to get you started:SearchCursor (10.0), da.SearchCursor (10.2) allows you to iterate through tables and get values. You could store the values (date, reading) within lists in a Python dictionary by meter number.Python datetime module (inbuilt) will be helpful for working with dates.Matplotlib allows you to plot things from Python.I don't know how to make PDFs from Python, but I have no doubt whatsoever that it is possible...I would suggest you start playing around with matplotlib, datetime and searchcursors first, once you are familiar with them, start to think about the data structure that you will use to get the information from the searchcursor, analyse the monthly peak, and pass the result to matplotlib. Happy to help if you have more specific queries!
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.