Append to Feature Layer Collection

149
2
Jump to solution
a week ago
Labels (3)
John_Herrera
New Contributor II

Hello!

My environment is ArcGIS Enterprise v11.1 & ArcGIS Pro v3.2.1.

I can successfully append from a shapefile to a hosted feature layer in Portal.  The new points come over, but the attributes are blank.

# initial imports
from IPython.display import display, HTML
from arcgis.features import FeatureLayerCollection
from arcgis.gis import GIS
import pandas as pd

# connect to GIS
gis = GIS("home")

# set a variable for the source .shp
src_table = r"C:\Data\orbs.shp"

# Read the shapefile using Spatially Enabled DataFrame
sdf = pd.DataFrame.spatial.from_featureclass(src_table)
sdf

# Get the item to append to (target)
item = gis.content.get("07bbd53a0efu413193fcb511c6dcb4d5")
flayer = item.layers[0] # first item in the FeatureLayerCollection
item

# confirming the first item in the collection
print(flayer)

# append
flayer.edit_features(adds = sdf)

 

Any assistance you can provide is greatly appreciated!

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

I have better better luck converting the dataframe to a featureset first. Try this for your final line:

flayer.edit_features(adds = sdf.spatial.to_featureset())

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

I have better better luck converting the dataframe to a featureset first. Try this for your final line:

flayer.edit_features(adds = sdf.spatial.to_featureset())

- Josh Carlson
Kendall County GIS
0 Kudos
John_Herrera
New Contributor II

This worked!  Thank you for your time!

0 Kudos