|
POST
|
What's the names of your columns? Are those aliases? I was guessing the spaces were underscores. Replace the names in the 'with arcpy.searchcursor ' line with their proper names
... View more
01-31-2020
04:06 PM
|
2
|
1
|
1226
|
|
POST
|
Haha, I've edited the original to count it as a list rather than new parameters. My bad.
... View more
01-31-2020
03:56 PM
|
2
|
9
|
1521
|
|
POST
|
Can you export your shapefile to a feature class? Not sure what's wrong.
... View more
01-31-2020
03:34 PM
|
2
|
11
|
1521
|
|
POST
|
Hi, I've edited the original code to account for my stupidity. Also you need to specify you path with 'r' then in quotes as per the code. E.g. r'c:/users/david/project.gdb'
... View more
01-31-2020
03:04 PM
|
2
|
15
|
1521
|
|
POST
|
Sorry change all those double equal signs to one equals sign up to and including line13
... View more
01-31-2020
02:39 PM
|
2
|
18
|
4164
|
|
POST
|
Rafael, Unfortunately I dont have a home license for arcmap to test this. Do you have an IDE? If not I cant talk you through making it as a tool
... View more
01-31-2020
02:13 PM
|
2
|
22
|
4164
|
|
POST
|
import arcpy
input_table = r'put the path to your table here'
#lcb is the lower class boundary
width_age_range_1 = 14.5
lcb_age_range_1 = 0.0
width_age_range_2 = 50.0
lcb_age_range_2 = 14.5
width_age_range_3 = 35.5
lcb_age_range_3 = 64.5
median_list = [ ]
with arcpy.da.SearchCursor(input_table, ["TOT", "TOT_0_14", "TOT_15_64", "TOT_65"]) as cursor :
for row in cursor :
#if all numeric fields hopefully
n_over2 = (row[0]/2.0)
if row[1] >= n_over2 :
#cumulative freq of groups before median group
cumu_freq = 0.0
if row[1] != 0.0 :
median = lcb_age_range_1 + ( ((n_over2 - cumu_freq)/row[1]) * width_age_range_1)
median_list.append(median)
continue
continue
if (row[1] + row[2]) >= n_over2 :
#cumulative freq of groups before median group
cumu_freq = row[1]
if row[2] != 0.0 :
median = lcb_age_range_2 + ( ((n_over2 - cumu_freq)/row[2]) * width_age_range_2)
median_list.append(median)
continue
continue
if (row[1] + row[2] + row[3]) >= n_over2 :
#cumulative freq of groups before median group
cumu_freq = row[1] + row[2]
if row[3] != 0.0 :
median = lcb_age_range_3 + ( ((n_over2 - cumu_freq)/row[3]) * width_age_range_3)
median_list.append(median)
continue
continue
else:
median_list.append("error")
for median in median_list :
print(median)
#obviously can add a field and append these values in rather than printing them. look at arcpy.da.UpdateCursors
... View more
01-31-2020
12:04 PM
|
3
|
24
|
4164
|
|
POST
|
It's not actually too hard. N/2 will be the cumulative frequency you're looking for, so a search cursor and a few conditional statements should find your median group. Then just plug that group's range and upper and lower bands into the grouped median formula. I can write it out if you like.
... View more
01-31-2020
11:19 AM
|
2
|
26
|
4164
|
|
POST
|
Perhaps try focal statistics on the original DEM to replicate the smoothing function. Then retry.
... View more
01-31-2020
09:12 AM
|
0
|
0
|
1222
|
|
POST
|
I guess it could be done by calculating the equations of both lines then solving to see if they are perpendicular and where the would cross, create a point at that intersection and points to line.
... View more
01-31-2020
07:43 AM
|
0
|
0
|
1260
|
|
POST
|
I'm assuming you meant this as 20 degrees (i.e 110 degrees)?
... View more
01-31-2020
06:29 AM
|
1
|
0
|
1127
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-13-2025 01:08 PM | |
| 1 | 09-25-2025 03:19 PM | |
| 1 | 09-24-2025 02:35 PM | |
| 1 | 09-17-2025 02:42 PM | |
| 1 | 09-10-2025 02:35 PM |
| Online Status |
Offline
|
| Date Last Visited |
Wednesday
|