<\/P>
以下の例ではオランダのデータを使用しています。
## ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<\/SPAN>## スクリプト: agol_define_areas_of_interest_on_hosted_feature_layer_views.py<\/SPAN>## 目的: 入力ジオメトリを使用して複数の Hosted Feature Layer View 上で関心領域を定義すること<\/SPAN>## 著者: Egge-Jan Polle - Tensing GIS Consultancy<\/SPAN>## 日付: 2019年3月27日<\/SPAN>## ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<\/SPAN>#<\/SPAN># このスクリプトは特定の ArcGIS/Python 環境内で以下のバッチファイルを使って実行してください<\/SPAN># (このバッチファイルは ArcGIS Pro のインストール時に付属しています)<\/SPAN># "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\scripts\\propy.bat" agol_define_areas_of_interest_on_hosted_feature_layer_views.py<\/SPAN>from<\/SPAN> arcgis.<\/span>gis import<\/span> GISfrom.features import FeatureLayerCollectionfrom provide_credentials import provide_credentialsusername, password = provide_credentials()my_agol = GIS("https://www.arcgis.com", username, password)# 全国データセットを含む Hosted Feature Layerpolice_stations = my_agol.content.get('')police_stations_flc = FeatureLayerCollection.fromitem(police_stations)# 地域区分を含む Hosted Feature Layerprovinces = my_agol.content.get('').layers[0].query()# 空間参照を取得spat_ref = provinces.spatial_reference# 地域区分ごとにループしてビューを作成for index, province in enumerate(provinces): prov_name = provinces.features[index].attributes['Provincienaam'].upper().replace('-', '_') print(prov_name) view_name = police_stations.name + "_" + prov_name + "_View" print(view_name) # 地域のジオメトリを取得 view_geom = provinces.features[index].geometry.get('rings') new_view = police_stations_flc.manager.create_view(name=view_name) # 新しく作成されたビューを検索 view_search = my_agol.content.search(view_name)[0] view_flc = FeatureLayerCollection.fromitem(view_search) service_layer = view_flc.layers[0] # update_dict にジオメトリと空間参照情報を設定 update_dict = {"viewLayerDefinition": {"filter": {"operator":"esriSpatialRelContains","value":{"geometryType":"esriGeometryPolygon","geometry":{"rings": view_geom,"spatialReference":spat_ref}}}}}# 関心領域を含めるように定義を更新します service_layer.manager.update_definition(update_dict)print('完了!')
Works for my case exactly.
Thanks,
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.