Was quite exited to update to ArcPro 2.7 and now I am wailing.
This code ran well on ArcPro 2.6 until I rolled to 2.7
from arcgis.gis import GIS
import arcgis
from arcgis import features
from arcgis.geoanalytics import manage_data
from arcgis.features.manage_data import overlay_layers
from arcgis.features import GeoAccessor, GeoSeriesAccessor, FeatureLayer
import arcpy
import sys, os
import pandas as pd
import datetime as dt
from arcgis.features import FeatureLayerCollection
import http.client
import mimetypes
import json
import requests
from pandas import json_normalize
from arcgis import geometry
from copy import deepcopy
from arcgis.features.manage_data import dissolve_boundaries
gis = GIS("url.maps.arcgis.com", "UserName", "Password)
item=gis.content.get('Feature_Layer Portal ID')
l=item.layers[0]
df=l.query().sdf
#Create Temporary Geodatabase
if arcpy.Exists(r"C:\Centroid"):
arcpy.Delete_management(r"C:\Centroid")
arcpy.CreateFolder_management(r"C:", "Centroid")
if arcpy.Exists(r"C:\Centroid"):
arcpy.Delete_management(r"C:\Centroid\Centroid")
arcpy.CreateFolder_management(r"C:\Centroid", "Centroid")
arcpy.CreateFolder_management(r"C:","Centroid")
if arcpy.Exists(r"C:\Centroid\Centroid\KCentroids.gdb"):
arcpy.Delete_management(r"C:\Centroid\Centroid\KCentroids.gdb")
arcpy.CreateFileGDB_management(r"C:\Centroid\Centroid","KCentroids")
#Write spatially enabled dataframe to disk
df.spatial.to_featureclass('C:\Centroid\Centroid\KCentroids.gdb\jana')
For reasons I cant explain df.spatial.to_featureclass can neither write feature class to geodatabase nor shapefile to a folder. Has anyone experienced this? If not what could it be because update was successful
I get the error
ValueError: invalid JSON data
Try adding a "r" to the path maybe?
df.spatial.to_featureclass(r'C:\Centroid\Centroid\KCentroids.gdb\jana')
Good general suggestion, but it would only have an impact if it was one of the "evil" escape characters, like, t, a, b, and a load of others
print('C:\Centroid\Centroid\tCentroids.gdb\jana')
C:\Centroid\Centroid Centroids.gdb\jana
If that exact json worked in 2.6, then you might want to flag the github site because they could narrow down changes to the api better than we could. You can examine the site under "issues" open or closed. Or report an "issue"
Esri/arcgis-python-api: Documentation and samples for ArcGIS API for Python (github.com)
Thanks, logged the issue https://github.com/Esri/arcgis-python-api/issues/890 . Will uninstall and reinstall 2.6 and see how I go
Resolved this issue by restricting myself to the ArcGIS API. I used this notebook and hence avoided writing to disc