Python API 1.9.1
I am seeing something similar to a few other posts where publishing from a SDF like sdf.spatial.to_featurelayer() creates the layer but there are no features or there is some other problem.
I have followed the https://developers.arcgis.com/python/sample-notebooks/html-table-to-pandas-data-frame-to-portal-item... example but in my case I only need to produce the SDF from known Lat Long fields so I use the following code basically I have tried all the methods out there and all produce broken services or services with features that only show up in the map viewer classic?
sdf = pd.read_excel("combined gis.xlsx") #used this as a work around to try instead of the from_xy() same result lat longs are backward in my sheet sdf['SHAPE'] = sdf.apply(lambda row : arcgis.geometry.Geometry({'x': row['Long'], 'y': row['Lat'], 'spatialReference': {'wkid': 4326}}), axis=1 ) sdf.spatial.set_geometry(sdf['SHAPE']) #used this but produces a empty service but the sdf plots fine in the map in my browser # sdf = dataframe1.spatial.from_xy(dataframe1, x_column='Long', y_column='Lat') print(len(sdf)) #filtered features with 0,0 in case that was causing a problem sdf = sdf[sdf.Lat != 0] print(len(sdf)) print(sdf.spatial.sr) # print(sdf) #the import just creates an empty service # fc = gis.content.import_data(sdf) #this also creates an empty service lyr = sdf.spatial.to_featurelayer('EMPTY USELESS LAYER', gis) #sdf plots fine in the jupyter notebook browser map1 = gis.map() map1.add_layer(sdf) map1
This workflow has never worked for me and so I have always just saved things locally to a feature class in FGDB then published from there. If anyone has any ideas I am listening! from_xy is simple enough but there is something happening when I try to import it or publish it - maybe with the projection? Maybe I am missing something simple.
I have looked at all samples and people have had similar issues but this scenario is even more basic than most and it doesn't work.
Thanks!
Solved! Go to Solution.
Looks like the empty service is due to some date fields not being of type datetime and one of them being a Timestamp value in the excel sheet so I think this is the issue.
Can you share a sample of the spreadsheet?
sent
Looks like the empty service is due to some date fields not being of type datetime and one of them being a Timestamp value in the excel sheet so I think this is the issue.
That's good to hear.