Select to view content in your preferred language

Adding feature layers using Plugins for different file extensions in ArcGIS Pro .Net SDK

1149
7
01-03-2023 01:14 AM
RITASHKOUL
Regular Contributor

 

I have successfully implemented multiple file extensions to be added as Plugin data sources to the map as feature layers. Some of them are new types and some are which are recognizable to Pro(like csv). For the new types I have created the Pro Custom Item to be started with. And for the ones which are recognizable to Pro as per the documentation there is no need. This is as per the Pro docs

File extension already in use by ArcGIS Pro (including portal, on-line, geodatabases, toolboxes, etc) cannot be overridden/extended with a custom item. This includes text files, xml files, folders, database connection files, layer files, task files, mxds, sxds, etc. Custom items defined on content types in use by ArcGIS Pro will be ignored.


I have also added multiple ways to add the data source like Context Menus, Drag and Drop and using Add Data in the Ribbon.

This is mostly achieved using interface IMappableItem and implementing the below method for the Custom Item class

public List<string> OnAddToMap(ArcGIS.Desktop.Mapping.Map map)

But how to achieve these use cases to add as feature layers for extensions like CSV. Because for CSV Add Data in the Ribbon is just adding the standalone table. And for CSV I am not sure how to add the custom context menu implementation for Add To Current Map and Add To New Map.

So the question is how to achieve these use cases for File extensions already in use by ArcGIS Pro.

Right now to add the plugin as a feature layer for CSV is just handled using Drag and Drop handler. But how to achieve all the below use cases for CSV:

"Add Data" dialog
"Add Data from Path" dialog
drag/drop of your item from the catalog window to a map
drag/drop of your item from the catalog window to the TOC
drag/drop of your item from windows explorer to a map
drag/drop of your item from windows explorer to the TOC

Tags (1)
0 Kudos
7 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

To add csv as feature layer you need to execute xy table to point geoprocessing tool.

The same as in ribbon "Add Data" - "XY Point Data"

0 Kudos
RITASHKOUL
Regular Contributor

So we cant add a custom code to add csv or text as a feature layer like a plugin data source using below use cases for .net sdk

 

"Add Data" dialog
"Add Data from Path" dialog
drag/drop of your item from the catalog window to a map
drag/drop of your item from the catalog window to the TOC
drag/drop of your item from windows explorer to a map
drag/drop of your item from windows explorer to the TOC

And also as a Add To Custom Map and Add To New Map. 

Because by default it will only add it as a standalone table.

@GKmieliauskas 

0 Kudos
GKmieliauskas
Esri Regular Contributor

There is Esri ArcGIS Pro SDK community sample with exactly csv data:

https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Authoring/AddToMapCustomIte... 

 

It adds csv data in  List<string> IMappableItem.OnAddToMap(Map map) method.

0 Kudos
RITASHKOUL
Regular Contributor

This doesnt seems to be for CSV

<content displayName="AddToMap" fileExtension="uxh" isContainer="false" keywords="AddToMap" contextMenuID="AddToMapCustomItem_AddToMap_ContextMenu">

And as per the Pro docs if we will create the custom item for file extensions used by Pro like CSV or TXT, custom items will be ignored. And if custom items are ignored then there is no use of implementing OnAddToMap method.

Below is the mention:

File extension already in use by ArcGIS Pro (including portal, on-line, geodatabases, toolboxes, etc) cannot be overridden/extended with a custom item. This includes text files, xml files, folders, database connection files, layer files, task files, mxds, sxds, etc. Custom items defined on content types in use by ArcGIS Pro will be ignored.

 

@GKmieliauskas 

0 Kudos
GKmieliauskas
Esri Regular Contributor

You can change file extension to csvx or something like that. If content of your file will be csv formatted then you can use code from sample, which uses exactly the same geoprocessing tool as I mentioned earlier.

0 Kudos
RITASHKOUL
Regular Contributor

I am still not sure why to create custom item if as per docs it is mentioned that it will be ignored.

@GKmieliauskas 

0 Kudos
GKmieliauskas
Esri Regular Contributor

CSV is not strong structured format, why you can load csv formatted files using different file extensions. For example, your csv formatted files could have different content.

First file columns: X, Y, attribute1, attribute2

Second file columns: attribute, X, Y

And etc.

So, each csv formatted file with different field order must have different plugin. For strongly formatted files there is no need to have different plugins.

0 Kudos