POST
|
Hi Got an odd one with the charts module and MakeFeatureLayer. Code will work fine if you run it inside the ArcPro py window but if it's outside ArcPro as standalone script or run from inside a GP toolbox script, the result is a catastrophic app crash with the 'please report crash dialog' showing up 😞 basic code: import arcpy
import os
source_fc = "chart-issues.gdb\\pts"
profile_name = "AB"
query_def = "Name='{}'".format(profile_name)
print(query_def)
r_chart_layer = arcpy.management.MakeFeatureLayer(source_fc, "chart_layer", query_def, None, None)
profile_chart = arcpy.charts.Line(
x="M",
y=["Z"],
dataSource = r_chart_layer.getOutput(0),
title="Elevation Over Distance: {}".format(profile_name),
xTitle = "Distance (Feet)",
yTitle = "Elevation (Feet)"
)
print("chart initialized")
chart_path = arcpy.CreateUniqueName(os.path.join("{}.svg".format(profile_name)), arcpy.env.scratchFolder)
print(chart_path)
profile_chart.exportToSVG(chart_path, 500, 500)
print("qed") I tried a ton of variations and found a few extra nuggets. I know the feature class and feature layer are correct. If I set the dataSource = source_fc, chart generates without error but i don't get the filter applied so it's not 'path to data kind of issue' If I export the layer to a table or lyrx it will also work but 'why do i have to add an extra step to write data back to disk'? If I add: print(r_chart_layer.getOutput(0).dataSource) It will print out the expected path to the feature class Oddly, this changes the failure, it's no longer an app crash but generates this error message: Traceback (most recent call last): File "D:\support\arcgis\chart-issues\create-chart.py", line 39, in <module> profile_chart.exportToSVG(chart_path, 500, 500) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\charts.py", line 449, in exportToSVG svgRes = self.getSVG(width if width != None else self.displaySize[0], File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\charts.py", line 445, in getSVG return _convertArcObjectToPythonObject(self._arc_object.getSVG(width, height)) RuntimeError: Invalid dataset: CIMPATH=internal_map/pts.json There are work arounds but seems like you should be able to MakeFeatureLayer() and assign it as a chart data source without any extra steps.
... View more
03-09-2023
11:01 AM
|
0
|
1
|
364
|
POST
|
Hi @Anonymous User, Is there documentation on 'licensing' arcpro inside ArcGIS Server? I have an full ArcGIS Server Advanced license on this machine. What other license or setup is required? Also the script runs has expected when I execute it at the command line using the python env embedded in the ArcGIS server installation directory ... ArcPro app is not even running at that point so it doesn't seem like a licensing issue to me but possibily
... View more
01-11-2023
03:29 PM
|
0
|
0
|
426
|
POST
|
Hello All, We have a cool little geoprocessing analysis script that creates some data, does a bit of analysis and generates an awesome pdf 😉 .... this script works great when run from a desktop toolbox. When we publish it to server to connect to a web application, it fails at the point where we open the layout (pagx). There's no error message, the job just seems to die. Nothing in the AGS logs after a certain point when setting log level = debug. All the data and analysis artifacts (charts, csvs) get created fine -- i can inspect them in the AGS jobs folder. It's definitely in the final manipulation and export of the layout. We've done this before with ArcMap mxds and this is the first attempt with Pro aprx/pagx so maybe I'm just missing a crucial step in the process of opening the layout. I've distilled out all the fun data analysis and made a simple layout with a single text element for the title and a single map with only the stock basemap... no custom data, no fancy other elements... still dies in the same manner. I took out the map, so the layout has only a text element which the script/service will modify when run to ensure something is running dynamically and it works. So it seems like something with the map/map frame is the issue. Is there a 'activate' or 'update' map needed? Setup: ArcPro 2.9.5 / ArcGIS Server (standalone) 10.9.1 Here's the guts of the "run" method in the simplified script. Any thoughts would be greatly appreciated def ScriptTool(input_templates_folder, input_cool_text):
analysis_folder = arcpy.env.scratchFolder
map_template = os.path.join(input_templates_folder, 'Layout3.pagx')
arcpy.AddMessage('Template PAGX: {}'.format(map_template))
analysis_template = os.path.join(analysis_folder,'Layout3.pagx' )
arcpy.AddMessage('Analysis PAGX: {}'.format(analysis_template))
shutil.copyfile(map_template, analysis_template)
arcpy.AddMessage('Analysis PAGX: copied')
lyt = arcpy.mp.ConvertLayoutFileToLayout(analysis_template)
arcpy.AddMessage('Analysis PAGX: opened')
txt = lyt.listElements('TEXT_ELEMENT', 'Text')[0]
arcpy.AddMessage('Analysis PAGX: element found')
txt.text = input_cool_text
arcpy.AddMessage('Analysis PAGX: element updated')
layout_pdf = os.path.join(analysis_folder, "layout.pdf")
arcpy.AddMessage('Analysis PAGX: exporting to {}'.format(layout_pdf))
lyt.exportToPDF(layout_pdf)
arcpy.AddMessage('Analysis PAGX: complete')
return layout_pdf
... View more
01-10-2023
05:15 PM
|
0
|
2
|
471
|
POST
|
@ChristopherAllen Thanks for the verification. The 'aggregation=min' chart looks good when I use the full data. Looks like I was tinkering and had converted the values to integers to see if 'doubles' were the cause...this produced non-unique values and then the aggregation kicked in and made the chart a bit off.
... View more
01-10-2023
07:17 AM
|
1
|
2
|
863
|
POST
|
@Anonymous User Thanks! The whole chart dataSource things is really odd... It works fine with a 'FeatureLayer' if you're running the code inside the ArcPro py window but standalone code with arcpy.MakeFeatureLayer doesn't work --- full on 'blow up' of the process. I did add the 'aggregation='min' on the constructor and got some sort of result but it was a bit off... I'm going to submit a bug on this and see what tech-support says. I'll report back on the findings.
... View more
01-06-2023
10:07 AM
|
0
|
0
|
918
|
POST
|
Hi All, I must be missing something simple for a line chart. I have a simple csv file X,Y data ... values are doubles and I want to create a line chart but it blows up with the error: File "<stdin>", line 1, in <module> File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\charts.py", line 449, in exportToSVG svgRes = self.getSVG(width if width != None else self.displaySize[0], File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\charts.py", line 445, in getSVG return _convertArcObjectToPythonObject(self._arc_object.getSVG(width, height)) If I use the 'scatter' chart type, works fine but I don't get the nice line thru the data... so I don't think it's the data or csv format. ArcPro 3.0.2 CODE (running in a simple windows cmd window via C:\Users\fspataro\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\python.exe): import arcpy
out_svg_file = r"T:\scratch\analysis2\test.svg"
temp_csv_file = r"T:\scratch\analysis2\test.csv"
c = arcpy.charts.Line(x='X', y='Y', dataSource=temp_csv_file)
c.exportToSVG(out_svg_file, width=400, height=400) DATA (save as test.csv): X,Y 0.00,8.32 3.27,8.66 6.54,9.06 9.81,9.44 13.08,9.86 16.35,10.38 19.62,11.02 22.89,11.74 26.17,12.67 Thanks!
... View more
01-05-2023
04:18 PM
|
0
|
9
|
970
|
POST
|
Hi zain909, see my notes above. the default schema will ONLY be used if the incoming json doesn't have a 'fields' property. if the json has a fields, the service will correctly use them.
... View more
11-22-2022
09:06 AM
|
0
|
0
|
757
|
POST
|
Thanks DEWright_CA. Yes been there done that, this appears to be more in the compiled tbx that's produced for the service rather than the python I can manipulate. The data/schema is already modify by the time the script receives it.
... View more
11-16-2022
03:44 PM
|
0
|
0
|
772
|
POST
|
Tech support has verified the issue as bug in 2.0.1: BUG-000152141
... View more
11-15-2022
10:58 AM
|
1
|
0
|
526
|
POST
|
Bit of follow up... Wasn't able to find a way to make the service publish without a default schema using a single value input parameter. If you use a multi-value input parameter it appears to be less defined. However, the key to using the service either way is to make sure to include the 'fields' object on the FeatureSet json. When the fields object is included, your schema follows thru as you'd expect. If the fields object is NOT included in the json, then the 'default' schema is used --- which was what caused my original issue.
... View more
11-15-2022
10:55 AM
|
1
|
0
|
776
|
POST
|
Hi All, I have a geoprocessing tool that will work on any featureset I provide it in the tool window. But when I publish the tool as service, the schema gets locked to the exact match of the features I used to run the tool for publishing. Then it's not at all generic for the needs of the service. Is there an 'empty schema' that can be used to run the tool for publishing or a way to tell the publisher to ignore the schema? Thanks Fred
... View more
11-11-2022
02:45 PM
|
0
|
5
|
822
|
POST
|
HI, My script to update a content item data (file) fails when the item is in a folder. Seems like i might be missing something simple but can't figure out what. Setup: ArcGIS API for Python 2.0.1 Enterprise portal v 10.9.1 ... seems to work with AGOL Content item (tpk file) published/upload as simple file not as layer I can reproduce with the simple code below in the ArcPro python window Works fine if the item is in the owner root but fails when item is put into a folder Error:Traceback (most recent call last): File "<string>", line 1, in <module> File "D:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 12961, in update status = self._gis.content._add_by_part( File "D:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 5102, in _add_by_part path += "/" + folder_id TypeError: can only concatenate str (not "NoneType") to str Code: from arcgis.gis import GIS
gis = GIS('home')
id = '{item_guid_here}'
existing_tpk = gis.content.get(id)
tpk_path = r'C:\{my_new_awesome_file_here}.tpk'
existing_tpk.update(data=tpk_path)
... View more
08-29-2022
02:07 PM
|
0
|
1
|
661
|
POST
|
Hi All, Got an odd one... I feel like I've come across something similar before but it's got me stumped right now. Quick Summary: The script tool runs successfully outside of ArcMap/Catalog via python CLI The script tool runs successfully the FIRST time run from the toolbox inside ArcMap/ArcCatalog The script tool FAILS every time after the first until ArcMap/ArcCatalog is closed and restarted The function in the script tool runs successfully if called multiple times from a second script tool during the same execution but then fails with the same pattern when run consecutively. The failure is a critical level exception exiting the script: Traceback (most recent call last): File "D:\support\arcgis\msal\doauth.py", line 21, in <module> result = get_token() File "D:\support\arcgis\msal\doauth.py", line 14, in get_token client_credential="" File "C:\Python27\ArcGIS10.6\lib\site-packages\msal\application.py", line 239, in __init__ self.http_client, validate_authority=validate_authority) File "C:\Python27\ArcGIS10.6\lib\site-packages\msal\authority.py", line 85, in __init__ self.http_client) File "C:\Python27\ArcGIS10.6\lib\site-packages\msal\authority.py", line 142, in tenant_discovery resp = http_client.get(tenant_discovery_endpoint, **kwargs) File "C:\Python27\ArcGIS10.6\lib\site-packages\requests\sessions.py", line 543, in get return self.request('GET', url, **kwargs) File "C:\Python27\ArcGIS10.6\lib\site-packages\requests\sessions.py", line 516, in request prep = self.prepare_request(req) File "C:\Python27\ArcGIS10.6\lib\site-packages\requests\sessions.py", line 455, in prepare_request headers=merge_setting(request.headers, self.headers, dict_class=CaseInsensitiveDict), File "C:\Python27\ArcGIS10.6\lib\site-packages\requests\sessions.py", line 69, in merge_setting merged_setting = dict_class(to_key_val_list(session_setting)) File "C:\Python27\ArcGIS10.6\lib\site-packages\requests\structures.py", line 46, in __init__ self.update(data, **kwargs) File "C:\Python27\ArcGIS10.6\Lib\_abcoll.py", line 564, in update if isinstance(other, Mapping): File "C:\Python27\ArcGIS10.6\Lib\abc.py", line 144, in __instancecheck__ return cls.__subclasscheck__(subtype) File "C:\Python27\ArcGIS10.6\Lib\abc.py", line 180, in __subclasscheck__ if issubclass(subclass, scls): File "C:\Python27\ArcGIS10.6\Lib\abc.py", line 180, in __subclasscheck__ if issubclass(subclass, scls): File "C:\Python27\ArcGIS10.6\lib\site-packages\typing.py", line 1410, in __subclasscheck__ return super(GenericMeta, self).__subclasscheck__(cls) TypeError: super() argument 1 must be type, not None Details: The script tool integrates data between a feature class and an external API behind an AzureAD authentication. I've installed the official Microsoft library: c:\Python27\ArcGIS10.6\Scripts\pip.exe install msal The failure is not in the actual call for an authorization token but simply in the init constructor of the 'AD App' class so I'm able to strip it down to a very basic example which is attached in the zip file: 1. doauth.py - script file with function that initializes the 'AD App' and returns a true/false if the app class is created 2. doauth2.py - script file that calls the 'create app' function inside doauth.py twice in a row This was an attempt to see if it's something with multiple instances of the app class being created or if it's something specific with how ArcMap/Catalog are running the script itself.... appears to be the latter 3. toolbox.tbx - toolbox with both scripts attached as tools To repo: 1. install msal (see above) 2. CLI tests (execution is successful, no exceptions throw, simple text output returned) c:\Python27\ArcGIS10.6\Scripts\python.exe doauth.py c:\Python27\ArcGIS10.6\Scripts\python.exe doauth2.py 3. Open ArcCatalog Browse to toolbox Execute DoAuth tool - success, close window Execute DoAuth tool - fail Close ArcCatalog Repeat Any thoughts? Thanks in advance
... View more
11-03-2020
03:29 PM
|
0
|
1
|
561
|
POST
|
Just in case anyone else runs across this ... apparently you can't add the extension via the 'Addin Manager/Customize' dialog. Just double-click/execute the add-in with all the arcgis apps closed. As per the doc: Install add-in - Attribute Assistant | ArcGIS Solutions RTFM ..
... View more
09-03-2020
08:53 AM
|
0
|
0
|
640
|
POST
|
Hi All, I've downloaded the latest version of the attribute assistant from here: Attribute Assistant | ArcGIS Solutions Requirements says: ArcMap (Standard or Advanced) 10.2.1, 10.5 - 10.8 I'm running: I get the following error: I've tried running ArcMap 'as administrator'... same result. Any ideas? Thanks Fred
... View more
09-03-2020
08:43 AM
|
0
|
1
|
656
|
Title | Kudos | Posted |
---|---|---|
1 | 06-19-2024 01:20 PM | |
1 | 04-10-2024 09:26 AM | |
1 | 07-26-2023 03:18 PM | |
9 | 12-01-2023 09:37 AM | |
5 | 10-23-2023 11:31 AM |
Online Status |
Offline
|
Date Last Visited |
Thursday
|