|
POST
|
Edit: I didn't notice at first and still can't quite tell if you are actually implementing jcornet's solution from GitHub, but it looks to be pretty close to what you need. Just publish the GP service on your ArcGIS Server and it looks like they also supply a widget (I think that's what it is) you can add to your WAB solution. There's likely a few things to consider but without looking at anything specific you have it will be difficult to locate the issue(s) you've run into. Just some things to keep in mind: 1. Perhaps there is an alternative way to perform your task client-side. I'd personally go down the path of just building a new widget that you can add to the WAB app. The JavaScript API is quite powerful but you'd have to migrate everything to that language and I'm unsure if all of the tools you'd need are available but it's probably worth the time to investigate. 2. I do beleive the ArcGIS Server would need to be setup to allow uploads (your csv), although I have not gone down this route to see what is involved. 3. I see that there is an input parameter type "File" available. That's where I'd start. 4. The output parameter should be set to Feature Layer. 5. Perform the conversion from your CSV to Featuer Layer and then create an arcpy.FeatureSet variable that you would set the output parameter to. feature_class = "tmpfc"
arcpy.Clip_analysis(lyr1, lyr2, feature_class)
feature_class_lyr = arcpy.MakeFeatureLayer_management (feature_class, "feature_class_lyr")
feature_set = arcpy.FeatureSet(feature_class)
arcpy.SetParameter(1, feature_set) 6. Run the tool in ArcMap and see if it successfully adds your feature layer to the TOC. If so, publish it. 7. Add the Geoprocessing widget to your WAB and specify the url pointing to the GP service you just published and it should automatically understand the input/output parameters required.
... View more
04-05-2017
06:43 AM
|
1
|
0
|
1404
|
|
POST
|
Our organization has implemented ZScaler security across the internal environment and it seems to intermittently affect our WAB deployments. Our WAB apps are built with WAB Developer v2.3 (the non-"hosted" WAB developer) and deployed to our own IIS or JBOSS servers, which of course have items referenced on our Organizational AGOL account and their redirect url's pointing to where the WAB is deployed. There is no issue with the workflow where a user must go to our AGOL site, login, locate the WAB application and then launch/open it. The problem is when we are opening the WAB app from a hyperlink or from some other web-based application -- the blue startup screen of the WAB app will appear but it never loads, I suspect because it cannot validate authentication. It seems to be totally random for some and a rare occurrence for others. However it never fails to happen during demo's and presentations! The solution has been to clear the browser cache, navigate to some other site and invoke the ZScaler login challenge. After this is completed the WAB app will then launch from the link as originally intended. This however is not an acceptable workflow and I'm hoping to find some alternative solutions: is there some setting on ZScaler that can be applied? Any input is greatly appreciated!
... View more
04-04-2017
10:32 AM
|
0
|
5
|
4378
|
|
POST
|
I get an error running your .json sample ValueError: Expecting : delimiter: line 1 column 14 (char 13) filename = r'H:\input.json'
with open(filename, 'r') as fp:
jData = json.loads('{ "features" " ' + fp.read().decode("utf-8-sig").encode("utf-8") + '}')
print json.dumps(jData, indent=4, sort_keys=False) This happens with the input.json sample you provided as well as the contents of the .json file I am working with: [
{
"Arrow Size": "0.60",
"Color": "icon20",
"Date": "March 3, 2017",
"Desciption": "ff00ffff",
"Flow": "80",
"Heading": "315",
"Lat": "46.60",
"Long": "-50.44",
"Name": "Some Name1",
"table": "<TABLE>\n<tr><td>G310-P:</td><td style=\"text-align: right\">84 cfs; Mar 2, 17</td></tr>\n<tr><td>G251-P:</td><td style=\"text-align: right\">0 cfs; Mar 2, 17</td></tr>\n</TABLE><a href=\"http://my.sfwmd.gov/dbhydroGraph/servlet/DbhydroGraphServlet.do?v_report_type=format6&v_period=1week&v_dbkey=64308/64267/65115\">Hydrograph</a>"
},
{
"Arrow Size": "0.60",
"Color": "icon20",
"Date": "March 3, 2017",
"Desciption": "ff00ffff",
"Flow": "80",
"Heading": "315",
"Lat": "42.30",
"Long": "-53.42",
"Name": "Some Name2",
"table": "<TABLE>\n<tr><td>G310-P:</td><td style=\"text-align: right\">84 cfs; Mar 2, 17</td></tr>\n<tr><td>G251-P:</td><td style=\"text-align: right\">0 cfs; Mar 2, 17</td></tr>\n</TABLE><a href=\"http://my.sfwmd.gov/dbhydroGraph/servlet/DbhydroGraphServlet.do?v_report_type=format6&v_period=1week&v_dbkey=64308/64267/65115\">Hydrograph</a>"
},
{
"Arrow Size": "0.60",
"Color": "icon20",
"Date": "March 3, 2017",
"Desciption": "ff00ffff",
"Flow": "80",
"Heading": "315",
"Lat": "45.50",
"Long": "-55.44",
"Name": "Some Name3",
"table": "<TABLE>\n<tr><td>G310-P:</td><td style=\"text-align: right\">84 cfs; Mar 2, 17</td></tr>\n<tr><td>G251-P:</td><td style=\"text-align: right\">0 cfs; Mar 2, 17</td></tr>\n</TABLE><a href=\"http://my.sfwmd.gov/dbhydroGraph/servlet/DbhydroGraphServlet.do?v_report_type=format6&v_period=1week&v_dbkey=64308/64267/65115\">Hydrograph</a>"
}
]
... View more
04-03-2017
06:27 AM
|
0
|
4
|
7153
|
|
POST
|
Good stuff. I appreciate it and will try to implement something today!
... View more
04-03-2017
06:11 AM
|
0
|
0
|
2296
|
|
POST
|
I appreciate it. However, I don't see where you are starting your input.json file from. In my OP above, that's what I'm starting with and I need to get it into the geoJSON format that you show! Interestingly, I cannot seem to access individual attributes like you are showing either. I get this error when I try to access the "Name" attribute: TypeError: string indices must be integers, not str But it validates in a JSON formatter tool. This is what I have so far that will convert a csv file into the JSON output I posted in my OP: csvfile = open('H:\MyFile.csv', 'r')
reader = csv.DictReader(csvfile)
fieldnames = ('Name', 'Flow', 'Arrow Size', 'Date', 'Lat', 'Long', 'Heading', 'Color', 'Desciption', 'table')
output = []
for each in reader:
row = {}
for field in fieldnames:
if not field == 'Coords':
row[field] = each[field]
output.append(row)
jData = json.dumps(output)
json.dump(output, jsonfile, indent=2, sort_keys=True)
... View more
03-31-2017
01:42 PM
|
0
|
8
|
7153
|
|
POST
|
What do you think would be the best plan of attack on this one? 1. Attempt to churn the supplied JSON into a well-formatted esri-JSON object, minus that table column. 2. Just parse out the table column into new columns, effectively just making them new attribute fields. I'm thinking for now I should just go with the #2 option to manipulate the csv and just convert that to a feature class. Open to suggestions.
... View more
03-31-2017
10:09 AM
|
0
|
1
|
7153
|
|
POST
|
That "tables" originally comes in as a string (really it's an html table stored in that column of the csv file) and I had converted it to a list like that. If it's a problem then I can revert it back to its original string value and deal with it later (as you suggested, make it it's own table).
... View more
03-30-2017
12:18 PM
|
0
|
0
|
7153
|
|
POST
|
I've been provided a JSON output in the sample below and tasked with getting this into a point feature class somehow. [
{
"Name": "w1",
"Long": "-60.44",
"Lat": "21.60",
"table": [
[
"G310-P:",
"84 cfs; Mar 2, 17"
],
[
"G251-P:",
"0 cfs; Mar 2, 17"
]
],
"Heading": "315"
},
{
"Name": "w2",
"Long": "-60.32",
"Lat": "21.63",
"table": [
[
"S362-P:",
"136 cfs; Mar 2, 17"
]
],
"Heading": "0"
},
{
"Name": "w2",
"Long": "-60.35",
"Lat": "21.37",
"table": [
[
"S10A-C:",
"0 cfs; Mar 2, 17"
],
[
"S10C-C:",
"0 cfs; Mar 2, 17"
],
[
"S10D-C:",
"0 cfs; Mar 2, 17"
]
],
"Heading": "20"
}
] I have some existing processes that get close but hoped to run it by the community to see if someone spots the obvious solution before I dillydally down the wrong path for too long. In the JSON sample above, I have Lat/Lon attributes that I would need to get into an array in order to use this def() to convert it to something closer to what I need. My first thought is to create a new attribute called 'rings' so that it would just work with my geo_convert() def: def geo_convert(ring_string):
from json import loads, dumps
rings = loads(ring_string)
feat_coll = {'type': 'FeatureCollection',
'features':[]}
for ring in rings:
feat_coll['features'].append(
{'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': ring['rings'][0]
}})
return dumps(feat_coll) Any ideas on what I could do?
... View more
03-30-2017
10:37 AM
|
0
|
15
|
12841
|
|
POST
|
The Feature Class is a source to a GP service and it needed to be stopped in order to run this script.
... View more
03-29-2017
10:46 AM
|
0
|
0
|
1148
|
|
POST
|
They're just input parameters. I could manually set these to some value and still get the same behavior. However, the issue I was having was due to the fact that this is the source to a GP service and it needed to be stopped in order to run this script. Thanks for your input
... View more
03-29-2017
10:45 AM
|
0
|
0
|
1148
|
|
POST
|
Can anyone spot an issue with the codeblock? I'm not exactly sure what occurred but this was working on Monday, I was out all-day Tuesday, and now Wednesday (today) the script fails to update, there are no errors and simply "hangs" and I must kill the PythonWin session. The sde database that this Feature Class is in is for non-versioned editing. ws = r'\\path_to_conn_file\my_conn_file.sde'
fcname = r'schema.FEATURE_CLASS_NAME'
input_fc = os.path.join(ws, fcname)
input_fc_sql = "APP_ID='" + inputAppId.strip().upper() + "'"
#check for a matching appId and set successmsg parameter for return JSON
test = [trow[0] for trow in arcpy.da.SearchCursor(input_fc, ['APP_ID'], input_fc_sql)]
if len(test) > 0:
##open edit session
edit = arcpy.da.Editor(ws)
edit.startEditing(False, False)
edit.startOperation()
with arcpy.da.UpdateCursor(input_fc, ['REVIEW_STATUS', 'PERMIT_ID', 'PERMIT_TYPE', 'PERMIT_SUBTYPE', 'PROJECT_NAME'], input_fc_sql) as ucur:
for urow in ucur:
urow[0] = inputStatus.strip().upper()
urow[1] = inputPermitId.strip().upper()
urow[2] = inputPermitType.strip().upper()
urow[3] = inputPermitSubType.strip().upper()
urow[4] = inputProjectName.strip().upper()
ucur.updateRow(urow) #seems to hang here and does not go to print statement below
print "step 1"
## Stop the edit operation.
edit.stopOperation()
## Stop the edit session and save the changes
edit.stopEditing(True)
... View more
03-29-2017
08:10 AM
|
0
|
3
|
1890
|
|
POST
|
Not a complete solution but might be something to look into. numpy and pandas have much better grouping functions. Challenge is to get the result back into your arcpy.da cursor and update the desired column. nparr = arcpy.da.FeatureClassToNumPyArray(fc,["Account", "Acres"])
pdarr = pd.DataFrame(nparr)
counts = pdarr.groupby(["Account", "Acres"]).size()
pddups = pd.DataFrame(counts, columns = ['size'])
pddups = pddups[pddups.size>1]
print pddups
... View more
03-24-2017
07:36 AM
|
0
|
0
|
3868
|
|
POST
|
fc = r'H:\Documents\ArcGIS\Default.gdb\MyFeatureClass'
fields= ["OBJECTID", "Field1", "Field2"]
with arcpy.da.SearchCursor(fc, fields) as cursor:
for row in cursor:
if row[1]==row[2]:
sql = "OBJECTID=" + str(row[0])
with arcpy.da.UpdateCursor(fc, "Field3", sql) as ucur:
for urow in ucur:
urow[0]=0
ucur.updateRow(urow)
... View more
03-23-2017
10:36 AM
|
1
|
2
|
3868
|
|
POST
|
I'm typically using the numpy and pandas libraries and they have good export/saveas functionality. Just convert your Feature Class to a numpy array and then save it to csv. import numpy
import pandas as pd
fc = r'H:\Documents\ArcGIS\Default.gdb\MyFeatureClass'
nparr = arcpy.da.FeatureClassToNumPyArray(fc,['Field1', 'Field2', 'Field3'])
pdarr = pd.DataFrame(nparr)
pdarr.to_csv(r'H:\nparr.csv')
... View more
03-23-2017
08:45 AM
|
3
|
1
|
5574
|
| 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
|