POST
|
Hi, Sorry if this is a basic question but I can't seem to crack it. I am creating a Polygon feature from a list of xy values and want to add it to a Spatially Enabled Dataframe. How could I make a SEDF that holds the following polygon? import pandas as pd
from arcgis.geometry import Polygon
from arcgis.features import SpatialDataFrame
shape = {
"rings": [[[-90.0, 30.0], [-91.0, 30.0], [-90.0, 31.0]]],
"spatialreference" : {"wkid" : 4326}}
polygonFeature = Polygon(shape)
print(polygonFeature.is_valid)
df = pd.DataFrame() The polygon created from the values is valid, I'm just not sure how I could add it to an SEDF and then append additional polygons. Thanks for any help!
... View more
10-26-2020
11:14 AM
|
1
|
1
|
1586
|
POST
|
Turns out it was an issue with our server implementation. Going from SEDF > FeatureSet and using Feature set to update the table works well.
... View more
10-26-2020
10:23 AM
|
1
|
0
|
3594
|
POST
|
Hi Jake Skinner, thanks for continuing to engage with this. I will be adding the data to our Enterprise Server. Your approach seems to be a fine workflow with the exception of the time between the table truncation and the data being added. I can likely work around this using a mix of add/edit/delete once I get going. Question for you: is it possible to add the features in your example as a featureset after converting the second SEDF? Here is what I am trying: import pandas as pd
from arcgis.gis import GIS
from arcgis.features import FeatureSet
#GIS Server credentials
gis = GIS(GISURL, username, password, verify_cert=False)
df1 = pd.DataFrame([["foo", -90.0, 30.0], ["bar", -91.0, 31.0]], columns = ["ID", "Longitude", "Latitude"])
df1SEDF = df1.spatial.from_xy(df1, "Longitude", "Latitude")
dataFrameLayer = df1SEDF.spatial.to_featurelayer("DataFrame to a layer", gis) This continues to work excellently and places the objects on the server as expected. However, this portion seems to be giving me an issue: df2 = pd.DataFrame([["foo", -90.0, 30.0], ["fighter", -93.0, 33.0]], columns = ["ID", "Longitude", "Latitude"])
df2SEDF = df1.spatial.from_xy(df2, "Longitude", "Latitude")
# Get Item ID of previous published data frame
searchResults = gis.content.search('title:DataFrame to a layer AND owner:{0}'.format(username), item_type='Feature Layer')
sourceId = searchResults[0]['id']
# Reference layer in feature service
fLayer = gis.content.get(sourceId)
editTable = fLayer.layers[0]
# Truncate feature service
editTable.manager.truncate()
df2FeatureSet = FeatureSet.from_dataframe(df2SEDF)
editTable.edit_features(adds = df2FeatureSet) The code returns what appears to be success (apologize for the non congruent objectids - I ran it twice): {'addResults': [{'objectId': 5, 'success': True}, {'objectId': 6, 'success': True}], 'updateResults': [], 'deleteResults': [], 'attachments': {'addResults': [], 'updateResults': [], 'deleteResults': []}} However, the data on server is blank: Any ideas why this could be the case? Am I incorrectly using the FeatureSet? Thanks a bunch!
... View more
10-23-2020
03:22 AM
|
0
|
1
|
3594
|
POST
|
Thanks for the response Jake. The data is about 10,000 point objects, so I was hoping to do this with SEDF or file, but I will certainly give this a try and report back.
... View more
10-22-2020
02:50 AM
|
0
|
3
|
3594
|
POST
|
Hi all. Sorry, I'm relatively new to all of this and wanted to ask what the easiest way to accomplish this would be. Below is an example of the code I am working with: import pandas as pd
from arcgis.gis import GIS
gis = GIS(ServerURL, username, password, verify_cert=False)
df1 = pd.DataFrame([["foo", -90.0, 30.0], ["bar", -91.0, 31.0]], columns = ["ID", "Longitude", "Latitude"])
df1SEDF = df1.spatial.from_xy(df1, "Longitude", "Latitude")
dataFrameLayer = df1SEDF.spatial.to_featurelayer("DataFrame to a layer", gis)
# df1SEDF is published to the server
df2 = pd.DataFrame([["foo", -90.0, 30.0], ["fighter", -93.0, 33.0]], columns = ["ID", "Longitude", "Latitude"])
df2SEDF = df1.spatial.from_xy(df2, "Longitude", "Latitude") The first six lines of code runs fine, takes the two points in the dataframe and adds them to the server (as a Shapefile and Feature Layer (hosted)). What would be the easiest way to update the layer with the contents of the second dataframe? The ID column is unique if that matters. It could be an overwrite, or update only the changes (remove "bar" and add "fighter"). Any help is much appreciated. Thanks!
... View more
10-21-2020
09:31 AM
|
0
|
5
|
3710
|
Title | Kudos | Posted |
---|---|---|
1 | 10-26-2020 11:14 AM | |
1 | 10-26-2020 10:23 AM |
Online Status |
Offline
|
Date Last Visited |
03-23-2022
09:07 PM
|