Can I use a featureset as input to analyze_patterns.interpolate_points?

793
5
Jump to solution
03-31-2017 11:05 AM
DavidJohnson5
Esri Contributor

The API guide for interpolate_points for the input_layer parameter mentions "see Feature Input in documentation".  Where do I find that documentation?  More specifically, I'm trying to figure out if I can use featureset as the input layer?  I'm currently getting this error:

---------------------------------------------------------------------------Exception                                 Traceback (most recent call last)<ipython-input-52-ba1e10e3e46c> in <module>()      1 from arcgis.features.analyze_patterns import interpolate_points----> 2 interpolated_sites = interpolate_points(solardatasites_fset, field='jul_ghi') C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\analyze_patterns.py in interpolate_points(input_layer, field, interpolate_option, output_prediction_error, classification_type, num_classes, class_breaks, bounding_polygon_layer, predict_at_point_layer, output_name, context, gis)    209         predict_at_point_layer,    210         output_name,--> 211         context)C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\tools.py in interpolate_points(self, input_layer, field, interpolate_option, output_prediction_error, classification_type, num_classes, class_breaks, bounding_polygon_layer, predict_at_point_layer, output_name, context)   1322         params = {}   1323 -> 1324         params["inputLayer"] = super()._feature_input(input_layer)   1325         params["field"] = field   1326         if interpolate_option is not None: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\tools.py in _feature_input(self, input_layer)    381             input_param =  {"url": input_layer_url }    382         else:--> 383             raise Exception("Invalid format of input layer. url string, feature service Item, feature service instance or dict supported")     384      385         return input_param Exception: Invalid format of input layer. url string, feature service Item, feature service instance or dict supported
0 Kudos
1 Solution

Accepted Solutions
RohitSingh2
Esri Contributor

You can construct an in-memory FeatureCollection object and that will work. The format of FeatureCollection is in the Feature Input page.

View solution in original post

0 Kudos
5 Replies
RohitSingh2
Esri Contributor

FeatureSets are not supported as input to the feature analysis tools.

The following are supported:

  • URL to feature layers
  • Items of type Feature Layer
  • Items of type Feature Collections
  • FeatureCollection as a Python dictionary
  • FeatureLayer objects
  • FeatureLayerCollection objects - the first layer is used.

The 'Feature Input' reference was to Feature input—ArcGIS REST API: Spatial Analysis Service | ArcGIS for Developers  but we should have it a better place in the Python API doc - thanks for alerting us to this.

0 Kudos
DavidJohnson5
Esri Contributor

Thanks Rohit the quick response!.  Would it be possible to construct an in-memory feature layer object from a FeatureSet to use as the tool input?  If not, can you suggest any alternatives for passing in a subset of points from a feature layer to the tool that does not involve creating a new feature layer item?

0 Kudos
RohitSingh2
Esri Contributor

You can construct an in-memory FeatureCollection object and that will work. The format of FeatureCollection is in the Feature Input page.

0 Kudos
DavidJohnson5
Esri Contributor

That works.  Thanks again!

my_featureset = my_flyr.query(where="state='WY'")

from arcgis.features import FeatureCollection
my_fc = FeatureCollection(my_featureset.to_dict())

from arcgis.features.analyze_patterns import interpolate_points
interpolated_points = interpolate_points(my_fc, field='GHI')

0 Kudos
RohitSingh2
Esri Contributor

All I can say is... "even better" !

0 Kudos