|
POST
|
And it successfully merges after this line? arcpy.Merge_management(fclist, sampevents) The error says it's failing on line 137 arcpy.CalculateField_management(sampevents, "SAMPLE_ID", "[FID] + 1", "VB", "") Which it would be logical if the above failed.
... View more
09-26-2017
12:24 PM
|
0
|
2
|
4150
|
|
POST
|
Could you clarify that you want "SAMPLE" as an output from these possibilities? "SAMPLE NAME" "SAM PLE NAME" " SAM PLE NAME" " SAM PLE NAME "
... View more
09-26-2017
12:17 PM
|
0
|
0
|
5450
|
|
POST
|
Did you try my suggestion to build the sampvents variable?
... View more
09-26-2017
12:14 PM
|
0
|
4
|
4150
|
|
POST
|
Are all of the Feature Classes in "fclist" of the same type? fclist = arcpy.ListFeatureClasses() Also, you may want to see if this is a source/path issue. I've run into that error on SDE feature classes if I simply set a variable reference to the full/complete path and had to break it up and use os.path.join() to build a reference to the feature class. #instead of this
sampevents = "C:\\Projects\\CreateSamples\\SampleFeatureClasses\\Sample_Events"
#try this
ws = r"C:\Projects\CreateSamples\SampleFeatureClasses"
fcname = r"Sample_Events"
sampvents = os.path.join(ws, fcname)
... View more
09-26-2017
12:06 PM
|
2
|
6
|
4150
|
|
POST
|
I'd think split() is a better method as long as the space between the two words is how you identify what to evaluate. That way it doesn't have to be a set number of characters to the left or right. variable = "SAMPLE NAME"
splitVar1 = variable.split()
print splitVar1[0]
... View more
09-26-2017
11:54 AM
|
2
|
6
|
5450
|
|
DOC
|
This widget is incorrectly calculating length values -- we tested a section polygon (640acres) and it shows the perimeter as 3 miles (it should be 4mi). Also, when I added it to an app in WAB Developer 2.5 the config panel doesn't fully load (just spins) but the widget is added to the app (Launchpad theme).
... View more
09-25-2017
10:24 AM
|
0
|
0
|
18487
|
|
POST
|
It's all still contained in an RDBMS with tables storing rows of features/attributes. It just so happens there's a column that holds spatial information. Glad to hear you've worked it out!
... View more
09-25-2017
06:48 AM
|
0
|
0
|
13131
|
|
POST
|
Alternatively... Why are you creating an external process (a .py script/tool) to do this? This seems like it should just run as a time-event on the sql server itself.
... View more
09-22-2017
01:26 PM
|
0
|
0
|
13131
|
|
POST
|
Even easier would be to just convert your Feature Class to a numpy array and export that to .csv. import arcpy
import sys, os
import numpy
import pandas as pd
ws = r'myworkspace.sde'
fcname = r'MyFeatureClass'
input_fc = os.path.join(ws, fcname)
#create the numpy array
narr = arcpy.da.FeatureClassToNumPyArray(input_fc, ("Field1", "Field2", "Field3"))
#I prefer to use pandas to export from. personal preference is all
df = pd.DataFrame(narr)
df.to_csv('H:\somefolder\dfoutput.csv', header=None)
... View more
09-22-2017
11:37 AM
|
1
|
0
|
13131
|
|
DOC
|
I went and implemented an ArcGIS Server solution for overcoming the issue with internet browsers like IE that do not support downloading data from url's. I suppose this could be much easier to implement as a regular web service but I just don't have access to tools needed to build and deploy such a thing. However, as a Geographer I do have the ability to create and deploy Geoprocessing services and that is why I've implemented this approach. The solution consists of: 1. A Geoprocessing Service with two parameters: -Name: "inputSession" | DataType(GPString) | Direction(esriGPParameterDirectionInput) | Parameter Type(esriGPParameterTypeRequired) -Name: "returnFile" | DataType(GPDataFile) | Direction(esriGPParameterDirectionOutput) | Parameter Type(esriGPParameterTypeDerived) 2. A .py script source for the GP Tool. Run the GP Tool in ArcGIS Desktop and publish as you would any GP Service and be sure to set it as a synchronous service. import os
import arcpy
import uuid
inSessionStr = arcpy.GetParameterAsText(0)
output = 'SessionFile_{}.{}'.format(str(uuid.uuid1()), "json")
Output_File = os.path.join(arcpy.env.scratchFolder, output)
outputSessionfile = open(Output_File, 'w')
outputSessionfile.write(inSessionStr)
outputSessionfile.close()
#specify the output parameter as the outputSession file
arcpy.SetParameterAsText(1, Output_File)
3. Update the SaveSession's Widget.js to implement the Geoprocessing. Locate the existing "onSaveToFileButtonClicked" function and replace with: onSaveToFileButtonClicked: function (e) {
if (!this.config.useServerToDownloadFile) {
// skipping since there is no url to submit to
console.log('SaveSession :: onSaveToFileButtonClicked :: saveToFileForm submit canceled.');
return;
}
var sessionString = JSON.stringify(this.sessions);
//execute the GP service with sessionString value
this.executeGPDownloadSessions(sessionString);
}, 3a. Don't forget to add the necessary "esri/tasks/Geoprocessor" reference! 4. Add this function directly below the "onSaveToFileButtonClicked" function (or somewhere that makes sense for you). executeGPDownloadSessions: function (param) {
var gp = new Geoprocessor("https://mydomain/myAGSsite/rest/services/GP/myGPServiceName/GPServer/myGPServiceTaskName");
var params = { "inputSession": param };
gp.execute(params, downloadFile);
function downloadFile(results, messages) {
//do something with the results
var theSessionFile = results[0].value;
window.open(results[0].value.url);
}
}, 5. Be sure to set the widget to use the "Use Server To Download File" and add the address to your GP service url into the "Url for Save To File" box. Now when the SaveToFile link is clicked on the widget, the user will be prompted to "SaveAs" the .json file that is returned from the GP service. Only tested in Chrome and IE.
... View more
09-21-2017
11:32 AM
|
0
|
0
|
17857
|
|
POST
|
Again, the python script works as intended and I just wanted to post the full solution. GP Tool Source Script: import os
import arcpy
import uuid
#GP tool input parameter
inSessionStr = arcpy.GetParameterAsText(0)
#write a to a temp .json file (taken from the enhanced print service blog
output = 'SessionFile_{}.{}'.format(str(uuid.uuid1()), "json")
Output_File = os.path.join(arcpy.env.scratchFolder, output)
#write to the .json file
outputSessionfile = open(Output_File, 'w')
outputSessionfile.write(inSessionStr)
#specify the output parameter as the outputSession file
arcpy.SetParameter(1, outputSessionfile) What the GP Tool looks like: Parameters: inputSession: String returnFile: File JavaScript implemented in a widget: executeGPDownloadFile: function (param) {
var gp = new Geoprocessor("https://mydomain/myserver/rest/services/GPToolName/GPServer/GPTaskName");
var params = { "inputSession": param };
gp.execute(params, downloadFile);
function downloadFile(results, messages) {
//do something with the results
var theSessionFile = results[0].value;
window.open(results[0].value.url);
}
}
... View more
09-21-2017
10:55 AM
|
1
|
0
|
1588
|
|
POST
|
EDIT: Turns out the .py script example I have below does actually create the .json file with the input parameter value. I'm just not correctly handling the JavaScript side to allow user to "SaveAs". Wild idea but *should be* straight forward. I'd like to publish a GP service that simply takes an input string (well formatted json), write that string to a .json file (just a text file would do with a .json extension I think) and set this to an output parameter. What I have so far doesn't error out but also doesn't seem to generate the output .json I'm expecting. Simple python script source to the GP tool: import os
import arcpy
import uuid
#GP tool input parameter
inSessionStr = arcpy.GetParameterAsText(0)
#write a to a temp .json file (taken from the enhanced print service blog
output = 'SessionFile_{}.{}'.format(str(uuid.uuid1()), "json")
Output_File = os.path.join(arcpy.env.scratchFolder, output)
#write to the .json file
outputSessionfile = open(Output_File, 'w')
outputSessionfile.write(inSessionStr)
#specify the output parameter as the outputSession file
arcpy.SetParameter(1, outputSessionfile) Any ideas on if this might work and what to look for?
... View more
09-21-2017
07:23 AM
|
0
|
1
|
2082
|
|
POST
|
Just not totally sure if .mp4 or other media type like that is acceptable. Edit: it works.
... View more
09-20-2017
01:43 PM
|
1
|
0
|
2070
|
|
POST
|
Add attachments to the feature class before publishing the service and they should show up as clickable links on the popup.
... View more
09-20-2017
01:26 PM
|
1
|
3
|
2070
|
|
DOC
|
I hoped to publish a simple GP service that would take an input JSON string, write it into a .json file and then set that as an output parameter but I'm unable to write to any intermediate .txt file that can be set to an output parameter "File" type on the GP tool. import os
import arcpy
inSessionStr = arcpy.GetParameterAsText(0)
outputPath = os.path.join(r"outputSession.json")
outputSessionfile = open(outputPath, 'w')
outputSessionfile.write(inSessionStr)
#specify the output parameter as the outputSession file
outputSession = arcpy.SetParameter(1, outputSessionfile)
... View more
09-20-2017
12:48 PM
|
0
|
0
|
17857
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-17-2020 10:47 AM | |
| 1 | 10-25-2022 11:46 AM | |
| 1 | 08-08-2022 01:40 PM | |
| 1 | 02-15-2019 08:21 AM | |
| 2 | 08-14-2023 07:14 AM |
| Online Status |
Offline
|
| Date Last Visited |
01-22-2025
02:28 PM
|