Query and Project AGOL Feature Layer export locally

333
0
12-21-2021 09:22 AM
kmsmikrud
Occasional Contributor III

Hello,

I currently have a post-survey script that queries AGOL survey layers by survey date and surveyor and then uses the arcpy.FeatureClassToFeatureClass_conversion to export the data to a local file geodatabase.

The AGOL feature layers are in GCS WGS84 and I would like to project the queried data and export to a feature class stored in a feature dataset/file geodatabase.

I've seen reference to the project_as or  using the out_sr = 3338 in the service query statement, but I haven't had success. With the syntax below it runs with an error 'Object: Error in executing tool'. Is a featureSet input not allowed for the FeatureClassToFeatureClass_conversion? 

 

 

exp_fltr = map_fltr  + " AND Creator = '" + str(s) + "'"
                    print(str(exp_fltr))
                    fn = ft_dict[str(svc)] + str(obs_dict[s]) + "_" + str(sdate1)
                    print(str(fn))
                    ftds = FeatureLayer(svc).query(where = exp_fltr, out_sr = 3338)
                    print(type(ftds))
                    fc = arcpy.FeatureClassToFeatureClass_conversion(ftds, outpath, str(fn))

 

 

 

One thing I did notice if I use the feature layer service as input as I have been doing and the output location is a Feature Dataset (with the desired projection) the following code does export the queried feature layer and saves the feature class with desired projection. Although this doesn't seem the best way or is it legit?

 

 

 fc = arcpy.FeatureClassToFeatureClass_conversion(svc, outpath, str(fn) , exp_fltr)

 

 

 

Thanks in advance as I'm floundering here on the best methods.

Kathy

0 Kudos
0 Replies