POST
|
Thank you Dan: I have downloaded the code you passed over and I am learning from it. The missing piece that I could not figure out appears in line 18 in your post above. a = arcpy.da.FeatureClassToNumPyArray( in_fc, out_flds, skip_nulls=False, null_value=null_dict) Using this line of code I was able to pass in the fields I needed, in this case ambulance response times, and then start calculating statistics on it using Numpy. Now that I have an array of data I can also start with hypothesis testing and writing up code for other statistical cases. But this one line of code was the logjam that stopped me. thanks, David
... View more
08-21-2019
05:58 AM
|
1
|
0
|
929
|
POST
|
Hi Dan: Thank you for all this information. I have downloaded the Python files for your toolbox and I am poring over them for ideas.
... View more
08-09-2019
10:29 AM
|
0
|
3
|
929
|
POST
|
I am using ArcGIS Pro 2.3 and Python 3.6 My goal is to extract a column of numeric data from my geodatabase and analyze it using numpy. However I am not sure how to open a specific column in a geodatabase and make it available to analyze the data statistically. Typically I use PyODBC to query a database and then use numpy on that data. Enclosed at the bottom is the Python code for what I am hoping to achieve using PyODBC. But Geodatabases and arcpy are not my expertise. Here is my pseudocode: -) Use Arcpy to add a column and calculate values for that column -.) Use Arcpy to open up the geodatabase and select that specific column. -.) Use Numpy or Scipy on that column to generate descriptive statistics such as mean, median, mode, percentiles, etc. (NOTE: Pandas would also be a good option.) -) After calculating statistics on this column, create a histogram, -) further statistical analysis once I get past this road block. The part I am stuck on is how to bridge the gap from the geodatabase and select out a specific column and analyze that data as a dataframe or using cursor. Can you please point the way to solving this problem? Shown below is the code I currently have which adds a response time column and calculates the fire truck response times. My next step is to analyze the data. There is another post similar - but not quite what I am attempting to do. This is what I currently have started: # Create a column in the geodatabase that is numeric # update that column with an equation DTMArriveOnScene - DTMDispatch in seconds # Use the number of seconds of fire truck response times to generate descriptive statistics # Use the number of seconds of fire truck response times for a histogram # Write this information out to an html page so the user can have a report import arcpy # Set environment settings arcpy.env.workspace = "C:/Users/kulpandm/Documents/ArcGIS/Projects/CFD/CFD.gdb" # Set local variables inTable = "CincinnatiCFD2" fieldName = "ResponseT" fieldPrecision = 9 fieldAlias = "Response Time" # Execute AddField ##arcpy.AddField_management(inTable, fieldName, "LONG", fieldPrecision, field_alias=fieldAlias, field_is_nullable="NULLABLE") ## make a calculation for the response times expression = "DateDiff($feature.DTMArriveOnScene, $feature.DTMDispatch,'seconds')" # Execute CalculateField arcpy.CalculateField_management(inTable, fieldName, expression, "ARCADE") Shown above I have added a column and calculated the data. Now I want to analyze it using Numpy. this is the part where I am stuck. Shown below is an example of how I solved this issue before using PyODBC and Pandas. -*- coding: utf-8 -*- ## David Kulpanowski ## 27 July 2018 ## This is an example of how I do this using SQL Server and Python. import pyodbc import pandas as pd import time #import scipy import scipy.stats as stats import matplotlib.pyplot as plt import numpy #from scipy.stats import mannwhitneyu #from scipy.stats import kruskal #from statsmodels.graphics.gofplots import qqplot #from matplotlib import pyplot StartTime = time.clock() cnxn = pyodbc.connect('DRIVER={SQL Server}; SERVER=MyServer; DATABASE=MyDatabase; Trusted_Connection=yes' ) cursor = cnxn.cursor() Fires = pd.read_sql(""" SELECT ResponseTime FROM FireTruckDetails ; """, cnxn) ##print(Fires.head(n = 20)) ##night.to_csv('c:/temp/FiresResponseTime.csv', sep = ',') cursor.close() cnxn.close() #descriptive statistics print('The current statistics ') Fires.ResponseTime.describe() fires_counts= Fires.ResponseTime.count() print(fires_counts) #### ## create a histogram for the current time frame for all delta echo responses #### fig = plt.figure() ax = fig.add_subplot(111) ax.set_ylim(ymin=0, ymax=500) plt.hist(current.ResponseTime, bins=numpy.arange(0, 900, 60), range=[0, 900], cumulative=False, color='Crimson', label='Fire Truck Response times', alpha=0.75) plt.title('Current time frame responses') plt.xticks(numpy.arange(0, 900, 60), rotation='vertical') plt.savefig('C:/Temp/FiresHistogram.svg', format = 'svg', orientation = 'landscape') plt.show() plt.clf()
... View more
08-08-2019
08:51 AM
|
0
|
5
|
1023
|
POST
|
I am working on a project for next generation 911. Our goal is to import school schematics into ArcGIS for the purpose of assigning addresses to the cafeteria, swimming pool, offices, etc. I have obtained the AutoCAD files for every school in the County as a .dwg file. I navigate to the folder holding my CAD files using ArcGIS Pro Catalog, I click and drag one .dwg into the Contents pane. The schematic draws but no where near the location it is supposed to be. What can I do to place the AutoCAD .dwg where it is supposed to live??
... View more
01-22-2019
10:48 AM
|
0
|
1
|
1301
|
POST
|
Thank you Randy Burton. That was very helpful. I am posting a screen grab of the answer as it is supposed to look.
... View more
08-03-2018
12:48 PM
|
0
|
3
|
4406
|
POST
|
I am working on a TIGER line file of roads in my county in shapefile format (although I am having the same problem with geodatabase format). I am attempting to update a created field named SpeedMPH based on another field. If the field named ROAD_MTFCC is equal to S1200 then update the SpeedMPH field to 25. My code block is written in Python 3.6 and I am running ArcGIS Pro 2.2.1 with the latest updates. My code block is: def Reclass(fld): if(ROAD_MTFCC == 'S1200'): return 25 elif(ROAD_MTFCC == 'S1400'): return 35 elif(ROAD_MTFCC == 'S1500'): return 45 elif(ROAD_MTFCC == 'S1640'): return 55 I then click the green check to verify my code and it is accepted. I click the run button and it runs for a few seconds. When I look at my TIGER line file of roads attribute table the SpeedMPH field is NULL. Nothing was updated. What am I doing wrong? Enclosed is a picture of the Calculate field window and a 7zip of my TIGER line shapefile. It is pretty standard Census data.
... View more
08-03-2018
12:32 PM
|
0
|
6
|
8589
|
Title | Kudos | Posted |
---|---|---|
1 | 08-21-2019 05:58 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|