POST
|
Hello all! I am pretty new to hub. I am trying to put together a hub page that has things for the public and different internal groups. Below in the first image is what it looks like under my login. Notice all the tiles. Some of the applications in these tiles are private, but is there a way for the tiles to still show on the public side even if the application itself is not public? Then if someone hits the tile it would ask for log in? When I publish the site and make it Public, all the tiles of the dashboards and apps that aren't public don't show anymore. I was hoping they would still show even though the application itself is private. Or am I doing to have to create different hub pages for different internal groups? Thanks, Justin Nettleton
... View more
02-06-2025
03:39 PM
|
0
|
2
|
424
|
POST
|
I am trying to figure something out with the Table Element in my dashboard. My dashboard has a couple filters at the top. So when they select a Fire jurisdiction in the filter, it zooms to that jurisdiction on the map. That action also filters my table element I have set up. I have that table set to zoom when I click on a row in the table to zoom to those features inside the jurisdiction. When I unselect that row, it zooms back to the home extent of the entire map. Is there anyway to have it just return to the extent of the jurisdiction I selected in my filter? I don't see any settings in the dashboard to make this happen. Maybe can edit the JSON in AGO Assistant some how? Any guidance greatly appreciated. Thanks, Justin Nettleton
... View more
08-30-2024
04:02 PM
|
0
|
1
|
416
|
POST
|
I change to x and y and still nothing in the table updated. Latitude and Longitude are the names of my geometry fields, but not sure that it matters. Justin
... View more
05-30-2024
02:55 PM
|
0
|
0
|
1407
|
POST
|
Here is how incorporated what you suggested and the error I am getting now. # Updating units
for call in current_units:
if call in agol_units:
#unit_feature = [f for f in ago_list if f.attributes['id'] == call][0]
unit_dict = {"attributes":
{"id":call[0],
"Unit":call[1],
"Status":call[2],
"StatusCategory":call[3],
"StatusRank":call[4],
"OOSReason":call[5],
"StatusChange":call[6],
"Type":call[7],
"Juridiction":call[8].upper(),
"Division":call[9],
"LastUpdate":call[10]},
"geometry":
{"x": call[11], "y": call[12]}}
#agoLayer.edit_attributes(updates=[unit_dict])
resp = agoLayer.edit_attributes(updates=[unit_dict])
print (resp)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
In [20]:
Line 84: print (resp)
NameError: name 'resp' is not defined
---------------------------------------------------------------------------
... View more
05-30-2024
02:54 PM
|
0
|
0
|
1407
|
POST
|
I am working on a realtime GIS python script I was given. I am working on simplifying it and just want to update features from a SQL view to a Feature service. The script runs successfully, but nothing updates. Ideally I just want to update the AGO feature layer only when a unit status changes in the SQL view. But a beginner at this and can't get it to work right. Any guidance would be appreciated. I know I could just do a truncate and append but at the speed I would want for this to update, I was having issues where the dashboard this feeds would update during the truncate and no data would be shown. Plus would like to use this else where in the future if possible on other projects. Thanks, Justin! import pyodbc
import os
from arcgis.gis import GIS
import arcgis
import sys
import arcgis.features
#lists for Units used during the update process
agol_units = []
current_units = []
unit_numbers = []
##select id,Unit,Status,Type,Juridiction,Division,LastUpdate
# SQL Query being passed through the ODBC connection
SQL_QUERY = """
select id,Unit,Status,StatusCategory,StatusRank,OOSReason,StatusChange,Type,Juridiction,Division,LastUpdate,Longitude,Latitude
from Reports_Database.dbo.Avail_Units_T
order by id
"""
print ('Query Successful')
def ODBC_connect():
##SERVER = 'CADGIS.heartlandcad.net\CADGIS\SQLEXPRESS' # Server FQDN
SERVER = 'CADGIS\SQLEXPRESS' # Server FQDN
DATABASE = 'Reports_Database' # Database Name
##Connection string to pass in pyodbc connection request. Using Trusted_Connect=yes to have SQL Server Native Client ODBC driver use Windows Authentication of the account running the script
## Using the Windows Authentication of the account running the script allows for the use of a Managed Service Account to run the scheduled python script
connectionString = f'DRIVER={{ODBC Driver 17 for SQL Server}};SERVER={SERVER};DATABASE={DATABASE};Trusted_Connection=yes'
conn = pyodbc.connect(connectionString)
cursor = conn.cursor()
cursor.execute(SQL_QUERY)
records = cursor.fetchall()
for r in records:
record = [r.id,r.Unit,r.Status,r.StatusCategory,r.StatusRank,r.OOSReason,r.StatusChange,r.Type,r.Juridiction,r.Division,r.LastUpdate,r.Longitude,r.Latitude]
current_units.append(record)
unit_numbers.append(r.id)
print ('SQL Connection Successful')
def Portal_push():
#user = os.getenv('justin.nettleton') # System Environmental Variable Name for Username
#portal = os.getenv('https://www.arcgis.com') # System Environmental Variable Name for Portal URL
#gis = GIS(portal,user,password,use_gen_token=True)
gis = GIS("https://www.arcgis.com", "justin.nettleton", "******")
token = gis._con.token
agol_item = gis.content.get('c0011a3f169b45ca89f3142218fb4f3d') # ArcGIS Online Item ID
agoLayer = agol_item.layers[0]
agoFSet = agoLayer.query()#(where = '1=1')
ago_list = agoFSet.features
#Retrieving the unit numbers that are existing in the ArcGIS Online Feature Service
for exsting_unit in ago_list:
agol_units.append(exsting_unit)
# Updating units
for call in current_units:
if call in agol_units:
#unit_feature = [f for f in ago_list if f.attributes['id'] == call][0]
unit_dict = {"attributes":
{"id":call[0],
"Unit":call[1],
"Status":call[2],
"StatusCategory":call[3],
"StatusRank":call[4],
"OOSReason":call[5],
"StatusChange":call[6],
"Type":call[7],
"Juridiction":call[8].upper(),
"Division":call[9],
"LastUpdate":call[10]},
"geometry":
{"Longitude": call[11], "Latitude": call[12]}}
agoLayer.edit_attributes(updates=[unit_dict])
if __name__ == '__main__':
ODBC_connect()
Portal_push()
print ('Update Complete')
... View more
05-29-2024
03:29 PM
|
4
|
7
|
1562
|
POST
|
Yep, that was that issue. Used someone elses code and accidently removed those lines when editing. Fixed that and now getting cursor error: Possibly not connected to the database correctly? ---------------------------------------------------------------------------
ProgrammingError Traceback (most recent call last)
In [7]:
Line 72: ODBC_connect()
In [7]:
Line 28: records = cursor.fetchall()
ProgrammingError: No results. Previous SQL was not a query. @JustinNettleton1 wrote: I am working on python script that takes data straight from SQL server and update AGO feature service (Hosted table). I keep getting the below syntax error on line 50 but don't understand why. I have made sure all the fields have the correct spelling and case. Anyone have any ideas? Thanks, ---------------------------------------------------------------------------
SyntaxError Traceback (most recent call last)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\ast.py, in parse:
Line 50: return compile(source, filename, mode, flags,
SyntaxError: invalid syntax (<string>, line 72)
--------------------------------------------------------------------------- import pyodbc
import os
from arcgis.gis import GIS
#lists for calls used during the update process
agol_calls = []
current_calls = []
call_numbers = []
# SQL Query being passed through the ODBC connection
SQL_QUERY = """
select id,Unit,Status,Type,Juridiction,Division,LastUpdate
from Reports_Database.dbo.Avail_Units_T
order by Unit
"""
print ('Query Successful')
def ODBC_connect():
##SERVER = 'CADGIS.heartlandcad.net\CADGIS\SQLEXPRESS' # Server FQDN
SERVER = 'CADGIS\SQLEXPRESS' # Server FQDN
DATABASE = 'Reports_Database' # Database Name
## Connection string to pass in pyodbc connection request. Using Trusted_Connect=yes to have SQL Server Native Client ODBC driver use Windows Authentication of the account running the script
## Using the Windows Authentication of the account running the script allows for the use of a Managed Service Account to run the scheduled python script
connectionString = f'DRIVER={{ODBC Driver 17 for SQL Server}};SERVER={SERVER};DATABASE={DATABASE};Trusted_Connection=yes'
conn = pyodbc.connect(connectionString)
cursor = conn.cursor()
cursor.execute(SQL_QUERY)
records = cursor.fetchall()
for r in records:
record = [r.id,r.Unit,r.Status,r.Type,r.Juridiction,r.Division,r.LastUpdate]
current_calls.append(record)
call_numbers.append(r.id)
print ('SQL Connection Successful')
def Portal_push():
user = os.getenv('justin.nettleton') # System Environmental Variable Name for Username
password = os.getenv('******') # System Environmental Variable Name for Password
portal = os.getenv('https://www.arcgis.com') # System Environmental Variable Name for Portal URL
gis = GIS(portal,user,password,use_gen_token=True)
agol_item = gis.content.get('38aabc243aaf4f4ab5c8b9d5600ed173') # ArcGIS Online Item ID
cadLayer = agol_item.layers[0]
cadFSet = cadLayer.query(where = '1=1')
cad_list = cadFSet.features
# Retrieving the call numbers that are existing in the ArcGIS Online Feature Service
for exsting_call in cad_list:
agol_calls.append(exsting_call.attributes['id'])
for call in agol_calls:
if call not in call_numbers:
call_feature = [f for f in cad_list if f.attributes['id'] == call][0]
call_objid = call_feature.get_value('OBJECTID')
cadLayer.edit_features(deletes=str(call_objid))
# Adding Calls
for call in current_calls:
if call[0] not in agol_calls:
call_dict = {"attributes":
{"id":call[0],
"Unit":call[1],
"Status":call[2],
"Type":call[3],
"Juridiction":call[4].upper(),
"Division":call[5],
"LastUpdate":call[6],
cadLayer.edit_features(adds=[call_dict])
if __name__ == '__main__':
ODBC_connect()
Portal_push() import pyodbc
import os
from arcgis.gis import GIS
#lists for calls used during the update process
agol_calls = []
current_calls = []
call_numbers = []
##select id,Unit,Status,Type,Juridiction,Division,LastUpdate
# SQL Query being passed through the ODBC connection
SQL_QUERY = """
select id,Unit,Status,Type,Juridiction,Division,LastUpdate
from Reports_Database.dbo.Avail_Units_T
order by id
"""
print ('Query Successful')
def ODBC_connect():
##SERVER = 'CADGIS.heartlandcad.net\CADGIS\SQLEXPRESS' # Server FQDN
SERVER = 'CADGIS\SQLEXPRESS' # Server FQDN
DATABASE = 'Reports_Database' # Database Name
## Connection string to pass in pyodbc connection request. Using Trusted_Connect=yes to have SQL Server Native Client ODBC driver use Windows Authentication of the account running the script
## Using the Windows Authentication of the account running the script allows for the use of a Managed Service Account to run the scheduled python script
connectionString = f'DRIVER={{ODBC Driver 17 for SQL Server}};SERVER={SERVER};DATABASE={DATABASE};Trusted_Connection=yes'
conn = pyodbc.connect(connectionString)
cursor = conn.cursor()
records = cursor.fetchall()
for r in records:
record = [r.id,r.Unit,r.Status,r.Type,r.Juridiction,r.Division,r.LastUpdate]
current_calls.append(record)
call_numbers.append(r.id)
print ('SQL Connection Successful')
def Portal_push():
user = os.getenv('justin.nettleton') # System Environmental Variable Name for Username
password = os.getenv('******') # System Environmental Variable Name for Password
portal = os.getenv('https://www.arcgis.com') # System Environmental Variable Name for Portal URL
gis = GIS(portal,user,password,use_gen_token=True)
agol_item = gis.content.get('38aabc243aaf4f4ab5c8b9d5600ed173') # ArcGIS Online Item ID
cadLayer = agol_item.layers[0]
cadFSet = cadLayer.query(where = '1=1')
cad_list = cadFSet.features
# Retrieving the call numbers that are existing in the ArcGIS Online Feature Service
for exsting_call in cad_list:
agol_calls.append(exsting_call.attributes['id'])
for call in agol_calls:
if call not in call_numbers:
call_feature = [f for f in cad_list if f.attributes['id'] == call][0]
call_objid = call_feature.get_value('OBJECTID')
cadLayer.edit_features(deletes=str(call_objid))
# Adding Calls
for call in current_calls:
if call[0] not in agol_calls:
call_dict = {"attributes":
{"id":call[0],
"Unit":call[1],
"Status":call[2],
"Type":call[3],
"Juridiction":call[4].upper(),
"Division":call[5],
"LastUpdate":call[6]}}
cadLayer.edit_features(adds=[call_dict])
if __name__ == '__main__':
ODBC_connect()
Portal_push()
... View more
05-16-2024
06:57 PM
|
0
|
0
|
2423
|
POST
|
I am working on python script that takes data straight from SQL server and update AGO feature service (Hosted table). I keep getting the below syntax error on line 50 but don't understand why. I have made sure all the fields have the correct spelling and case. Anyone have any ideas? Thanks, ---------------------------------------------------------------------------
SyntaxError Traceback (most recent call last)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\ast.py, in parse:
Line 50: return compile(source, filename, mode, flags,
SyntaxError: invalid syntax (<string>, line 72)
--------------------------------------------------------------------------- import pyodbc
import os
from arcgis.gis import GIS
#lists for calls used during the update process
agol_calls = []
current_calls = []
call_numbers = []
# SQL Query being passed through the ODBC connection
SQL_QUERY = """
select id,Unit,Status,Type,Juridiction,Division,LastUpdate
from Reports_Database.dbo.Avail_Units_T
order by Unit
"""
print ('Query Successful')
def ODBC_connect():
##SERVER = 'CADGIS.heartlandcad.net\CADGIS\SQLEXPRESS' # Server FQDN
SERVER = 'CADGIS\SQLEXPRESS' # Server FQDN
DATABASE = 'Reports_Database' # Database Name
## Connection string to pass in pyodbc connection request. Using Trusted_Connect=yes to have SQL Server Native Client ODBC driver use Windows Authentication of the account running the script
## Using the Windows Authentication of the account running the script allows for the use of a Managed Service Account to run the scheduled python script
connectionString = f'DRIVER={{ODBC Driver 17 for SQL Server}};SERVER={SERVER};DATABASE={DATABASE};Trusted_Connection=yes'
conn = pyodbc.connect(connectionString)
cursor = conn.cursor()
cursor.execute(SQL_QUERY)
records = cursor.fetchall()
for r in records:
record = [r.id,r.Unit,r.Status,r.Type,r.Juridiction,r.Division,r.LastUpdate]
current_calls.append(record)
call_numbers.append(r.id)
print ('SQL Connection Successful')
def Portal_push():
user = os.getenv('justin.nettleton') # System Environmental Variable Name for Username
password = os.getenv('******') # System Environmental Variable Name for Password
portal = os.getenv('https://www.arcgis.com') # System Environmental Variable Name for Portal URL
gis = GIS(portal,user,password,use_gen_token=True)
agol_item = gis.content.get('38aabc243aaf4f4ab5c8b9d5600ed173') # ArcGIS Online Item ID
cadLayer = agol_item.layers[0]
cadFSet = cadLayer.query(where = '1=1')
cad_list = cadFSet.features
# Retrieving the call numbers that are existing in the ArcGIS Online Feature Service
for exsting_call in cad_list:
agol_calls.append(exsting_call.attributes['id'])
for call in agol_calls:
if call not in call_numbers:
call_feature = [f for f in cad_list if f.attributes['id'] == call][0]
call_objid = call_feature.get_value('OBJECTID')
cadLayer.edit_features(deletes=str(call_objid))
# Adding Calls
for call in current_calls:
if call[0] not in agol_calls:
call_dict = {"attributes":
{"id":call[0],
"Unit":call[1],
"Status":call[2],
"Type":call[3],
"Juridiction":call[4].upper(),
"Division":call[5],
"LastUpdate":call[6],
cadLayer.edit_features(adds=[call_dict])
if __name__ == '__main__':
ODBC_connect()
Portal_push()
... View more
05-16-2024
04:46 PM
|
0
|
4
|
2483
|
POST
|
Thanks for this. This helps. It kind of led me to a knew issue though. I don't want the Closed events to show on the map. I can change the symbol to be blank, but when I click on a feature that is Open, it could have 4 other features under it that are closed and show up in the popup. So is there anyway to just show the date for the Open events on the map and in the popup? I wish they we could just run arcade expressions in the filter tool.
... View more
02-26-2024
03:52 PM
|
0
|
0
|
731
|
POST
|
I have web service that is showing road closures that usually last less than a day. I am trying to find a way to only show the closures on the map that are active, so after the start date/time and before the end date/time. I have been trying to accomplish this by using an arcade symbology expression, but I can't figure out. Says the expression is right but doesn't show the closures I want on the map. Is this the best way to accomplish this? Does anybody have an idea on how to best set up the expression? I have 3 types of date time fields to choose from, I can't figure out any of them out. I have attached an image of the field options I have. Here is one expression I tried with the epoch date fields. //ToLocal(Timestamp()) var started = $feature.closureStartEpoch var closed = $feature.closureEndEpoch var present = date() // if current date/time is greater than or equal to the start time // AND current date/time is less than or equal to the close time // return open, otherwise its closed If (present >= started && present <= closed) { return "Open" If (present <= started && present >= closed) { return "Closed" } } else { return "Other" } These are the Start and End Date/Time fields I have to choose from.
... View more
02-26-2024
11:54 AM
|
0
|
2
|
817
|
POST
|
I have created a model in ArcGIS Pro that takes a csv document, exports the date using XY to points tool, deletes some fields then adds and calculates some fields. When I run this model from the ArcPro model window below, it works just fine. No errors and the table populates just fine. The end product I am looking for, is to schedule the model to run several times a day to update this layer. I then have a different python script that update a web service in AGO. That portion works just fine. I just can't get the data to that point. The issue I am having is when I try to run the model from the Geoprocessing tool or try to schedule, it to run in task scheduler, it corrupts the table and I get this error. The model says it runs just fine, but get this image below when I try to open the table. Any one have any ideas on why this would be happening or different ways to go about this? I am using. ArcPro 3.1.3 Thanks, Justin Nettleton
... View more
02-08-2024
02:07 PM
|
0
|
1
|
636
|
POST
|
Thank you for these solutions. They have helped the performance.
... View more
08-25-2022
11:15 AM
|
0
|
0
|
1059
|
POST
|
I am setting up some attribute rules to populate fields in my NG911 address database. A Lot of these fields are populated off of interests of 3 different polygon layers. I have them all set up as multiple rules now and they are working, but editing is very slow. I know I can combine these rules into one, just not sure how to do it when I am intersecting multiple layers to populate different fields. Can some one point me in the right direction or have a sample for me? Thanks, Justin
... View more
08-23-2022
12:13 PM
|
0
|
3
|
1103
|
Title | Kudos | Posted |
---|---|---|
1 | 06-03-2024 02:48 PM | |
4 | 05-29-2024 03:29 PM | |
1 | 05-18-2021 09:26 AM |
Online Status |
Offline
|
Date Last Visited |
a month ago
|