Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArcPro 2.7 failing to execute sdf.spatial.to_featureclass() #890

Closed
Mungakha opened this issue Dec 21, 2020 · 4 comments
Closed

ArcPro 2.7 failing to execute sdf.spatial.to_featureclass() #890

Mungakha opened this issue Dec 21, 2020 · 4 comments
Assignees
Labels
cannot reproduce cannot reproduce the error/bug/issue

Comments

@Mungakha
Copy link

Mungakha commented Dec 21, 2020

Describe the bug
Have been using ArcPro 2.6 to download feature layer from ArcGIS Online, write the resulting spatially enabled dataframe into a geodatabase on local disc to resource multiple business processes. I updated to ArcPro 2.7 and the process now returns the following error ValueError: invalid JSON data. I reinstated 2.6.2 and now it works ok

To Reproduce
Steps to reproduce the behavior:

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')

error:

ValueError: invalid JSON data

Screenshots
If applicable, add screenshots to help explain your problem.

Expected behavior
A clear and concise description of what you expected to happen.

Platform (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Python API Version [e.g. 1.6.2] (you can get this by typing print(arcgis.__version__)

Additional context
Add any other context about the problem here, attachments etc.

@Mungakha Mungakha added the bug label Dec 21, 2020
@priyankatuteja
Copy link
Collaborator

I tried to reproduce this issue.
Screenshot below shows the same code run using ArcGIS Pro's Python command prompt (Version 2.6):
image

The same code is run using ArcGIS Pro (2.6) embedded notebook:
image

image

As mentioned, then I uninstalled Pro 2.6
Screenshot below shows version of Pro uninstalled:
image

Reinstalled Pro 2.7:

image

Notebook server launched using Python command prompt (Version 2.7):
image

The same code is run using ArcGIS Pro (2.7) embedded notebook:
image

image

@priyankatuteja
Copy link
Collaborator

@Mungakha Can you try the code mentioned below and see if you still get some error:

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("https://geosaurus.maps.arcgis.com", "arcgis_python", "P@ssword123")

item=gis.content.get('e1979a2137ca427690b2240262a84a5b')
item
l=item.layers[0] 
df=l.query().sdf
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')

If so, please open close any already open Python command prompts and close ArcGIS Pro as well Then uninstall and reinstall pro 2.7. After that try running the code mentioned above.

@priyankatuteja priyankatuteja self-assigned this Jan 15, 2021
@priyankatuteja priyankatuteja added cannot reproduce cannot reproduce the error/bug/issue and removed bug labels Jan 15, 2021
@Mungakha
Copy link
Author

Mungakha commented Jan 20, 2021

@priyankatuteja Trying with a ArcPro 2.7 downloaded from MyEsri on 21/12/2020 and installed on two different computers; my pc and a Virtual Machine in Azure, the error replicated itself on both machines

image

Like I did on on 21/12/2020, I have uninstalled, downloaded ArcPro 2.7 , cloned a new environment and run the code and I ran into the same issue.
image

However, when I install ArcPro 2.6, clone a new environment the notebook does run well on both the pc and Virtual Machine.

I also made attempts to avoid writing to disc and write back to portal using ArcGIS API for Python as detailed in this code. This too worked.

Interested in understanding why 2.7 fails to write to disc but 2.6 does.

@Mungakha
Copy link
Author

Mungakha commented Feb 9, 2021

This was resolved by patch 2.7.1

@Mungakha Mungakha closed this as completed Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cannot reproduce cannot reproduce the error/bug/issue
Projects
None yet
Development

No branches or pull requests

2 participants