|
POST
|
Xander Bakker I know...you are right. I submit to this as like every thread and experienced python developer says this is a better way to go. In an effort to make my code better and to add some value to this thread I will reconfigure my code to use a cursor to do the field calculation. Many thanks. If anyone thinks it would be of value I'll post the final product here.
... View more
11-15-2018
06:16 AM
|
2
|
1
|
2715
|
|
POST
|
Dan Patterson Dan, are you familiar with the proverb For Want of a Nail? Notice that one slight change I underlined? jeez... And the output: Thanks for sticking with me on this one! In the end you were right...it was ultimately about quotes
... View more
11-15-2018
06:13 AM
|
1
|
1
|
10655
|
|
POST
|
Thanks Dan. I'm not firing on all cylinders but I'm gonna try to tackle this again in the AM. I'm also nervous about the format block in the code block. I just wish I knew why this worked in MB. (,I even tried to yank out converted script. I even built a stand alone function that does this same part that works!) Thanks again
... View more
11-14-2018
06:57 PM
|
0
|
3
|
10655
|
|
POST
|
Thanks Dan! We're calculating a field called Q_BEARING, with BEARING being one the inputs to the epression. Not sure if you cought my last blurb but it does indeed appear to be a problem with my notation statement (if I simplify that things work). Can I embed an additional string formatter within the codeblock?
... View more
11-14-2018
06:41 PM
|
0
|
5
|
10655
|
|
POST
|
Dan thanks for the heads-up on the Jive formatting. I looked back at my code and I do have the indentations. However, I did modify the beginning and end of the codeblock a bit. I know images are generally frowned upon when relaying code, but given the formatting issue I'm adding this for verification. Still have the same error: UPDATE: after much picking away it does appear that something is wrong with the 'notation' statement or at least something isn't happy there. If I reduce it down to just notation = prefix + str(degrees) the output is fine. Admittedly the output is a bit over-complicated (but it works in model builder) . Is there a way to insert another string formatting statement w/in the codeblock? I may try that fresh in the AM.
... View more
11-14-2018
05:37 PM
|
0
|
7
|
10655
|
|
POST
|
Dan Patterson After a really long day I came home to try your fix, but to no avail. I was very hopeful on this one too! Same error. i wonder if i try to format my notation statement? too bad because it did work in the model builder prototype but it's probably some kinda issue with quote escaping (although that lingering thing about copying and pasting the code block is bugging me too, i'll redo that but remote access is slow tonight).
... View more
11-14-2018
04:07 PM
|
0
|
9
|
10655
|
|
POST
|
I've spent quite a bit of time looking at all the similar issues on GeoNet and Stack Exchange but I still can't find an answer. I'm sure that someone will be quick to say that I should use a cursor, but this exact same code works in ModelBuilder just fine! Is there the potential for a carriage return or something? I copied and pasted my codeblock so that might be a possibility. Here's my code (the FC in question does indeed have a field called 'BEARING'): # Add Quandrant Bearing Field
arcpy.AddField_management(BoundSplit, "Q_BEARING", "TEXT", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
# Calculate Quadrant Bearing
expression = """ DD_DMS_Line(!BEARING!,{0}) """.format(correction)
arcpy.AddMessage(expression)
codeblock = """def DD_DMS_Line(bearing, correction=0):
value = bearing + correction
if value <= 90:
numb = value
prefix = "N"
suffix = "E"
elif value > 90 and value < 180:
numb = 180 - value
prefix = "S"
suffix = "E"
elif value >= 180 and value < 270:
numb = value - 180
prefix = "S"
suffix = "W"
elif value > 270 and value <= 360:
numb = 360 - value
prefix = "N"
suffix = "W"
elif value > 360:
numb = value - 360
prefix = "N"
suffix = "E"
degrees = int(numb)
submin = abs( (numb - int(numb) ) * 60)
minutes = int(submin)
subseconds = abs((submin-int(submin)) * 60)
notation = prefix + str(degrees) + u"\u00b0" + str(minutes) + "\'" +\
str(subseconds)[0:5] + "\"" + suffix
return notation"""
arcpy.CalculateField_management(BoundSplit, "Q_BEARING", expression, "PYTHON", codeblock) My expression appears to be fine (highlighted in this image). ugh, been banging my head against the wall on this one!
... View more
11-14-2018
01:46 PM
|
1
|
15
|
16403
|
|
POST
|
Dan Patterson To be clear: the folks I know are using Shiny to generate outputs directly into word docs. I know that ReportLab directs outputs to PDF. To reiterate: the requirements are generally that the table (example here) are included directly in the map document (exported as a PDF). These are often contractual documents so having the categorized acreage values on the map is a requirement. Again, it is silly to me to have to generate a table, export it, only to have to copy & paste it back into the document but that's the required product and I don't currently see a way around it. [Pro Table Frames do not support the required categorization.]. My purpose here is to automate this task of report generation while enforcing a consistent format. We have a number of users generating this kind of content. Even if the user has to copy&paste the (pre-formatted) output and then manually resize to accommodate the various map elements (since record number, scale, and extent all vary) that is still a win. Right now the ability to format Excel with Python appears to be too limited which is why I'm seeking reporting alternatives.
... View more
11-13-2018
06:39 AM
|
0
|
0
|
870
|
|
POST
|
Starting a 'discussion' (rather than a specific 'question') seems like the best venue for my inquiry. I realize that many of you may have multiple reporting strategies and that other things like the output itself and audience would dictate or impact your choice for reporting. I feel like I'm about to jump into ReportLab with all the talk of future integration into Pro. Some of my colleagues are more on the R side of things and use Shiny which seems light years more advanced than anything I've found for a python implementation (please, tell me I'm wrong! I want to hear about it). That said, Shiny might be overshooting the scope of what I need to accomplish. My needs are mostly tabular outputs of acres/area categorizations but charts & graphs could become something the audience is interested in. Mostly, the product requirement is that the table be included directly on the map document. That creates some limitations & challenges right there. [One specific question I do have is: is there a way to output a Pandas dataframe directly into an ArcMap/Pro document? Having to export solely for the sake of having the ability to copy the content into ArcGIS is less than desirable (if not silly)]. So that's the context from my end. What are you all using? What's your output content requirement? Who's your audience? Thanks!
... View more
11-13-2018
06:02 AM
|
0
|
2
|
2132
|
|
POST
|
Dan Patterson thanks! there's some real gold in there. I've bookmarked these and downloaded your table tools. I ended up getting some help on SE and found an easy way to move the totals. Thanks again Dan!
... View more
11-13-2018
05:17 AM
|
0
|
0
|
15191
|
|
POST
|
Dan Patterson, thanks for that...I didn't know it would be so simple. Here is what I came up with for my test code before I roll it up into a function. I've always got open ears for improvement! Edit: my pivot table fails to include a grand total. Any suggestions? table = "\\\\fileServer\\MAP_PROJECTS\\LV_WEB\\SDE_CONNECTIONS\\LV_NEXUS.sde\\LV_NEXUS.DATAOWNER.NORTHEAST\\LV_NEXUS.DATAOWNER.NE_HARVEST_OPS"
HUID = "669-NMTC-139"
whereClause = """ "LV_HARVEST_UNIT_ID" = '{0}' """.format(HUID)
print(whereClause)
tableArray = arcpy.da.TableToNumPyArray(table, ['STAND_NUMB', 'SUPER_TYPE','STRATA', 'OS_TYPE', 'SILV_PRES', 'ACRES'], where_clause = whereClause)
df = pd.DataFrame(tableArray)
report = df.groupby(['SUPER_TYPE']).apply(lambda sub_df: sub_df.pivot_table(index=['STRATA', 'OS_TYPE', 'STAND_NUMB', 'SILV_PRES'], values=['ACRES'], margins=True) )
np.round(report,1)
... View more
11-12-2018
06:13 AM
|
0
|
2
|
15191
|
|
POST
|
I'm attempting to add in subtotals to a pivot table from a very basic array. The first example I provide I derived on my own, but this has no subtotals for each group. The second example I borrowed and honestly I don't really get how it works just yet, and I cannot get a round to work. pd.pivot_table(df.round({'ACRES':1}),values = 'ACRES', index = ['SUPER_TYPE','STRATA', 'OS_TYPE'], aggfunc=np.sum, margins = True) Returns: 2nd example: df.groupby(['SUPER_TYPE']).apply(lambda sub_df: sub_df.pivot_table(index=['STRATA', 'OS_TYPE'], values=['ACRES'], margins=True) ) I'm guessing there are a number of ways to go about this. Thanks in advance!
... View more
11-09-2018
08:21 AM
|
0
|
4
|
21254
|
|
POST
|
Thanks Kelly. However, I'm still confused. There is a difference in pricing with level 1 users between ArcGIS Enterprise and ArcGIS Online, so there will be no changes with this. There is a change or there isn't?? Could you please expand on this? After the December release of ArcGIS Online, Level 2 users will convert to a Creator which have access to field apps. So if I currently have 30-40 users using Collector for free with AGO (AND assuming we will are about to migrate to Portal [this part may not be relevant but I'm adding for context]), I will need to now budget for an increased cost of $15,000-$20,000 to support the same field staff ($500/Level 2 user)?? Am I missing something? I sure hope so!
... View more
11-06-2018
01:10 PM
|
0
|
1
|
1382
|
|
POST
|
Just reading the latest blog post regarding this. Do I understand correctly that Level 1 users, previously available at no cost to an organization, will now cost $100/user/year? Do I understand correctly that in order to use field data collection apps like Collector, each user will now cost $500/user/year? Currently I have no cost associated with users using these free app. We currently use ArcGIS Online as a front end to our onprem ArcGIS Server. We are moving towards an ArcGIS deployment with Portal and a federated server. Will these same costs now be applied to ArcGIS Portal?
... View more
11-06-2018
12:43 PM
|
0
|
4
|
1929
|
|
POST
|
I'd like to resurrect this discussion as well; any updates on this?!
... View more
10-11-2018
06:31 AM
|
1
|
1
|
2066
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-06-2024 06:58 AM | |
| 1 | 12-16-2022 07:01 AM | |
| 1 | 08-09-2024 06:55 AM | |
| 1 | 08-13-2024 05:58 PM | |
| 1 | 07-23-2024 08:00 AM |
| Online Status |
Offline
|
| Date Last Visited |
10-24-2025
05:12 AM
|