|
POST
|
It seems you may be on a version of the API that does not have that function. I am on Version 2.3.0 and do have access to the function.
... View more
07-01-2024
10:24 AM
|
1
|
1
|
745
|
|
POST
|
Can you elaborate on your attempt using the arcgis.gis.Item.update() method ? How were you passing in the JSON? Were you reading from a file?
... View more
06-29-2024
09:30 AM
|
0
|
3
|
3108
|
|
POST
|
I've not tested this, but assuming the schema is exactly the same then you should be able to do this for your specific case (i.e., you added Enterprise Feature Services as items to your AGOL content). from arcgis.gis import GIS
gis = GIS("https://www.arcgis.com", "user", "passwd")
new_url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/RedlandsEmergencyVehicles/FeatureServer"
your_item_id = "4567fd6780e74ccb877fasdfghjlkl"
item = gis.content.get(your_item_id) # here the item id of the Feature Service you added to AGOL
item_properties = {"url": new_url}
item.update(item_properties=item_properties) Coding this may not be worthwhile for a few urls. As Jake mentioned, you can do the same thing rather quickly in AGO Assistant.
... View more
06-27-2024
02:06 PM
|
0
|
0
|
1102
|
|
POST
|
Hello Matthias. I'll do my best to be helpful here. 1. I'm not sure why both name/title exist nor when name is initialized, but you can set the value of "name" locally without updating pushing the update. I'd be curious to see if this fixes your problem. Can you trick clone_items into working with one of the bad items by setting the name property beforehand? item.name = "test" 2. I'm not sure what this is about, but it seems like there is some incomplete logic. Again, I would try the manual set mentioned in #1 and see if that is enough to fix it. You might also consider logging this as an issue here: Issues · Esri/arcgis-python-api · GitHub 3. You could log another issue for this and point out the line number/block where the issue is happening. I suspect that updating the line "if name is None" to "if not name" would fix the problem as it should handle both None and empty strings. You could even try this fix yourself and see if it fixes the problem! I would just advise to be careful to change it back to the original or else use a development python environment.
... View more
06-26-2024
05:57 AM
|
0
|
0
|
1548
|
|
POST
|
Here's an idea. Load that shapefile into a spatial dataframe. sdf = pd.DataFrame.spatial.from_featureclass("path\to\your\data\census_example\cities.shp") Then append like this instead: adds = sdf.spatial.to_featureset()
feature_layer.edit_features(adds=adds)
... View more
06-21-2024
08:36 AM
|
0
|
0
|
979
|
|
POST
|
My pleasure @John_Herrera . Hope you can figure out and fix whatever's wrong!
... View more
06-14-2024
02:49 PM
|
0
|
1
|
1765
|
|
POST
|
A nice idea, but alas I believe the intended usage of this is something like this: from arcgis.gis import GIS
gis = GIS("https://www.arcgis.com", "user", "passwd")
feature_layer_id = "123456789abcdefghijk" # here feature layer in the portal Item sense, not API object sense
item = gis.content.get(feature_layer_id )
flc = item.layers[0].container # here any layer/table index should return the same FeatureLayerCollection object So, just another way to get a FeatureLayerCollection. There might be scenarios where this could be more convenient than using fromitem (maybe when fiddling with views?), but to me using fromitem or just directly initializing a FeatureLayerCollection is more readable. Regarding the get/set - that's just Python. Everything is public so you're allowed to set things you probably wouldn't or shouldn't set 🙂
... View more
06-14-2024
02:28 PM
|
1
|
1
|
683
|
|
POST
|
Ah, thank you for clarifying. Unfortunately, as other people seem to have reported I observed the view_layers and view_tables parameters to be quite buggy. They also do not do what I would expect. You can, however, do this with create_service and I have a very simplified sample that will add all fields from source table. I start with the source FeatureLayerCollection so that the source information can be tied back nicely without any extra work. from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
gis = GIS("https://www.arcgis.com", "user", "passwd")
url = "https://services3.arcgis.com/ON5SbcAnbs908sd90j/arcgis/rest/services/source/FeatureServer"
flc = FeatureLayerCollection(url, gis)
view_item = gis.content.create_service(name="tableOnly", is_view=True)
view_flc = FeatureLayerCollection.fromitem(view_item)
definition_to_add = {
"layers": [],
"tables": [
{
"name": flc.tables[0].properties.name,
"type": "Table",
"cacheMaxAge": 30,
"description": "",
"url": flc.tables[0].url,
"adminLayerInfo": {
"viewLayerDefinition": {
"sourceServiceName": flc.service.properties.adminServiceInfo.name,
"sourceLayerId": flc.tables[0].properties.id,
"sourceLayerFields": "*"
}
}
}
]
}
view_flc.manager.add_to_definition(definition_to_add) After this step, you can apply your viewDefinitionQuery as usual using update_definition.
... View more
06-14-2024
01:14 PM
|
1
|
1
|
1312
|
|
POST
|
Hi, it's not clear to me if you have two problems here or one so my response is going to target both possibilities. Is the problem that create_view is not creating a view with both the feature layer and table? Or are you wanting to create a view with just the table (not the feature layer)? It used to be in older versions of the ArcGIS API for Python that tables were not included in the create_view logic. Nowadays, unless you explicitly set the layers/tables you want using the view_layers/view_tables params, create_view should just create a view that contains all layers and tables. If none of the above is what you're talking about and what you're really asking is how to set the view definition on a table, then the problem is that in your "create_view" function, your logic only looks at layers: # The viewDefinitionQuery property appears under layers
view_layer = view_flc.layers[layer_index] What you need to do for tables is: # The viewDefinitionQuery property appears under layers
view_layer = view_flc.tables[idx] So, you can just do a quick fix on the params. You can use an enum or just a boolean like this: def create_view(gis, source_flc, view_name, idx, view_def, is_table=False):
...
...
view_layer = view_flc.tables[idx] if table else view_flc.layers[idx]
view_layer.manager.update_definition(view_def) When you need to make an update on a table, simply set is_table to True.
... View more
06-14-2024
06:53 AM
|
0
|
3
|
1322
|
|
POST
|
Hey @John_Herrera , Are you able to publish the source data (i.e., one of the datasets without joining anything to it)? Just trying to see if this is a general publishing problem or something directly related to the join.
... View more
06-13-2024
01:08 PM
|
1
|
0
|
1786
|
|
POST
|
Ah, okay. So, right now are you doing this manually? If all that's changing in the source data is the addition/removal of a few fields here and there, I think you can just: Update the View feature layer definition to match the current source fields Update the View definition if necessary Hopefully, I've understood what you're needing to do.
... View more
06-13-2024
12:58 PM
|
0
|
1
|
313
|
|
POST
|
Can you try that again, but way smaller? I don't know if you are working from a dataframe, but another check would be just sending in the data with just a few fields. Just to narrow down the problem.
... View more
06-12-2024
02:08 PM
|
0
|
1
|
2030
|
|
POST
|
Since they're indexed, I don't think there's a way to do this without a significant amount of work that will result in your data going offline.
... View more
06-12-2024
02:03 PM
|
0
|
1
|
593
|
|
POST
|
Have you tried with a subset of the data? Like 1-2 features? Seems like a list of Feature objects should work, but I must admit I've only used FeatureSet objects (and raw json to a much lesser extent). Unfortunately, the error handling is not great with that function so it can be hard to pinpoint the cause of failure. Sometimes it can be that a length of a string exceeds the limit allowed by a field or an issue with data types.
... View more
06-12-2024
01:43 PM
|
0
|
3
|
2038
|
|
POST
|
You know what? The more closely I look at the source the more it's apparent that "overwrite" option doesn't do anything! This is the only thing it actually does: if overwrite:
_log.warning(
"overwrite is currently not supported on this platform, and will not be honored"
) And reading the documentation: I'm so sorry to have led you astray here. I didn't run create with overwrite myself and so didn't catch this earlier. It seems absolutely pointless to add this parameter if it doesn't do anything at all.
... View more
06-12-2024
01:20 PM
|
0
|
3
|
1428
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 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 |