Last active
October 6, 2022 21:01
-
-
Save apfister/a9626b8b6ef58f30b31ec67a4fed60f2 to your computer and use it in GitHub Desktop.
Publish a Feature Service with multiple layers from a spatial data frame or multiple frames
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create an empty service | |
create_params = { ... } | |
created_item = gis.content.create_service(name=create_params['name'] , create_params=create_params) | |
# get a reference to the base feature service | |
ci_fl = FeatureLayer(created_item.url) | |
# create a feature collection from your dataframe | |
fc = final_df.spatial.to_feature_collection() | |
# set the name of the layer, and the id (integer) | |
fc.layer.layerDefinition.name = 'SDG_1' | |
fc.layer.layerDefinition.id = len(created_item.layers) | |
# make an add to definition call | |
add_res = ci_fl.manager.add_to_definition({ | |
"layers": [fc.layer.layerDefinition.__dict__['_mapping']] | |
}) | |
# now go on with your bad self. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment