XY Array


1万レコードなので1件あたりはそこまで差がないのだが…。
FeatureClassToNumPyArrayで多少マシ程度 ( 条件も絞れるので数多い場合は絞った方が良さそうだが )

Python
6594ミリ秒
3960ミリ秒
3741ミリ秒

ArcObjects
956ミリ秒
942ミリ秒
970ミリ秒

Python

# -*- coding: cp932 -*-
import arcpy
import time

fc = r"C:\jpn\jpn.gdb\rnd10k"

start = time.time()

array = arcpy.da.FeatureClassToNumPyArray(fc, ["SHAPE@XY"])

print time.time() - start

ArcObjects

var spWatch = new System.Diagnostics.Stopwatch();
spWatch.Start();

using (ComReleaser com = new ComReleaser())
{
  Type t = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
  IWorkspaceFactory wsf = (IWorkspaceFactory)Activator.CreateInstance(t);
  com.ManageLifetime(wsf);

  IFeatureWorkspace ws = (IFeatureWorkspace)wsf.OpenFromFile(@"C:\jpn\jpn.gdb", 0);
  com.ManageLifetime(ws);

  IFeatureClass fc = ws.OpenFeatureClass("rnd10k");
  com.ManageLifetime(fc);

  IFeatureCursor cursor = fc.Search(null, true);
  com.ManageLifetime(cursor);

  List<double[]> xyArray = new List<double[]>();

  IFeature feature = null;
  while ((feature = cursor.NextFeature()) != null)
  {
    var pt = (IPoint)feature.Shape;

    var d = new double[] { pt.X, pt.Y };
    xyArray.Add(d);

  }//end loop
}//end com

spWatch.Stop();
Console.WriteLine(spWatch.ElapsedMilliseconds);
カテゴリー: 開発 タグ: , パーマリンク