|
POST
|
Oh, so you would basically just do this and I think it should work: sedf = pd.DataFrame.spatial.from_df(df)
adds = sedf.spatial.to_featureset()
fl.manager.truncate()
fl.edit_features(adds=adds) I don't remember if the result includes a SHAPE column, but if it does you could simply drop it before creating the featureset. There is a Table object you can use (although you can actually also just use FeatureLayer without a problem) which also has edit_features. @Trippetoe Sorry, I realized I was using "updates" instead of "adds" before. Updated all the samples accordingly. You would use "updates" in the case that you were simply updating attributes in the data.
... View more
05-29-2024
02:46 PM
|
1
|
0
|
1690
|
|
POST
|
Did you view the layer's data? It sounds like the Shape values may be missing.
... View more
05-29-2024
12:47 PM
|
0
|
3
|
2201
|
|
POST
|
You have two options: 1. Keep doing what you're doing but add an additional step that updates the feature layer definition to reapply the aliases and descriptions. For this, you'll need to access the FeatureLayer you want to update from the FeatureLayerCollection and then save the fields properties somewhere before you overwrite (FeatureLayer.properties.fields). On overwrite, you will use the FeatureLayer.update_definition() and supply the fields. 2. Truncate/append instead of overwriting. I like this option better because it's faster and results in less service downtime. This example assumes you have geometry to parse. If you don't then use "df" instead of "sedf" : import pandas as pd
from arcgis import GIS
from arcgis.features import GeoAccessor, GeoSeriesAccessor
from arcgis.features import FeatureLayer
gis = GIS()
url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Earthquakes_Since1970/FeatureServer/0"
fl = FeatureLayer(url, gis)
csv_path = "/path/to/xy.csv"
df = pd.read_csv(csv_path)
sedf = pd.DataFrame.spatial.from_xy(df=df, x_column="LONGITUDE", y_column="LATITUDE", sr=4326)
adds = sedf.spatial.to_featureset()
fl.manager.truncate()
fl.edit_features(adds=adds) Note for this to work you have to point to individual layer you want to update with new data.
... View more
05-29-2024
06:42 AM
|
1
|
3
|
1711
|
|
POST
|
I tested your example and it works fine for me: I'm on version 2.3.0.1 of the API. My guess is maybe your version isn't correctly parsing that JSON into geometry objects? Any difference if you explicitly parse into Polygon objects beforehand? from arcgis.geometry import Polygon
parsed = [
Polygon({'rings': [[
[-79608.7971409224, 853510.7087014914],
[-6525.311090338975, 856120.8334024921],
[-2610.1243669204414, 780427.2229789868],
[-78303.73479042202, 780427.2229789868],
[-79608.7971409224, 853510.7087014914]]],
'spatialReference': {'wkid': 2881, 'latestWkid': 2881}}),
Polygon({'rings': [[
[-44372.1163020879, 880917.0160934925],
[32626.556143827736, 886137.2648393214],
[41761.991941161454, 837849.9618078247],
[-44372.1163020879, 837849.9618078247],
[-44372.1163020879, 880917.0160934925]]],
'spatialReference': {'wkid': 2881, 'latestWkid': 2881}})]
... View more
05-22-2024
01:11 PM
|
0
|
1
|
1197
|
|
POST
|
There's a few different ways you can do this. Here's an example that uses buffers on point data and updates an "IntersectIds" field in a line feature layer to note which points are within 10m of a line: import pandas as pd
from arcgis import GIS
from arcgis.geometry import Geometry
from arcgis.features import FeatureLayer
gis = GIS("https://www.arcgis.com", "user", "passwd")
point_url = "https://services3.arcgis.com/ON5SbcAnb3R45678/arcgis/rest/services/point/FeatureServer/0"
point_fl = FeatureLayer(point_url, gis)
point_df = pd.DataFrame.spatial.from_layer(point_fl)
line_url = "https://services3.arcgis.com/ON5SbcAnb3Rdfghj/arcgis/rest/services/ln/FeatureServer/0"
line_fl = FeatureLayer(line_url, gis)
line_df = pd.DataFrame.spatial.from_layer(line_fl)
buffer_df = point_df.copy()
buffer_df["SHAPE"] = buffer_df["SHAPE"].apply(lambda x: x.buffer(10))
joined = line_df.spatial.join(
buffer_df,
how="left",
op="intersects",
left_tag="left",
right_tag="right"
)
intersecting_records = joined[~joined["OBJECTID_right"].isnull()].copy()
intersecting_records["IntersectIds"] = intersecting_records["PointId"].astype(str)
intersecting_records = intersecting_records.copy()[["OBJECTID_left", "IntersectIds"]].rename(columns={"OBJECTID_left" : "OBJECTID"})
final = intersecting_records.groupby("OBJECTID")["IntersectIds"].apply(",".join).reset_index()
fs = final.spatial.to_featureset()
line_fl.edit_features(updates=fs)
... View more
05-22-2024
11:26 AM
|
0
|
0
|
922
|
|
BLOG
|
@Clubdebambos Do you mean you are having trouble updating symbology at the item level? I just tried this on my end without issues.
... View more
05-22-2024
07:27 AM
|
0
|
0
|
4530
|
|
POST
|
There's not a stacktrace pointing to a problem? It's hard to say what's going on, but I assure you that while that method is not perfect it does work. Perhaps a different user account with publishing rights or different data may yield different results.
... View more
05-21-2024
01:42 PM
|
0
|
0
|
1152
|
|
POST
|
It sounds like you're already doing things correctly? You don't need Notebook Server to publish data from dataframes. My guess is your error is about something else - auth as you mentioned, or perhaps the environment you're using.
... View more
05-21-2024
12:46 PM
|
0
|
2
|
1178
|
|
POST
|
My guess is you are hitting the max record limit as I don't see logic to page through results. The good news is that getting all records should be relatively simple now. In more recent versions of the API, the query method has a "return_all_records" param you can set to True and the method will automatically keep calling the service until all records that satisfy the where clause are found.
... View more
05-21-2024
11:49 AM
|
1
|
1
|
1211
|
|
POST
|
I don't have a reliable way to test this at the moment, but you would expect to find that kind of information in the service manifest. Per the API Reference, The service manifest resource documents the data and other resources that define the service origins and power the service. This resource will tell you underlying databases and their location along with other supplementary files that make up the service. Instead of "service.properties" you would use "service.service_manifest()" - this function returns JSON with the described information.
... View more
05-20-2024
12:15 PM
|
1
|
0
|
652
|
|
POST
|
There's a few ways you can do this. You can either check the Pro Package Manager (arcgis), run "conda list" and check the arcgis package version, or in code like this: import arcgis
print(arcgis.__version__)
... View more
05-17-2024
02:11 PM
|
0
|
1
|
2264
|
|
POST
|
Might be a version problem? I am on 2.3.0.1 and it works fine.
... View more
05-16-2024
01:48 PM
|
0
|
5
|
2319
|
|
POST
|
The problem here is that you're getting the admin url for those services (which is not what you want to be using). They come back in the format: https://server.domain.com/server/admin/services/serviceName.MapServer If you're not doing any Server administration then it would be better to just use gis.content, I'd say. However, if you must stick with the Server submodule, then I think you can do so by changing your code to: server1 = gis_servers[0]
fservices = server1.content.list(folder='GDPServices') There is a catch - content.list doesn't have filtering built in beyond the folder and will try to initialize objects (this may be a slow process) from the services for you. So, unless you are certain all you have in there are Feature Services, I would recommend setting the as_dict param to True and getting only what you need: server.content.list(folder="Hosted", as_dict=True) This adds extra work as you will need to filter for feature services and then concatenate the expected urls from the services directory url and content urls. So again, unless there's a reason you need to be using the Server submodule, probably using gis.content is going to be easier for whatever you're doing.
... View more
05-16-2024
01:17 PM
|
0
|
7
|
2326
|
|
POST
|
Okay, so the problem seems to be the logic used to get layer - it doesn't account for the case you mentioned where the id could be higher than the length of the list. I believe this is a valid bug you can log in the repo: Issues · Esri/arcgis-python-api · GitHub To fix this, you might just be able to adjust the for loop to use enumerate. So, in the source it would change to: for index, layer_id in enumerate(layer_ids): And then you would replace the point where it fails with layers[index] You might need to do that in a few places.
... View more
05-10-2024
07:06 AM
|
0
|
0
|
1033
|
| 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 |