|
POST
|
My survey was created in Survey123 Connect and is intended for use in the web app. The end-user is required to put in their address. This may sound like a silly question, but is there a way to geocode the survey submissions based on the address field(s)? I'm not including a map question. Right now the points are at 0,0. I'm interested in having the points geocoded because internally there will be an app with the ability to export the features (using the select widget). And, it wouldn't look right when viewing the app if the points were not in their correct locations.
... View more
12-03-2021
10:54 AM
|
1
|
3
|
3081
|
|
POST
|
Have you tried this? I would test it in Pro, but I'm all of a sudden getting Kernel Error, and none of my Notebooks are working... Apparently, It won't work in a stand-alone. You'd have to run it in a Pro Notebook or console. import arcpy
aprx = arcpy.mp.ArcGISProject('CURRENT')
print(aprx.activeMap) Taken from: https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject-class.htm
... View more
11-24-2021
02:22 PM
|
1
|
0
|
2926
|
|
POST
|
I've been experimenting with the FeatureSharingDraft class. It works fine accessing map objects indiscriminately, and one at a time. However, I'm trying to access specific objects (layers) in an if statement. Then I want them to overwrite the corresponding feature services using the service_names list. In my if statement I'm able to find the selected_layer and assign it. However, I'm looking for some help to plug it into the FeatureSharingDraft part of the code. And I also don't think my service_name variable is doing much outside the maps loop, as I'm not sure how to include it. In a nutshell, I want to be able to iterate the service_names list and overwrite the service with the selected_layer from each of the maps in my Pro project. #existing service names in my AGOL
service_names = ['Elementary Districts Vacc Rate Tot Pop','Elementary Districts Vacc Rate 12 to 18','Elementary Districts Vacc Rate 0 to 18',
'Elementary Districts Vacc Rate 11 to 14','Elementary Districts Vacc Rate 14 to 16','Elementary Districts Vacc Rate 16 to 18',
'Elementary Districts Vacc Rate 19 to 64','Elementary Districts Vacc Rate 65 Plus']
# Set output file names
outdir = r"C:/Users/jpilbeam"
for service_name in service_names:
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)
'''For each map in the Pro project,
grab the selected_layer and overwrite the service from the service_name list'''
# Reference maps
maps = aprx.listMaps()
for m in maps:
for selected_layer in m.listLayers():
if selected_layer.name.endswith('Elementary'): #<--look for selected layer in map
print(f'layer: {selected_layer}')
#---------FeatureSharingDraft------------------
# Create FeatureSharingDraft and set overwrite property
server_type = "HOSTING_SERVER"
# returns a map class object based on service_type selected
sddraft = m.getWebLayerSharingDraft(server_type, "FEATURE", service_name) #<--map class function
sddraft.overwriteExistingService = True
# Create and save to service definition draft file
# returns location and name of sddraft
sddraft.exportToSDDraft(sddraft_output_filename)
# Convert to service definition (.sd) file. Staging compiles all necessary info needed to sucessfully publish
print("Start Staging")
arcpy.StageService_server(sddraft_output_filename, sd_output_filename)
# take .sd file, copy it onto server, extract required info and publish
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, server_type)
print("Finish Publishing") I have tried putting selected_layer in the getWebLayerSharingDraft() function as a parameter, but it doesn't ultimately overwrite the feature service. Rather, it publishes a new one. sddraft = prj.getWebLayerSharingDraft(server_type, "FEATURE", service_name, [selected_layer])
sddraft.overwriteExistingService = True
... View more
11-24-2021
01:45 PM
|
0
|
2
|
1796
|
|
POST
|
It doesn't look like anyone has mentioned this help page: https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/featuresharingdraft-class.htm The FeatureSharingDraft class allows you to create a service definition draft file (.sddraft) for a web feature layer that copies all data to either ArcGIS Enterprise or ArcGIS Online. I needed to overwrite an existing feature service in AGOL. I adapted one of the code examples from the help page. I'm referencing a map layer within a Pro project from a stand-alone script. import arcpy
import os
'''
Publish a layer
The following script publishes a layer in a map as a web feature layer to a portal.
'''
# Sign in to portal
arcpy.SignInToPortal("https://gis.maps.arcgis.com/", "user", "pass")
arcpy.env.overwriteOutput = True
# Set output file names
outdir = r"C:/Users/folder"
service_name = "TEST"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)
# Reference layers to publish
aprx = arcpy.mp.ArcGISProject(r"\pathto\Project.aprx")
m = aprx.listMaps('Tot Pop')[0]
selected_layer = m.listLayers()[0]
print(selected_layer)
# selected_table = m.listTables()[0]
# Create FeatureSharingDraft and set overwrite property
server_type = "HOSTING_SERVER"
sddraft = m.getWebLayerSharingDraft(server_type, "FEATURE", service_name, [selected_layer])
sddraft.overwriteExistingService = True
# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)
# Stage Service
print("Start Staging")
arcpy.StageService_server(sddraft_output_filename, sd_output_filename)
# Share to portal
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, server_type)
print("Finish Publishing")
... View more
11-18-2021
01:31 PM
|
1
|
4
|
4680
|
|
POST
|
Here's the updated link: https://desktop.arcgis.com/en/arcmap/latest/tools/server-toolbox/stage-service.htm Also, for anyone here looking for the Pro help doc page: https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/featuresharingdraft-class.htm
... View more
11-18-2021
01:05 PM
|
2
|
0
|
2863
|
|
POST
|
I second @CarstenB_orsted . This worked for signing in to AGOL: # Sign in to AGOL
arcpy.SignInToPortal("https://wcountygis.maps.arcgis.com/", "user", "pass")
arcpy.SignInToPortal(r"https://wcountygis.maps.arcgis.com/", "user", "pass") This didn't work: arcpy.SignInToPortal("https://wcountygis.maps.arcgis.com/home", "user", "pass")
arcpy.SignInToPortal(r"https://wcountygis.maps.arcgis.com/home", "user", "pass")
... View more
11-18-2021
11:43 AM
|
1
|
1
|
4664
|
|
POST
|
Above is Survey123 Connect. Below is the web version. How do I remove the grey boxes that (kind of) surround the questions in the web version? It looks good in Connect. Below are my settings in the XLSForm.
... View more
11-04-2021
11:14 AM
|
0
|
0
|
718
|
|
POST
|
Josh, The carpetyards field is an integer type. It wasn't (isn't) working in S123 Connect, but it is in the web app. Go figure. But, I guess I have a new problem. It isn't showing decimals? I'm no good at math, but my calculator tells me 66 * 84.4 / 2000 = 2.78.
... View more
10-27-2021
10:58 AM
|
0
|
2
|
2999
|
|
POST
|
Is it not possible to do this? ${carpetyards} * 84.4 div 2000 I'm not getting an error but I'm also not getting a result.
... View more
10-27-2021
09:31 AM
|
0
|
4
|
3014
|
|
POST
|
Interestingly, all I had to do was change arcpy.GetParameterAsText() to arcpy.GetParameter(). Then I didn't even have to bother with later changing the value to a float.
... View more
10-22-2021
08:32 AM
|
1
|
0
|
3735
|
|
POST
|
You need to use 'equal to'. You have 'equals'. if WATER == "1":
... View more
10-22-2021
08:07 AM
|
2
|
0
|
1931
|
|
POST
|
OK, I was too focused on one part of the script. The snippet I had posted above was the section of code that takes the users input and puts it into a variable. Then there is the other part of the script the assigns that input to the upperBound element of the symbology. This is what I needed to convert to a float! Thanks for your answers. import arcpy, sys
aprx = arcpy.mp.ArcGISProject('CURRENT')
#make sure fields in list are in same order as maps in project
fields = ['VaccPercentageTotPop', 'VaccPercentage11to14', 'VaccPercentage0to18', 'VaccPercentage12to18',
'VaccPercentage14to16', 'VaccPercentage16to18', 'VaccPercentage19to64', 'VaccPercentage65Plus']
c = 0 #use counter to give a number to each map in for loop
for map in aprx.listMaps():
arcpy.AddMessage(f'--- map: {map.name} ---')
layers = map.listLayers()
for layer in layers:
arcpy.AddMessage(f'layer: {layer.name}')
sym = layer.symbology
#Reset renderer
sym.updateRenderer('SimpleRenderer')
sym.updateRenderer('GraduatedColorsRenderer')
if hasattr(sym, 'renderer') and layer.name.startswith('BaseLayer'):
Renderer = sym.renderer
Renderer.classificationField = fields[c]
#class break values
classbreakvalues = arcpy.GetParameterAsText(0)
breakvalues_list = classbreakvalues.split(";")
new_breakvalues_list = []
for brkvalues in breakvalues_list:
newbreak = brkvalues
arcpy.AddMessage(f'break value: {newbreak}')
new_breakvalues_list.append(newbreak)
classBreakValues = new_breakvalues_list
#class break labels
classbreaklabels = arcpy.GetParameterAsText(1)
breaklabels_list = classbreaklabels.split(";")
classBreakLabels = breaklabels_list
# Run the Renderer.breakCount function to use the classBreakValues
# array parameters as the values, and create a counter.
Renderer.breakCount = len(classBreakValues)
i = 0
for brk in Renderer.classBreaks:
brk.upperBound = float(classBreakValues[i]) #<-- Convert this to float
arcpy.AddMessage(f'upper bound in symbology: {brk.upperBound}')
brk.label = classBreakLabels[i]
i+=1
layer.symbology = sym
c+=1
... View more
10-20-2021
02:33 PM
|
0
|
0
|
3780
|
|
POST
|
All three of the following arrangements in the code are successful when running them from the script tool. But, not one of them change the break value to a decimal in the layer's symbology. This leads me to believe something is up with the tool. #Results in neither decimal in layer symbology nor print statement
for brkvalues in breakvalues_list:
newbreak = int(float(brkvalues))
arcpy.AddMessage(f'newbreak: {newbreak}')
#prints these values
#break value: 40
#break value: 45
#break value: 60
#break value: 100
#No decimal in layer symbology, but decimal in print statement
for brkvalues in breakvalues_list:
newbreak = float(brkvalues)
arcpy.AddMessage(f'break value: {newbreak}')
#prints these values
#break value: 40
#break value: 45
#break value: 60.9
#break value: 100
#No decimal in layer symbology, but decimal in print statement
from decimal import Decimal
for brkvalues in breakvalues_list:
newbreak = Decimal(brkvalues)
arcpy.AddMessage(f'break value: {newbreak}')
#prints these values
#break value: 40
#break value: 45
#break value: 60.9
#break value: 100
... View more
10-20-2021
11:29 AM
|
0
|
0
|
3785
|
|
POST
|
Using newbreak = float(brkvalues) also does something with the highest value in a particular field. I set the last upper break value to be 100 in the tool parameters before I ran it. But, for some reason its grabbing the highest value in a particular layer's table and setting it as the last upper value in the symbology. Here, for example, 69.57 is the highest value in the % Vaccinated - 14-16 field. It ignores my label and it shows a decimal?
... View more
10-19-2021
08:13 AM
|
0
|
0
|
3806
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-25-2026 12:25 PM | |
| 1 | 05-04-2026 08:45 AM | |
| 1 | 04-20-2026 01:20 PM | |
| 1 | 07-24-2025 01:27 PM | |
| 1 | 11-13-2025 08:22 AM |
| Online Status |
Offline
|
| Date Last Visited |
Friday
|