Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am having trouble running some ArcObjects C# code that calls create random points. I would not be doing this in ArcObjects, but I am suffering with the same issue using Arcpy as seen here: http://forums.arcgis.com/threads/12782-Python-scripting-and-creating-random-points?p=85866&viewfull=1#post85866

Any help as to the cause of this error would be greatly appreciated (Indeed, an official confirmation that create random points is bugged would also be appreciated).

code excerpt:

ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
//ESRI License Initializer generated code.
m_AOLicenseInitializer.InitializeApplication(
new esriLicenseProductCode[] { 
esriLicenseProductCode.esriLicenseProductCodeArcInfo }, 
new esriLicenseExtensionCode[] { esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst });
//ESRI License Initializer generated code.

//For some reason the license thing above doesn't always do the job so this is here
IAoInitialize ao = new AoInitialize();
ao.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo);

Geoprocessor gp = new Geoprocessor();
gp.OverwriteOutput = true;
gp.LogHistory = true;

//Input parameters
string constrainingFeatures = "lineRoute";
string outFeatures = "test";
string workspace = "\\\\1.2.3.4\\output\\Routes.gdb";

//Open workspace
IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass();
IWorkspace gdb;
try
{
    gdb = workspaceFactory.OpenFromFile(workspace, 0);
}
catch
{
    Console.WriteLine("Unable to open geodatabase");
    return;
}
IFeatureWorkspace fws = (IFeatureWorkspace)gdb;

//Get constraining feature class
IFeatureClass fc = fws.OpenFeatureClass(constrainingFeatures);

//Create random points - DOES NOT WORK WITH A PATH TO WORKSPACE OR THE IFeatureWorkspace
//CreateRandomPoints crp = new CreateRandomPoints(fws, outFeatures);
CreateRandomPoints crp = new CreateRandomPoints(workspace, outFeatures);
crp.number_of_points_or_field = "2000";
crp.minimum_allowed_distance = "1 Meter";

//DOES NOT WORK WITH A PATH TO cfc OR the IFeatureClass
//crp.constraining_feature_class = fc;
crp.constraining_feature_class = workspace + "\\" + constrainingFeatures;

//this out_feature_class does not seem to make a difference
crp.out_feature_class = workspace + "\\" + outFeatures;


try
{
    gp.Execute(crp, null);
}

Here is the log:

