Select to view content in your preferred language

Writing features to a feature class by a batch process

915
12
Jump to solution
10-22-2024 02:53 PM
TyroneLigon1
Regular Contributor

I apologize in advance that I can't post any of our code. We have an add-in that manages the display of a couple of WMS services. A feature of the add-in is the ability to export the displayed points to a feature class. We accomplish this by running a WFS request; it returns a GeoJSON list of features, which we then write to a new feature class.

The issue is that the user might have tens of thousands of points on the map, and in some cases over 100,000 features. The add-in iterates through this list and adds the features to the feature class one at a time. In the test I ran, it took almost 3 minutes to write about 14,000 features. We were wondering if there's a batch write method somewhere in the SDK, or maybe we incorporate a Python script to do the feature writing.

0 Kudos
1 Solution

Accepted Solutions
Aashis
by Esri Contributor
Esri Contributor

@TyroneLigon1 , The Insert Cursor API should be used for your level of bulk insertion; it is designed to insert faster rows in the Pro SDK.

View solution in original post

0 Kudos
12 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Have you tried to call geoprocessing tool Batch import data from you add'in? It can import GeoJSON to featureclass.

0 Kudos
TyroneLigon1
Regular Contributor

Can I call the tool via Geoprocessing.ExecuteToolAsync? If so, what is the tool's alias?

Otherwise, will I have to open the tool in the geoprocessing panel? If so, do I have to save the GeoJSON to the file system, then have the user open the file and specify the geodatabase location? Or, can I populate those fields on my own?

0 Kudos
GKmieliauskas
Esri Regular Contributor

Yes, You can call Geoprocessing.ExecuteToolAsync. Tool name will be "BatchImportData_intelligence". You need to have minimum Standard ArcGIS Pro license to use that tool.

0 Kudos
TyroneLigon1
Regular Contributor

Do I first execute Geoprocessing.MakeValueArray with the GeoJSON and the geodatabase location as the arguments? Also, how can I then specify the feature class name? Currently, we first create the feature class in the map project's default geodatabase (the name is a concatenation of a timestamp and WMS layer name), then we add the fields, then we populate the feature class one feature at a time.

0 Kudos
GKmieliauskas
Esri Regular Contributor

Yes, you need to create parameters first:

        IReadOnlyList<string> importParams = Geoprocessing.MakeValueArray(@"c:\data\sourcedata", @"\\data\operationaldata.sde", "*airports*.shp", "NO_SUBFOLDERS");
        IGPResult result = await Geoprocessing.ExecuteToolAsync("intelligence.BatchImportData", importParams);
        if (result.IsFailed)
        {
          MessageBox.Show("Unable to import", "Batch import");
          return;
        }

Parameters from documentation sample. Use yours. As I understand featureclass names will be created automatically from source names. After you can rename them.

0 Kudos
TyroneLigon1
Regular Contributor

Can you give me a link to this sample? I can't find it in the Pro SDK documentation.

0 Kudos
GKmieliauskas
Esri Regular Contributor

Link is above. This is python sample at the bottom of page. There is no documentation for each geoprocessing tool for ArcGIS Pro SDK for .NET.

0 Kudos
TyroneLigon1
Regular Contributor

Sorry, I got pulled away from this project for a few days. The parameter array is failing - I believe it's because I'm directly injecting a GeoJSON list object. Do I have to save the list to the file system first?

0 Kudos
GKmieliauskas
Esri Regular Contributor

Yes. Documentation says that first parameter must be file or folder:

Name Explanation Data Type
in_data
[in_data,...]

The folders containing the data files or the data files to convert to geodatabase feature classes.

Folder; File
0 Kudos