My AGOL Notebooks are not working

874
3
03-30-2022 07:31 AM
MVAC
by
New Contributor III

Hello,

This week I've been having issues with the notebooks I've been using for the past two months. Some parts work others doesnt and I cant find the problem.

For example:

# set our spatial reference
print('Setting spatial reference...')
sr = 32633

# query features to dataframe
print('Querying features to dataframe...')
df = parcels.query(
    as_df = True,
    return_centroid = True,
    return_geometry = False,
    out_sr = sr
)

# convert centroid to dict
print('Converting centroid to dictionary...')
sdf = GeoAccessor.from_xy(df.join(pd.DataFrame(df.loc[:, 'centroid'].to_dict()).T), 'x', 'y', sr=sr)

# drop the centroid columns
sdf.drop(columns=['x', 'y', 'centroid', 'OBJECTID'], inplace=True)
print('Spatial DataFrame succesfully created')
#sdf.head()


# export to new feature class
sdf.spatial.to_featurelayer(
    title = 'Points_parcels',
    gis = gis,
    tags = ['parcels', 'centroids'],
    folder = 'Layers',
    sanitize_columns = True,
    service_name = 'parcels'
)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_44/3260207136.py in <module>
      6     folder = 'Layers',
      7     sanitize_columns = True,
----> 8     service_name = 'parcels'
      9 )

TypeError: to_featurelayer() got an unexpected keyword argument 'sanitize_columns'

 

Another notebook I use to create workforce projects its returning an error as well:

# create a new workforce project
project = arcgis.apps.workforce.create_project(name_project, summary='This project was created by Python')

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_64/338207951.py in <module>
----> 1 project = arcgis.apps.workforce.create_project(name_project, summary='This project was created by Python')

/opt/conda/lib/python3.7/site-packages/arcgis/apps/workforce/_store/projects.py in create_project(title, summary, major_version, gis)
     65                 "Offline Workforce Projects not supported at GIS lower than 7.1"
     66             )
---> 67         return _v2_create_project(gis, summary, title)
     68 
     69     else:

/opt/conda/lib/python3.7/site-packages/arcgis/apps/workforce/_store/projects.py in _v2_create_project(gis, summary, title)
    176 def _v2_create_project(gis, summary, title):
    177     """Creates project following version 2 Workforce schema"""
--> 178     for f in gis.users.me.folders:
    179         if f["title"].lower() == title.lower():
    180             raise WorkforceError("A folder named '{}' already exists.".format(title))

AttributeError: 'NoneType' object has no attribute 'folders'

 

Thank you

Tags (2)
0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

did you upgrade arcgis?

There is at least one issue with sanitize_columns vs sanitize_column_names on their github site

sedf.spatial.to_featureclass(sanitize_columns=True) always mutates the calling SEDF · Issue #923 · E...


... sort of retired...
0 Kudos
MVAC
by
New Contributor III

I think this issue has been fixed. A week ago I used `to_featurelayer()` and it workerd perfectly fine but this week is not working at all 😞

AaronKoelker
Occasional Contributor III

I'm running into a similar issue but with the service_name parameter. Haven't figured it out yet. Following the documentation here: https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html?highlight=to_featurelaye...

 

 

sdf.spatial.to_featurelayer(title='My Feature Layer Title', tags=['my','tags'], service_name='My_Feature_Layer_Title')

 

 

 

TypeError: to_featurelayer() got an unexpected keyword argument 'service_name'

 

It works if I remove the service_name argument, but then the name of my service is a randomly generated string. Not sure how else to define it.

 

Maybe because I'm using a Spatially Enabled Dataframe instead of the deprecated Spatial Dataframe?

-Aaron