POST
|
Hi @JakeSkinner, I just invited you! Also, for context here is my python script minus our credentials: Thanks in advance! import arcpy, os, uuid
import pandas as pd
import datetime
from datetime import date, timedelta
from zipfile import ZipFile
from arcgis.features import GeoAccessor, GeoSeriesAccessor, FeatureLayerCollection
from arcgis.gis import GIS
# get table from AGOL
gis = GIS('https://kirklandwa.maps.arcgis.com', 'user', 'pw')
CrimeTrendsTable = gis.content.get('{78e4a92c5c324dd18cc6eee11cb6b2f7}')
# still trying to figure this part out whether it be an overwrite or a delete and append
CrimeTrendsTable.delete_features(where="1=1", return_delete_results=True)
# import feature class and create slice of the data set in a new dataframe
df = pd.DataFrame.spatial.from_featureclass(r"local path of larger feature class from sde")
df = df.sort_values(['OFFENSES_YEAR', 'CRIME_STAT_TYPE', 'FROM_DATE'], ascending= [True, True, True], ignore_index=True)
df = df.loc[:, ['OFFENSES_YEAR', 'CRIME_STAT_TYPE', 'FROM_DATE']]
# set variables for today and the previous 5 years
today = datetime.datetime.today()
todate1 = today - timedelta(365)
todate2 = today - timedelta(730)
todate3 = today - timedelta(1095)
todate4 = today - timedelta(1460)
todate5 = today - timedelta(1825)
this_year = datetime.datetime.today().year
one_year_ago = this_year - 1
two_years_ago = this_year - 2
three_years_ago = this_year - 3
four_years_ago = this_year - 4
five_years_ago = this_year - 5
# create new dataframes for current and each previous year to date
df0 = df.loc[(df['OFFENSES_YEAR']==this_year) & (df['FROM_DATE'] < today)]
df1 = df.loc[(df['OFFENSES_YEAR']==one_year_ago) & (df['FROM_DATE'] < todate1)]
df2 = df.loc[(df['OFFENSES_YEAR']==two_years_ago) & (df['FROM_DATE'] < todate2)]
df3 = df.loc[(df['OFFENSES_YEAR']==three_years_ago) & (df['FROM_DATE'] < todate3)]
df4 = df.loc[(df['OFFENSES_YEAR']==four_years_ago) & (df['FROM_DATE'] < todate4)]
df5 = df.loc[(df['OFFENSES_YEAR']==five_years_ago) & (df['FROM_DATE'] < todate5)]
# create tables for each current and previous year grouped by crime type, add together previous year tables and average
table0 = df0.groupby('CRIME_STAT_TYPE')['OFFENSES_YEAR'].count().reset_index()\
.rename(columns={"OFFENSES_YEAR" : this_year})
table1 = df1.groupby('CRIME_STAT_TYPE')['OFFENSES_YEAR'].count()
table2 = df2.groupby('CRIME_STAT_TYPE')['OFFENSES_YEAR'].count()
table3 = df3.groupby('CRIME_STAT_TYPE')['OFFENSES_YEAR'].count()
table4 = df4.groupby('CRIME_STAT_TYPE')['OFFENSES_YEAR'].count()
table5 = df5.groupby('CRIME_STAT_TYPE')['OFFENSES_YEAR'].count()
avgtable = pd.concat([table1, table2, table3, table4, table5]).groupby('CRIME_STAT_TYPE').mean().reset_index()\
.rename(columns={"OFFENSES_YEAR" : "previous5yearAverage"})
trendstable = avgtable.join(table0.set_index('CRIME_STAT_TYPE'), on='CRIME_STAT_TYPE').fillna(0)
trendstable.to_csv(r"local path.csv", sep='\t', encoding='utf-8')
# hoping to add a line here that would update my hosted table from the trendstable dataframe...
trendstable.to_featurelayer('CrimeTrends')
print(trendstable)
... View more
a month ago
|
0
|
6
|
145
|
POST
|
Thanks @DerekLaw both of these tips are helpful! I'll experiment with them but hopefully this gets us started. As far as items go I'd like to be able to trace back from the feature layer or web map to the map service to the registered data in the sde. Right now I go into server manager and I can see where the service was published from but if that aprx or mxd is no longer accessible is there another way to find where the registered data that it's referencing is located? Ultimately, I'd like to have a spreadsheet that lists all the sde's and their feature layers or datasets, the map service REST URL, and the associated items in Portal and their service IDs. I may not be describing this perfectly but basically having some way to track where everything is and how it's dependent on each other. Hope that makes sense!
... View more
a month ago
|
0
|
0
|
24
|
POST
|
Hi Kara, thanks for sharing this code! I've been trying to overwrite a hosted table in AGOL but I keep getting the following error: AttributeError: 'NoneType' object has no attribute 'type' Have you ever encountered this. I've been reading other posts by @JakeSkinner and trying to get this to work but no luck yet! Any thoughts anyone might have would be greatly appreciated. The hosted table is not spatial so I'm wondering if that has something to do with it. It's just 3 columns and a few rows of data that I'm extracted and using for a dashboard. Would love to be able to automate this!
... View more
a month ago
|
0
|
8
|
172
|
POST
|
@Psoralea thank you for posting this! We're in the process of migrating from web app builder to experience builder but I had to update an authoritative layer today and the symbology wouldn't show up even if I changed it after the fact in the map viewer. This little check box worked like a charm!
... View more
03-12-2024
10:44 AM
|
0
|
0
|
292
|
POST
|
@DerekLaw this is a bit of an old thread but somewhat relevant to what I'm trying to figure out. I'm curious if you have any info on how to trace back from portal to where in the enterprise geodatabase registered data is living. I just started at a new org and there has been some turnover. We have a bunch of items in portal that are not hosted but rather reference data in an enterprise geodatabase. Is there a way to reverse engineer or see what layers in the EGDB these items in portal are referencing and on what servers? Any help or support documentation you can provide would be so appreciated! Thanks!
... View more
03-11-2024
11:28 AM
|
0
|
1
|
53
|
IDEA
|
@jill_es do you or anyone from the Enterprise or Pro team know if this is in the product road map. We are also having some issues with attribute rules and replicas at the City of Kirkland, WA. We are hoping to switch to 10.9 and 3.2 and I was curious if this is fixed in those versions. Thanks!
... View more
03-06-2024
02:57 PM
|
0
|
0
|
113
|
POST
|
We also have a use case for this on a public facing form our county government is using. Looking forward to seeing this become available.
... View more
04-07-2022
10:37 AM
|
1
|
0
|
2172
|
POST
|
@DavinWalker2 @Anonymous User I am also having this issue. I was a bit embarrassing because we are rolling out a fairly comprehensive survey for a department in our county and we recently purchased a large set of fieldworker licenses so they could edit. Administrators can submit the survey but for some reason the fieldworker and creators can't despite having data editor or publisher roles and being in the group that the feature layer is shared in. I double checked the feature layer and it says editors can edit so I'm not sure what the deal is.
... View more
04-06-2022
08:35 AM
|
0
|
0
|
1011
|
POST
|
I'm using a locator (view) with my Survey123 form to limit the addresses that auto populate. The state recently published a geocode service (https://geo.nj.gov/arcgis/rest/services/Tasks/NJ_Geocode/GeocodeServer) that we were able to add to AGOL under the utility services tab. Is there a way to make a locator (view) like I did with the World Geocoding Service expect using the NJ service and then use it in Suvey123?
... View more
11-15-2021
05:39 AM
|
0
|
1
|
402
|
POST
|
@Anonymous User I'm also, having trouble with this...it seems as though you can't add or edit domain values on a hosted feature service and that I'll have to download it, edit, re-upload, and then change the URL in all my web and field apps? Curious if you've found any new info on this or if that seems to be the recommended workflow...if that's the case I'm thinking we should submit this as a request for an enhancement...
... View more
10-28-2021
12:17 PM
|
0
|
3
|
3887
|
POST
|
@ZacharySutherby, just in case the enhancement you mentioned doesn't fix the issue I'm having I've logged a separate one under ENH-00143976. Thanks again for all your help!
... View more
10-27-2021
12:28 PM
|
0
|
0
|
519
|
POST
|
Hi @Anonymous User, I've logged an enhancement with support under ENH-000143978. Thanks again for all your support on this! Respectfully, Fred
... View more
10-27-2021
12:26 PM
|
3
|
0
|
2069
|
POST
|
Hi @ZacharySutherby, Just came across this post and wanted to see if there's an updated script available? Thanks! Fred
... View more
10-25-2021
10:59 AM
|
1
|
0
|
1573
|
POST
|
Hi @ZacharySutherby, Thank you for your thorough response to my question. I didn't realize that when a form is loaded from the inbox it's treated differently than if it's opened in the browser. I see what you did there with addition of the prior question making the group relevant depending on the response to that question. It's a neat idea but I think for now I'll keep the now() expression in the calculate column instead of the default one. Whether it's in calculate or default it works once the user taps on the DateTime field but I like that when it's in calculate it gives the refresh option icon to the right of the field. From a UI/UX standpoint it's a little more intuitive for our field workers since it's an actual icon for them to click. Also, one of the downsides of having the group be relevant is that if they select no on start survey they could possibly still go through and submit the survey but bypass the first group of questions which is a risk I'm hesitant to take. In regards to the ENH-000134563 enhancement is there an estimated idea of which future release this would be included in? Thanks again for your time! I really appreciate it. Respectfully, Fred
... View more
10-22-2021
11:52 AM
|
1
|
4
|
2105
|
POST
|
Hi @Anonymous User, Thanks so much for your thorough response and explanation of the functionality of iOS and mobile OS in general. I am new to developing in this space so I really appreciate understanding how this works. I had no idea that to close the keyboard on an iPhone you could simply swipe down over it. I have seen the icon you mention in the on-screen keyboard with the down arrow/close option on iPad and other platforms. Do you think it would be reasonable from a UI/UX perspective to request an enhancement for Survey123 so that other non-text fields like radio, checkbox, etc., would cause the focus to change if the previous field is a text field resulting in the OS automatically closing the keyboard? Regardless of the outcome of this feature being included in future releases of Survey123 I really appreciate the time you took to explain the focus function in relationship to Survey123 on mobile OS platforms. Respectfully, Fred
... View more
10-22-2021
11:34 AM
|
0
|
2
|
2353
|
Title | Kudos | Posted |
---|---|---|
3 | Tuesday | |
1 | 3 weeks ago | |
1 | 3 weeks ago | |
1 | 10-13-2021 06:22 AM | |
1 | 10-13-2021 06:18 AM |
Online Status |
Offline
|
Date Last Visited |
2 hours ago
|