<ResultViews>
<ResultView Tool="Create Random Points">
<CommandLine>CreateRandomPoints_management \\1.2.3.4\Output\Routes.gdb \\1.2.3.4\Output\Routes.gdb\test \\1.2.3.4\Output\Routes.gdb\lineRoute '0 0 250 250' 2000 '1 Meters' POINT 0</CommandLine>
<ToolSource>C:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes\Data Management Tools.tbx\Feature Class\CreateRandomPoints</ToolSource>
<StartTime>Wed Mar 16 14:31:01 2011</StartTime>
<Parameters>
<Inputs>
<Parameter Label="Output Location" Type="Dataset">\\1.2.3.4\Output\Routes.gdb</Parameter>
<Parameter Label="Output Point Feature Class" Type="Scalar">\\1.2.3.4\Output\Routes.gdb\test</Parameter>
<Parameter Label="Constraining Feature Class" Type="Dataset">\\1.2.3.4\Output\Routes.gdb\lineRoute</Parameter>
<Parameter Label="Constraining Extent" Type="Scalar">0 0 250 250</Parameter>
<Parameter Label="Number of Points [value or field]" Type="Scalar">2000</Parameter>
<Parameter Label="Minimum Allowed Distance [value or field]" Type="Scalar">1 Meters</Parameter>
<Parameter Label="Create Multipoint Output" Type="Scalar">false</Parameter>
<Parameter Label="Maximum Number of Points per Multipoint" Type="Scalar">0</Parameter>
</Inputs>
<Outputs>
<Parameter Label="Output Feature Class" Type="Dataset">\\1.2.3.4\Output\Routes.gdb\\\1.2.3.4\Output\Routes.gdb\test</Parameter>
</Outputs>
</Parameters>
<Environments>
<Environment Label="Precision For New Coverages">SINGLE</Environment>
<Environment Label="Auto Commit">1000</Environment>
<Environment Label="Minimize memory use during analysis on terrains">false</Environment>
<Environment Label="Compression">LZ77</Environment>
<Environment Label="Coincident Points">MEAN</Environment>
<Environment Label="Random number generator">0 ACM599</Environment>
<Environment Label="Raster Statistics">STATISTICS 1 1</Environment>
<Environment Label="Level Of Comparison Between Projection Files">NONE</Environment>
<Environment Label="Output has Z Values">Same As Input</Environment>
<Environment Label="Maintain fully qualified field names">true</Environment>
<Environment Label="Tile Size">128 128</Environment>
<Environment Label="Pyramid">PYRAMIDS -1 NEAREST DEFAULT 75</Environment>
<Environment Label="Default TIN storage version">CURRENT</Environment>
<Environment Label="Output Spatial Grid 1">0</Environment>
<Environment Label="Cell Size">MAXOF</Environment>
<Environment Label="Output has M Values">Same As Input</Environment>
<Environment Label="Output Spatial Grid 2">0</Environment>
<Environment Label="Output Spatial Grid 3">0</Environment>
<Environment Label="Maintain Spatial Index">false</Environment>
<Environment Label="Precision For Derived Coverages">HIGHEST</Environment>
</Environments>
<Errors>
<Error>ERROR 999999: Error executing function.</Error>
<Error>Failed to execute (CreateRandomPoints).</Error>
</Errors>
<EndTime>36.00 seconds)</EndTime>
</ResultView>
</ResultViews>

The only other output message is:

Error HRESULT E_FAIL has been returned from a call to a COM component.

I also posted this here: http://forums.arcgis.com/threads/26029-Create-Random-Points-fails-with-ERROR-999999-Error-executing-function.

Thanks!

share|improve this question
1  
Is this a standalone exe? If so are you initializing the license? –  Kirk Kuykendall Mar 16 '11 at 20:06
    
Eddie, are you using 10.0 sp1? I found another bug (crashes when creating large numbers of random points) that was included in sp1. It's not listed in the issues fixed for the patch because it came in as a crash dump report. Um, never mind, as I found NIM061594 (not fixed yet) which appears to be a duplicate of nim064833. –  mkennedy Mar 16 '11 at 21:23
    
Hi, I am using 10.0 sp1. I am also initializing the license (I added the code above). –  Eddie Jesinsky Mar 17 '11 at 13:55
add comment

1 Answer

In early February, ESRI acknowledged the python part of your question as a bug when I asked for support: [#NIM064833 ArcPy.CreateRandomPoints_management crashes ArcMap when run as a script tool]

I suspect that the same bug is precluding using the tool from ArcObjects.

share|improve this answer
4  
Wouldn't it be nice if ESRI would use a public bug tracker, so we wouldn't have to individually reproduce all this head banging. –  Regan Sarwas Mar 16 '11 at 20:04
1  
If you're logged into the Esri website, you can search for bugs. You get the headline and workaround (if any known) only. Admittedly, I had trouble turning up NIM064833 because I didn't search for CreateRandomPoints_management ("Create random points" nor "createrandompoints" didn't turn it up). If you have the nimbus number, you can search those (nim064833). std disclaimer: I work for Esri. –  mkennedy Mar 16 '11 at 20:56
    
@mkennedy, Thanks. I'd searched before, but never found it. Here is more info on Bugs Online. –  Regan Sarwas Mar 16 '11 at 21:15
    
Thanks, I always have trouble finding out if bugs have been confirmed (I usually just post here or on the esri forums and hope for some confirmation). –  Eddie Jesinsky Mar 17 '11 at 14:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.