POST
|
Hi. Our organization is still using ArcMap and geometric network. I am using the Add Laterals from Line Locations tool to create different type of connections. I was able to configure the config file to create fire hydrant assemblies, but road block I am encountering is that the hydrant assembly gets created to a defined direction from the main. An example of this is the water main runs north-south and when I use the Add Laterals from Line Location tool the hydrant gets created to the east but I need it to the west of the main. Anyone knows how to change direction on this tool?
... View more
02-27-2024
08:44 AM
|
0
|
0
|
164
|
POST
|
Hi @BobBooth1, It slows down at the "Exporting attachments" section. I checked the folder the attachments get saved to and they do save but at a very slow rate. After about an hour and a half I canceled the process and used a machine using Python 3.7.11. I will do some research and look for the code to add timing print statements. Thank you!
... View more
02-08-2024
08:33 AM
|
0
|
0
|
144
|
POST
|
Hello, I updated ArcGIS Pro from 2.9.10 to 3.0.6, thus updating my Python environment from 3.7.11 to 3.9.11. My organization runs a daily script that downloads attachments from ArcGIS Online. The script ran smooth and quick with Python 3.7 (10-15 minutes) but now with 3.9 it takes longer (90 minutes). Any idea why this might be happening? The script is very similar to the one on this guide. import arcgis
from arcgis.gis import GIS
import os, re, csv
import shutil
import pandas as pd
import datetime
from pandas import ExcelWriter
import xlsxwriter
import arcpy
# Varialbles
agolURL = "https://irwd.maps.arcgis.com"
username = ""
password = ""
survey_item_id = "survey"
c_Directory = "O:/Water Resources/Conservation/Water Efficiency Tool/Spot_N_Stop/datasource"
directory = "Survey123"
save_path = "O:/Water Resources/Conservation/Water Efficiency Tool/Spot_N_Stop/datasource/Survey123"
keep_org_item = False
store_csv_w_attachments = False
# Login credential variable
# **Using personal AGOL credentials to log in**
gis = GIS(agolURL, username, password)
survey_item_id = gis.content.get(survey_item_id)
# Create Downloads directory
print('Creating directory.')
arcpy.CreateFolder_management(c_Directory, directory)
downloads_path = os.path.join(c_Directory, directory)
# Overwrite Downloads directory if it exist
if os.path.exists(downloads_path):
shutil.rmtree(downloads_path)
os.mkdir(downloads_path)
print("Directory '% s' created." % directory)
# Survey data exported to excel.
print("Exporting survey data to excel.")
rel_fs = survey_item_id.related_items('Survey2Service', 'forward')[0]
item_excel = rel_fs.export(title=survey_item_id.title, export_format='Excel')
item_excel.download(save_path=save_path)
if not bool (keep_org_item):
item_excel.delete(force=True)
# Survey attachments
print("Exporting attachments.")
layer = rel_fs.layers + rel_fs.tables
for i in layer:
if i.properties.hasAttachments == True:
feature_layer_folder = os.path.join(save_path, '{}_attachments'.format\
(re.sub(r'[^A-Za-z0-9]+', '', i.properties.name)))
# Overwrite survey_attachments folder if it exists.
if os.path.exists(feature_layer_folder):
shutil.rmtree(feature_layer_folder)
os.mkdir(feature_layer_folder)
if bool(store_csv_w_attachments):
path = os.path.join(feature_layer_folder, "{}_attachments.csv".format(i.properties.name))
elif not bool(store_csv_w_attachments):
path = os.path.join(save_path, "{}_attachments.csv".format(i.properties.name))
csv_fields = ['ObjectID', 'AttachmentPath']
with open(path, 'w', newline='') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerow(csv_fields)
feature_object_ids = i.query(where="1=1", return_ids_only=True, order_by_fields='objectid ASC')
for j in range(len(feature_object_ids['objectIds'])):
current_oid = feature_object_ids['objectIds'][j]
current_oid_attachments = i.attachments.get_list(oid=current_oid)
if len(current_oid_attachments) > 0:
for k in range(len(current_oid_attachments)):
attachment_id = current_oid_attachments[k]['id']
current_attachment_path = i.attachments.download(oid=current_oid, attachment_id=attachment_id, save_path=feature_layer_folder)
csvwriter.writerow([current_oid, os.path.join('{}_attachments'.format(re.sub(r'[^A-Za-z0-9]+', '', i.properties.name)), os.path.split(current_attachment_path[0])[1])])
# Joining the two excel files
print("Joining excel tables.")
testSurvey = pd.read_excel('O:/Water Resources/Conservation/Water Efficiency Tool/Spot_N_Stop/datasource/Survey123/Log-a-Leak.xlsx')
surveyAttach = pd.read_csv('O:/Water Resources/Conservation/Water Efficiency Tool/Spot_N_Stop/datasource/Survey123/survey_attachments.csv')
fileJoin = testSurvey[['ObjectID', 'GlobalID', 'CreationDate', 'Creator', 'EditDate', 'Editor', 'Name (optional)', 'Phone number (optional)', 'Email (optional)', 'Leak type', 'Date and time when the issue occurred' ,'x', 'y']].merge(surveyAttach[['ObjectID', 'AttachmentPath']], on = 'ObjectID', how = 'left')
# Creating new file
print('Creating new file from joins.')
#surveyResults = 'C:/Downloads/Survey123/Results_Join.xlsx'
#fileJoin.to_excel(surveyResults, index = False)
surveyResults = pd.ExcelWriter('O:/Water Resources/Conservation/Water Efficiency Tool/Spot_N_Stop/datasource/Survey123/Results_Join.xlsx', engine='xlsxwriter')
fileJoin.to_excel(surveyResults, sheet_name='Survey123' ,index = False)
surveyResults.save()
# Adding hyperlink
print("Adding hyperlink.")
df = pd.read_excel(surveyResults)
#df['AttachmentPath'] = '=HYPERLINK("O:\\Water Resources\\Conservation\\Water Efficiency Tool\\Spot_N_Stop\\datasource\\Survey123\\' + df["AttachmentPath"] + '")'
df['AttachmentPath'] = 'O:\\Water Resources\\Conservation\\Water Efficiency Tool\\Spot_N_Stop\\datasource\\Survey123\\' + df["AttachmentPath"]
df.to_excel('O:/Water Resources/Conservation/Water Efficiency Tool/Spot_N_Stop/datasource/Survey123/SurveyData.xlsx', index=False)
# Deleting files
print('Deleting files.')
deleteSurvey = 'O:/Water Resources/Conservation/Water Efficiency Tool/Spot_N_Stop/datasource/Survey123/Log-a-Leak.xlsx'
deleteAttachments = 'O:/Water Resources/Conservation/Water Efficiency Tool/Spot_N_Stop/datasource/Survey123/survey_attachments.csv'
deleteJoinedResults = 'O:/Water Resources/Conservation/Water Efficiency Tool/Spot_N_Stop/datasource/Survey123/Results_Join.xlsx'
deleteFiles = (deleteSurvey, deleteAttachments, deleteJoinedResults)
for file in deleteFiles:
if os.path.exists(file):
os.remove(file)
print('Removing ' + file.title())
else:
print(file.title() + ' does not exist.')
print('Process complete!')
... View more
02-07-2024
12:19 PM
|
0
|
2
|
230
|
POST
|
@BrettBlankner my organization moved from 10.5.1 to 2022 and did not lose the loaded licenses.
... View more
01-22-2024
02:35 PM
|
0
|
0
|
365
|
POST
|
Hi Mike, I updated the code as best as I could as shown below. I am receiving the following error "Invalid expression. Error on line 8. Expected convertable to geometry." var valves = FeatureSetByName($datastore, "dwSystemValve");
var fireLines = FeatureSetByName($datastore, "dwLateralLine");
var intersecting_lines = First(Intersects(fireLines, $feature));
// valves_to_update = [];
// for (var lat_line in intersecting_lines)
var intersecting_valves = Intersects(valves, fireLines);
for(var valve in intersecting_valves){
push(valves_to_update, {'globalID':valve.globalid,
'attributes': {
'num': lat_line.num
}})
}
return {
'edit': [{
'className': 'valve',
'updates': valves_to_update
}]
}
... View more
01-22-2024
10:07 AM
|
0
|
1
|
107
|
POST
|
@MikeMillerGIShydrants are connected to only one line.
... View more
01-18-2024
12:18 PM
|
0
|
3
|
416
|
POST
|
@Ed_ A lot of this was from other code I found in other forums. I thought applied to what I am trying to accomplish so I was testing it out.
... View more
01-17-2024
02:22 PM
|
0
|
0
|
487
|
POST
|
Getting an error, "Invalid expression. Error on line 11. Close parenthesis expected." Not sure why since I see the closed parenthesis in line 14. I am a bit of a novice so not sure what to look for now. I appreciate your time and effort on this @MikeMillerGIS .
... View more
01-17-2024
02:13 PM
|
0
|
1
|
184
|
POST
|
Hi Mike, I want this to run each time I add or edit a hydrant.
... View more
01-17-2024
09:51 AM
|
0
|
0
|
612
|
POST
|
Hello, My organization is moving from Geometric Network to Utility Network and that means we have to move all of our Attribute Assistant methods to Attribute Rules. I was hoping to get assistance on one of them. We number fire hydrants based on the corresponding valve. Both points are on the same line and that is the only relationship between them. All three features (hydrant, valve, and line) are in the same geodatabase. The attached code I am running comes up with an error mentioning "Invalid expression. Error on line 5. Wrong number of arguments." Hoping to get some help on this. var valves = FeatureSetByName($datastore, "dwSystemValve");
var hydrants = FeatureSetByName($datastore, "dwHydrant");
var fireLines = FeatureSetByName($datastore, "dwLateralLine");
var intersectingValve = Intersects(valves, fireLines, true);
var intersectingHydrant = Intersects(hydrants, fireLines, true);
var commonFireLine = Filter(intersectingValve, intersectingHydrant);
var valveField = "NUM";
var hydrantField = "NUM";
var result = {};
for (var i in commonFireLine) {
var valveValue = commonFireLine[i].attributes[valveField];
var hydrantValue = commonFireLine[i].attributes[hydrantField];
result[valveValue] = hydrantValue;
}
result
... View more
01-17-2024
09:33 AM
|
1
|
13
|
751
|
POST
|
Hi @jcarlson This is the closest thing to what I need to do and I am hoping you can help me out here. Is it possible to do a double intersect? My organization is moving to Utility Network and we need to recreate all the Attribute Assistant methods into Attribute Rules. The specific one we are stuck on is copying hydrant numbers from valve number. There is no relationship between them except that they are snapped to the same fire lateral line. All layers reside in the same SDE database. Hope you can help. Thank you for being a contributor.
... View more
01-15-2024
03:59 PM
|
0
|
0
|
1478
|
POST
|
Hello all. I hope you are staying safe in this crazy 2020. I came back to this issue I was having and discovered that my results were being exported to a csv. What I found out is that it is being exported the path where I have the .py file saved (B:\Scripts\Python\CCTV). I would like to save it to a different path (B:\Planning\GIS\CCTV) but after searching I have not been able to find the right code. Below is the updated code # Exporting relevant fields from CCTV Access (Master PACP 1.mdb) table to csv.
import pyodbc
import csv
import pandas as pd
# MS Access DB connection
print("Connecting to database.")
pyodbc.lowercase = False
conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};' +
r'DBQ=B:\Planning\GIS\CCTV\MASTER PACP 1.MDB;')
# Open cursor and execute SQL
print("Executing SQL.")
cursor = conn.cursor()
cursor.execute('select P_PipeID, P_ChangeDate, P_CreateDate, P_UpNumber, P_DownNumber, P_LocationDetails,\
P_Material, P_PlaceName, P_RoadName, P_ScheduleLength, P_Size, P_YearLaid FROM T_PIPES');
# Open csv and iterate through results.
print("Converting to csv.")
with open('PIPES.csv', 'w', newline='') as f:
writer = csv.writer(f)
for row in cursor.fetchall():
writer.writerow(row)
#writer.writerow([row[0], row[2]])
cursor.close()
conn.close()
# Adding headers to csv
print("Adding header to PIPES.csv.")
with open('PIPES.csv', newline='') as f:
r = csv.reader(f)
data = [line for line in r]
with open('PIPES.csv', 'w', newline='') as f:
w = csv.writer(f)
w.writerow(['PipeID', 'ChangeDate', 'CreateDate', 'UpManhole', 'DownManhole', 'LocationDetail',\
'Material', 'PlaceName', 'RoadName', 'Length', 'Size', 'YearInstall'])
w.writerows(data)
df = pd.read_csv('PIPES.csv')
df['SLID'] = df['UpManhole'] + df['DownManhole']
print("Done")
... View more
11-30-2020
04:48 PM
|
0
|
0
|
2952
|
POST
|
Krishan, Try removing the space in your output feature class. Instead of "bridge location" try "bridgelocation" or "bridge_location". Hope this helps.
... View more
08-26-2020
10:56 AM
|
2
|
1
|
924
|
POST
|
Thanks for contributing Jeff. I get the attached error on the following line writer.writerow(['Upstream Manhole', 'Downstream Manhole'])
... View more
03-13-2020
01:46 PM
|
0
|
1
|
2958
|
POST
|
Randy, your updated code worked. But it concatenates the fields. And I confirmed, the Access I have is 64 bit and I am using the conda package that comes with ArcGIS Pro.
... View more
03-13-2020
01:40 PM
|
0
|
0
|
2958
|
Title | Kudos | Posted |
---|---|---|
1 | 01-17-2024 09:33 AM | |
2 | 08-26-2020 10:56 AM |
Online Status |
Offline
|
Date Last Visited |
02-28-2024
07:02 PM
|