|
POST
|
Okay, if that is what you're trying to update the workflow you described isn't quite what I had in mind. What happens if instead you do: app_data = item.getdata()
app_data['geometryService'] = 'https://thisisanupdate.com'
item_properties = {"text": json.dumps(app_data)}
app.update(item_properties=item_properties) This update is successful for me and the application continues to work.
... View more
10-02-2019
07:51 AM
|
1
|
0
|
1279
|
|
POST
|
Hi Andrew, A bit more information on the type of data you're loading into the SEDFs would be helpful. As you're working with ArcPy, I'll assume at least some of it is local data. In that case, the requirement to be signed is by design: https://developers.arcgis.com/python/guide/introduction-to-the-spatially-enabled-dataframe/. That being said, with more information on what you're trying to load there may be some other options to explore. The fiona package, for example, allows you to open File Geodatabase feature classes, shapefiles, GeoJSON, etc. If you're loading Feature Services into the SEDF then that might be trickier. -Earl
... View more
10-01-2019
08:48 PM
|
0
|
0
|
699
|
|
POST
|
Hi Angus, Exactly what are you trying to update in the app? URLs defined in widgets (e.g., Geoprocessing Widget task URL)? Those would appear in the Web Application item data, otherwise any displayed layers should come from the underlying Web Map. -Earl
... View more
10-01-2019
08:39 PM
|
0
|
2
|
1279
|
|
POST
|
Hi Andreas, Based on the information you shared, the problem may be that you are publishing from a 10.7 client to ArcGIS Image Server 10.5/10.6. A common indicator of version mismatch is the 'invalid source path' error in logs. At the time of this writing, no patch has been released for ArcMap to allow backwards compatibility of 10.7 mosaic datasets (backwards compatibility is only offered in ArcGIS Pro 2.3.2+). If the problem is related to compatibility, then using ArcGIS Pro 2.3.2+ or ArcMap 10.6.1 to create and publish mosiac datasets should resolve your issues. For more information on the limitation, as well as steps to manually introduce backwards compatibility on mosaic datasets already created in ArcMap 10.7 or ArcGIS Pro 2.3, see this page: https://community.esri.com/community/gis/imagery-and-remote-sensing/blog/2019/03/28/mosaic-datasets-created-or-edited-with-pro-232 - Please note in order to do this, you need access to ArcGIS Pro 2.3.2+. Hope this helps, Earl
... View more
09-28-2019
09:22 AM
|
0
|
0
|
1476
|
|
POST
|
Hi Ming, Thank you for presenting this interesting scenario. I don't think this is possible through the ArcGIS Online UI (at least I'm not seeing where you might accomplish this), but you can accomplish this through some clever use of the ArcGIS API for Python. You mentioned your current workflow is to publish from ArcGIS Pro and then create the view in ArcGIS Online. That is a key detail: this means that the labeling information of the original service is stored within the service definition itself and not at the item level. Indeed, if you create a view from the original service, you can even see that the same exact labeling properties are defined. The problem, however, is for some reason they are not exposed. The good news is, you can expose those dormant properties by modifying the item after the fact. If all this is getting a bit confusing, it may help to read this post where I explain the levels at which you can set properties on a layer: https://community.esri.com/groups/arcgis-python-api/blog/2019/04/09/updating-layer-symbology-with-the-arcgis-api-for-python I talk about symbology in the post, but other properties like labeling apply as well. Okay, let me start with a very rough example I prepared for the sake of illustration. Let's suppose we publish some historic earthquake data in ArcGIS Pro and label events as follows: Red for earthquakes of magnitude greater than 6 Blue for earthquakes of magnitude less than 6. The published service (named eqpro) looks like this when loaded into a Web Map (the labels look terrible I know, but it's the colors we're interested in!): Our starting code is like so: import json
from arcgis import GIS
from arcgis.features import FeatureLayerCollection
conn = GIS("https://www.arcgis.com", "Hari", "Seldon")
def search_layer(conn,layer_name):
search_results = conn.content.search(layer_name, item_type='Feature Layer')
proper_index = [i for i, s in enumerate(search_results)
if '"' + layer_name + '"' in str(s)]
found_item = search_results[proper_index[0]]
flc = FeatureLayerCollection.fromitem(found_item)
return flc
def search_item(conn,layer_name):
search_results = conn.content.search(layer_name, item_type='*')
proper_index = [i for i, s in enumerate(search_results) if '"' + layer_name + '"' in str(s)]
found_item = search_results[proper_index[0]]
get_item = conn.content.get(found_item.id)
return get_item You don't have to worry so much about the functions here. They just help us locate the content easily. Next, we locate the eqpro service, load it as a Feature Collection object (source_flc), and create a view from the object (eqpro_view😞 source_flc = search_layer(conn, 'eqpro')
source_flc.manager.create_view(name='eqpro_view') The created view already has those labeling properties defined at the service level. What we need to do now is expose them at the item level. So, we locate the view item and update its properties to include the ones defined in the dictionary. Here, the dictionary you'll use may differ depending on how many layers are in the service, but you can use the one shown as a rough guide. update = {'layers': [{'id': 0, 'showLabels': True,
'layerDefinition': {'defaultVisibility': True}}]}
view_item = search_item(conn, "eqpro_view")
item_properties = {"text": json.dumps(update)}
view_item.update(item_properties=item_properties)
Lastly, we apply a view definition to the view to show only earthquakes of magnitude greater than 5. We do this at the service level: view_def = {"viewDefinitionQuery" : "magnitude > 5"}
view_flc = search_layer(conn, "eqpro_view")
view_layer = view_flc.layers[0]
view_layer.manager.update_definition(view_def) The final result looks like this: Note the blue labels still exist and some of the features (which were labeled in blue) have been filtered out (black boxes added to help illustrate the latter). Hopefully this helps. I know this is probably not the solution you had in mind, but at the very least it may be a viable alternative. If you're interested, the below posts go into more detail on how to create views with the ArcGIS API for Python: https://community.esri.com/groups/arcgis-python-api/blog/2019/02/11/using-the-arcgis-api-for-python-to-create-a-view-from-a-hosted-feature-layer-and-to-define-a-view-fefinition https://community.esri.com/people/EPolle_TensingInternational/blog/2019/03/27/create-view-from-hosted-feature-layer-and-define-area-of-interest Kind regards, Earl
... View more
09-26-2019
03:28 PM
|
4
|
2
|
2128
|
|
POST
|
Hi Jill, Thanks for the additional information. but I assume that the Data Store is a separate upgrade not part of the ArcGIS Server and other extensions? That depends on your environment configuration - you didn't mention whether you were using a base Enterprise deployment (ArcGIS Server, Portal for ArcGIS, ArcGIS Data Store). The Data Store is most valuable in a full enterprise, so I'll assume probably that's what your IT set up. I suspect that maybe sometime in the past you had at least an ArcGIS Server and Data Store 10.4.1 on one machine...and maybe today your IT has installed Data Store 10.7.1 on another machine? If your IT keeps some kind of a network diagram or if you can tell us whether you've been using Enterprise or just a standalone server we can figure this out.
... View more
09-26-2019
06:32 AM
|
1
|
1
|
2628
|
|
POST
|
Hi John, I'm guessing the problem is just that your input JSON is somehow invalid. I've attached another sample input which will add 3 layers to an existing service (point, line, polygon) - it's too long to include as a dictionary here. from arcgis import GIS
from arcgis.features import FeatureLayerCollection
conn = GIS("https://www.arcgis.com",
"Hari", "Seldon")
layer_name = "Foundation"
search_results = conn.content.search(layer_name, item_type="Feature Layer")
proper_index = [i for i, s in enumerate(search_results)
if '"' + layer_name + '"' in str(s)]
found_item = search_results[proper_index[0]]
source_flc = FeatureLayerCollection.fromitem(found_item)
add_data = <<< attached data >>>
source_flc.manager.add_to_definition(add) Note: You could load the attached data using the json library, but you'd need to change True to true, False to false, None to null.... Hope this helps. To answer your greater question, is your approach the best approach? That depends - you could certainly just overwrite the existing service with your additional layer and be done with the matter without ever having to guess what the JSON should be. It's really up to you how you want to approach the problem. -Earl
... View more
09-25-2019
05:15 PM
|
1
|
1
|
6250
|
|
POST
|
Hi Jill, It would be helpful if you included a screen of what you're seeing or part of a file path, but what Ryan said earlier is accurate. At 10.7, PostgreSQL 10.6 is used and whatever it is you're seeing should not be related to the current 10.7 Data Store. That being said, I can't say the 9.3 PGS database isn't in use somewhere else in your organization. -Earl
... View more
09-25-2019
03:47 PM
|
0
|
0
|
2628
|
|
POST
|
Hi Hannah, In your first function, you use an Update Cursor but aren't updating any values. A Search Cursor would be more appropriate. If I understand what you're trying to do correctly, I believe your question is touched upon in some older posts - you can check these two for guidance: update attribute table from another table based on a query https://community.esri.com/thread/208862-using-search-cursor-dictionaryupdate-populate-many-fields-using-values-from-another-table -Earl
... View more
09-24-2019
12:09 PM
|
0
|
0
|
1102
|
|
POST
|
Hi Jonathan, Your problem intrigued me so I decided to take a look at the create_view source code. I remember at least 3 other people seeking this functionality and found it's actually quite simple to implement. The behavior was logged as a defect by a colleague, but if you review the source code I think an Enhancement is more appropriate. The information I present here should not be taken as a solution. Rather, I want it to serve the purpose of bringing awareness to the situation and to provide some insight into how one might troubleshoot these matters. The accepted, supported solution is what I described previously: create the view manually or use the 3 individual methods. Anyhow, the file we're interested in arcgis/features/managers.py - this contains the create_view method. As you may have guessed, this method basically calls the createService and addToDefinition REST operations. Currently, it is written to only handle layers in the FeatureLayerCollection object and not tables - this is where that limitation comes from. The important snippet is this one (here I'm just showing one occurrence but it occurs twice): add_def = {
"layers" : []
}
if view_layers is None:
for lyr in fs.layers:
add_def['layers'].append(
{
"adminLayerInfo" : {
"viewLayerDefinition" :
{
"sourceServiceName" : os.path.basename(os.path.dirname(fs.url)),
"sourceLayerId" : lyr.manager.properties['id'],
"sourceLayerFields" : "*"
}
},
"name" : lyr.manager.properties['name']
}) Basically, all that needs to be done to enable tables to be created in the view is this: add_def = {
"layers" : [],
"tables" : [] # Add this key
}
if view_layers is None:
for lyr in fs.layers:
add_def['layers'].append(
{
"adminLayerInfo" : {
"viewLayerDefinition" :
{
"sourceServiceName" : os.path.basename(os.path.dirname(fs.url)),
"sourceLayerId" : lyr.manager.properties['id'],
"sourceLayerFields" : "*"
}
},
"name" : lyr.manager.properties['name']
})
# Add the below loop
for tbl in fs.tables:
add_def['tables'].append(
{
"adminLayerInfo" : {
"viewLayerDefinition" :
{
"sourceServiceName" : os.path.basename(os.path.dirname(fs.url)),
"sourceLayerId" : tbl.manager.properties['id'],
"sourceLayerFields" : "*"
}
},
"name" : tbl.manager.properties['name']
}) Thanks for asking about this - I hope the information here can help expedite a more permanent solution. -Earl
... View more
09-24-2019
08:22 AM
|
2
|
1
|
3933
|
|
POST
|
Hi Lino, Do you have a valid Raster Analytics System configured?
... View more
09-23-2019
03:38 PM
|
0
|
1
|
1208
|
|
POST
|
Hi Jonathan, I was able to achieve this after using a traffic capture for guidance. I confirm that thebelow operations are needed (I've pointed out the corresponding Python API methods): REST API Python API createService create_service addToDefinition add_to_definition update update_definition Relevant import statements: from arcgis import GIS from arcgis.features import FeatureLayerCollection You'll run the below to create a skeleton view - here make sure to set the WKID to match that of the service the view will be based on. gis.content.create_service(name="test_serv", service_description='',
has_static_data=False, max_record_count=1000,
supported_query_formats='JSON', capabilities='Query',
description='', copyright_text='', wkid=4326,
create_params=None, service_type='featureService',
owner=None, folder=None, item_properties=None, is_view=True) Once the service is created, load it as a FeatureLayerCollection object (let's supporse we call it test_flc). Next, run add_to_definition, where the input JSON is what you recorded from the traffic capture (I'm not including it here because the JSON is rather large). test_flc.manager.add_to_definition(input_add_json) Lastly, run update_definition where again the input JSON is from the traffic capture: test_flc.manager.update_definition(input_update_json) Hope this helps! -Earl
... View more
09-23-2019
02:30 PM
|
1
|
0
|
3933
|
|
POST
|
Hi Jonathan, It looks like your situation is described by this defect (logged at version 1.6.1): BUG-000122919: When using ArcGIS API for Python to create a view layer of a feature service that contains a layer and a table, the table is not included in the view layer. The workaround is to create the view manually. It seems you've captured the traffic when doing this manually and can see the which REST operations are involved? There are two add_to_definition methods - I believe you want the one that works on FeatureLayerCollection objects. I've not tested this myself but your approach sounds like it would work. -Earl
... View more
09-23-2019
11:56 AM
|
0
|
2
|
3933
|
|
POST
|
Hi Lino, I noticed at least one of those fields contains special characters. If you don't include that column (or any other column with special characters) dose the code run fine? I wonder if the problem is the encoding in the text...
... View more
09-19-2019
07:15 AM
|
0
|
1
|
1597
|
|
POST
|
Hi Gustavo, It's been a while, but I believe the information on this page may still be relevant: https://community.esri.com/thread/216481-adding-feature-class-and-applying-symbology-in-arcgis-pro-using-arcpy The problem was fixed at version 2.3 and I don't observe it at 2.4 So, if you're not on at least version 2.3 or if you are and this is still happening then you can try updating the connection or removing/re-inserting the layer. -Earl
... View more
09-17-2019
10:18 AM
|
0
|
1
|
1070
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 01-18-2024 01:34 PM | |
| 1 | 09-13-2023 06:48 AM | |
| 1 | 09-23-2022 09:04 AM | |
| 1 | 06-14-2024 01:14 PM | |
| 2 | 09-24-2019 08:22 AM |