FeatureClass to FeatureClass from ArcGIS Hub

337
2
06-28-2021 10:07 AM
LanceCole
MVP Regular Contributor

I am working on a script in Python to copy several Feature Classes hosted on ArcGIS Hub to a local fGDB.  I am using the workflow provided by @JoshuaBixby in Using arcpy to copy a portal feature service to a fgdb feature class. This is working for most of the features but a few will have NULL values listed for their Shape_Length and Shape_Area once imported into the fGDB.  Some features do not add these fields while others populate without issue.  Any Idea as to how to resolve the Null values.  

 

 

import arcpy
from arcgis.features import FeatureLayer

url_fl = r"https://the.url.com/arcgis/rest/services/structures/MapServer/0"
fgdb = r'c:\pathTo\mytest.gdb'
fc = r'thisfeature'

fl = FeatureLayer(url_fl)
fs = fl.query()
fs.save(fgdb, fc)

 

 

I do not own the data hosted on the Hub but have been given access to download/query the data.  If I use the Feature Class to Feature Class tool in ArcGIS Pro the Shape_Length and Shape_Area fields populate, without issue. 

0 Kudos
2 Replies
JoshuaBixby
MVP Esteemed Contributor

Is this publicly-accessible data I could look at myself?  (Send me an GeoNet e-mail if yes but you don't want to post it here).

0 Kudos
LanceCole
MVP Regular Contributor

After trying several different approaches, I found that I can run Project (Data Management) on the saved feature class and this will fix the NULL values.  The output feature class has the correct Shape_Length and Shape_Area values assigned in the fGDB. 

arcpy.management.Project(in_dataset, out_dataset, out_coor_system, transform_method)

It would be great is this could be resolved without having to run an additional data management function.  It would also be great if you could just run the Feature Class To Feature Class (Conversion)  from a python script for data hosted on ArcGIS Online and Hub.

I am going to put a ticket in for initial issue.

0 Kudos