|
POST
|
That is what the original script that I posted does. What you will need to do is create a sample graph and update the script with the correct paths to your data. Then, create a toolbox > right-click on the toolbox > Add Script > browse to the script. You will also need to add a parameter to the script of type Long. A user can then click on the script and it will open a dialog for them to specify a Meter Number. Once they do and execute the tool, the meter number is queried and the graph is saved to a PDF. Jake- Sounds like I have most of the parts....a good part of them from you...and I really appreciate that. The biggest headache right now is I cannot figure out the Script for the Search Cursor to isolate individual meter number records to produce a single graph for a specific meter number
... View more
08-28-2013
11:10 AM
|
0
|
0
|
3842
|
|
POST
|
Your fields need to be a list. http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000 Instead of: fields = "BILLING_PERIOD";"METER_NUMBER";"KWH";"KW_DEMAND" try: fields = ["BILLING_PERIOD","METER_NUMBER","KWH","KW_DEMAND"] Mind me asking what's the purpose of creating a list of the meter numbers? Jake- What I am trying to do is to take a File Geodatabase Table that lists Electric Meters with their Peak KW Demand on a given billing period to eventually make a graph. See previous posts in this thread for full explination. I am having a heck of a time with this Search Cursor just trying to get a list of unique meter numbers with all of the rest of the data and isolating the rows of the same meter number
... View more
08-28-2013
10:50 AM
|
0
|
0
|
3842
|
|
POST
|
Okay - what is not working here? ## extract unique records from a gdb table and make mulitple tables for
## graphing
import arcpy, os
arcpy.env.overwriteOutput = True
table = "C:\MEWCo GIS System\Electric System\MEWCo_Electric_Model-LOCAL.gdb\billing"
fields = "BILLING_PERIOD";"METER_NUMBER";"KWH";"KW_DEMAND"
# empty list to store unique meter numbers
meterNumbers = []
# use a search cursor to extract the unique numbers
with arcpy.SearchCursor(table,fields) as cursor:
for row in cursor:
if not row[1] in meterNumbers:
meterNumbers.append(row[1]) This is the error I'm getting: Traceback (most recent call last): File "Z:\Operations\Maps and Records\GeoDatabase\MEWCO GIS System\Python Scripts\SearchCursorExample.py", line 16, in <module> with arcpy.SearchCursor(table,fields) as cursor: File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 820, in SearchCursor return gp.searchCursor(*args) File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 357, in searchCursor self._gp.SearchCursor(*gp_fixargs(args))) IOError: "C:\MEWCo GIS System\Electric System\MEWCo_Electric_Model-LOCAL.gdb illing" does not exist
... View more
08-28-2013
10:37 AM
|
0
|
0
|
3842
|
|
POST
|
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. Stacy- Thank you for the posts. So far - I do not have much code written since I am still in the research and design phase of this project to get to the final outcome. Really looking for advice and maybe examples of different parts of the overall Python code. So far - I have some great information from different people to research and start doing some trial and error. The only thing I do not have yet: How do I go about taking a Python script and making a "One-Click" custom button in ArcMap that when someone clicks on it - it runs the Python Script in the background?
... View more
08-28-2013
07:08 AM
|
0
|
0
|
451
|
|
POST
|
Here is an example on how to accomplish this. First, you will want to create a sample graph in ArcMap. Here is a screen shot of the parameters I used: [ATTACH=CONFIG]27045[/ATTACH] After the graph is created, right-click on it and save it out as a .grf file. Now you can use the below code to create a graph of the "KW Demand by Meter" by specifying a meter number: 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) Jake- Thank you for the Python Script for creating a graph. I will work with that and see what I can come up with
... View more
08-28-2013
07:05 AM
|
0
|
0
|
3842
|
|
POST
|
Hi, Have part of an answer for you, the code below will allow you to extract out the information based on the unique billing numbers within your table. It doesn't yet create and export the graphs but more on that in a minute. Here is the code for extracting the unique billing tables. ## extract unique records from a gdb table and make mulitple tables for
## graphing
import arcpy, os
arcpy.env.overwriteOutput = True
table = r'H:\Python\test.gdb\billing'
fields = ['BILLING_PERIOD','METER_NUMBER','KWH','KW_DEMAND']
# empty list to store unique meter numbers
meterNumbers = []
# use a search cursor to extract the unique numbers
with arcpy.da.SearchCursor(table,fields) as cursor:
for row in cursor:
if not row[1] in meterNumbers:
meterNumbers.append(row[1])
# for each unique cursor make a table view using the billing number for
# the selection
for meter in meterNumbers:
## omit the quotes if you table stores the meter number as a number not a string
expression = arcpy.AddFieldDelimiters(table,'METER_NUMBER') + " = " + "'" + meter + "'"
arcpy.MakeTableView_management(table,"CurrentMeter",expression)
# copy the rows to a permanent table in the same location
outTable = os.path.join(os.path.dirname(table),("meter_" + meter))
arcpy.CopyRows_management("CurrentMeter",outTable)
## at this point can use the graphing options to generate the graphs and save
## unfortunately don't have the answer yet for this the copy rows at the end is not strictly need as you can do the graph creation in memory for each billing table. If you want to create the graph purely using arcpy and ArcGIS you have a couple of options. There are the make and save graph tools which you can use based on a template graph created in arcmap, all that is required then is to modify the data source for each graph to your current table. Alternatively use the arcpy graph class to carry out all these steps, I believe you will need to use this class to modify the data sources in the previous example. THe save graph will then allow you to export to pdf. There is also matplotlib shipped with arcpy and that may be a better way to create the graphs. Sorry haven't used it so can't give you any steering on utilising it. Hope this helps and gets you started. If i come up with anything I'll post again. Cheers Dave Dave- Thank you for the Python script to find the unique Meter Number and export them out. I will play with this and see what I can come up with.
... View more
08-28-2013
07:03 AM
|
0
|
0
|
3842
|
|
POST
|
What I have is a table I produced from our Customer Information System showing the billed KWH Usage and KW Demand for a ALL electric meters over a period of time (From July 2011 to July 2013). There are about 900,000 records in this table of around 9500 electric meters. What I am trying to accomplish is listed below: Attached: Example.xlsx This is also in a File Geodatabase as a Geodatabase Table This 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" Axis 4) Export the graph to a .PDF with the METER NUMBER as the file name From there I can use the Attachments Geoprocessing tool to take the .PDF and attach it to the Meter Location in the .MXD Long 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
... View more
08-27-2013
09:17 AM
|
1
|
32
|
12153
|
|
POST
|
I think I should include an example of the data that I am using to better explain what I am trying to accomplish Attached: Example.xlsx This is also in a File Geodatabase as a Geodatabase Table This 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" Axis 4) Export the graph to a .PDF with the METER NUMBER as the file name From there I can use the Attachments Geoprocessing tool to take the .PDF and attach it to the Meter Location in the .MXD Long 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
... View more
08-27-2013
08:18 AM
|
0
|
0
|
3056
|
|
POST
|
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_DEMAND So 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
... View more
08-27-2013
07:43 AM
|
0
|
0
|
3056
|
|
POST
|
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? 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!
... View more
08-27-2013
06:57 AM
|
0
|
0
|
3056
|
|
POST
|
Greetings I have a rather large project I am trying to do and I hope I can get Python to do it for me. I have a file geodatabase table called "SERVICE METERS DEMAND" which is basically composed of the peak demand reading on an electric meter for a given month. I have the range of readings from November 2011 to March 2013. The table contains about 172,000 total records with almost 10,000 electric meters. What I want to be able to do is to take an individual meter by number (TWACs Number) and create a graph visually showing the peak demand for each month. This would be used by our engineering department and our meter techs for analysis and decisions making. The big thing is - I update this table about 4 times a year so my geodatabase can have the latest demand readings that other departments use. With that being said, I would like to create a script that can automatically create all new graphs and export them out to a .PDF format. I can than use the Attachment geoprocessing tools to link those .PDF graphs to the meter locations. Do you think this is something that can be done by Python? If so - how do I start this. I currently have ArcMap 10.0 on one machine and in the process of testing a bunch of different tools/processes on ArcMap 10.2 on a different machine. Thank you in advance. Can send a sample of the SERVICE METERS DEMAND table as well
... View more
08-23-2013
06:56 AM
|
0
|
10
|
3720
|
|
POST
|
Greetings- Our company does things a little different. Instead of using ArcGIS Server and web development, we use ArcMAP as our editor and ArcReader as our viewer. I have been getting complaints from different users inside my company that ArcReader 10.0 is unreliable. The largest complaint I get is when they use the "FIND" tool. Sometimes it comes up fast. BUT, most of the time it takes a few minutes for the FIND dialog box to show up. Other times - ArcReader 10.0 completely freezes up and they have to force close it and reopen it. Is this a known issue? Also - Does ArcReader 10.1 and/or ArcReader 10.2 have a better FIND tool and is the new release(s) more reliable than ArcReader 10.0? Thank you
... View more
07-31-2013
10:48 AM
|
0
|
1
|
3547
|
|
POST
|
I was doing some more research on ESRI and I didn't get a chance to go to the International User Conference this year - but saw that ArcMap 10.2 is now out. Did they fix this issue with this new release? Can I install ArcMap 10.2 on my local machine and create a .PMF that can be opened in ArcReader 10.0? Greetings- Having a hard time getting a straight answer on this problem. Does ArcMap 10.1 Service Pack 1 fix the issue with creating a .PMF in ArcMap 10.1 and having the ability to open it in ArcReader 10? I have ArcReader installed on about a dozen machines in my company and will be a pain to go to each one and uninstall 10 and install 10.1 for ArcReader. I want to use ArcMap 10.1 because of the new features, but my operations and engineering staff relies on ArcReader. Or - is there a patch I cannot find? Thanks
... View more
07-30-2013
10:33 AM
|
0
|
0
|
558
|
|
POST
|
Greetings- Having a hard time getting a straight answer on this problem. Does ArcMap 10.1 Service Pack 1 fix the issue with creating a .PMF in ArcMap 10.1 and having the ability to open it in ArcReader 10? I have ArcReader installed on about a dozen machines in my company and will be a pain to go to each one and uninstall 10 and install 10.1 for ArcReader. I want to use ArcMap 10.1 because of the new features, but my operations and engineering staff relies on ArcReader. Or - is there a patch I cannot find? Thanks
... View more
07-30-2013
10:10 AM
|
0
|
2
|
3790
|
|
POST
|
Caleb- You have been a huge help and I appreciate your time in helping me get this process working.... I am a little confused though since I am still very much a rookie when it comes to working with Python scripting. I have the basics down.. but this advanced stuff is a little over my head. My next process: Service Location feature class (the same feature class I have been working with) CIS_Service_Meters Table What do I put where in which script. I have the Memory script in the Python directory. And I will make a new python script for the CIS Service Meters to update into the Service Location feature class ALSO - Do you have a good website tutorial that you can point me to that I can learn about all this advanced python scripting (Dictionaries, indexes, etc)? Thank you
... View more
04-15-2013
09:40 AM
|
0
|
0
|
1412
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-23-2026 10:58 AM | |
| 1 | 11-20-2025 02:52 PM | |
| 1 | 10-30-2025 12:42 PM | |
| 1 | 10-16-2025 10:51 AM | |
| 1 | 08-27-2025 08:47 AM |
| Online Status |
Online
|
| Date Last Visited |
yesterday
|