POST
|
Hi, We just upgrade from ArcObjects 10.1 to 10.2.2 and now we're having a problem where the Geographic Coordinate System (GCS) object gets corrupted after calling the DefineEx (or Define) method a few times (see code sample 1). I found a workaround by pulling the GCS object from a projection coordinate system object (see code sample 2). Is there any reason for this behavior and how can I create a Geographic Coordinate System from a factory code? Thanks, Niro Code Sample 1
int numberOfErrors = 0;
for (int i = 0; i < 1000; i++)
{
var spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); //(ISpatialReferenceFactory4)Activator.CreateInstance(Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"));
var geographicCoordinateSystem = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_NAD1983) as IGeographicCoordinateSystem;
// var projectedCoordinateSystem = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983UTM_17N);
// var geographicCoordinateSystem = projectedCoordinateSystem.GeographicCoordinateSystem;
(geographicCoordinateSystem as IGeographicCoordinateSystemEdit).DefineEx(
geographicCoordinateSystem.Name,
geographicCoordinateSystem.Alias,
geographicCoordinateSystem.Abbreviation,
geographicCoordinateSystem.Remarks,
geographicCoordinateSystem.Usage,
geographicCoordinateSystem.Datum,
geographicCoordinateSystem.PrimeMeridian,
geographicCoordinateSystem.CoordinateUnit);
if (String.IsNullOrEmpty(geographicCoordinateSystem.Name))
numberOfErrors++;
}
Code Sample 2
int numberOfErrors = 0;
for (int i = 0; i < 1000; i++)
{
var spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); //(ISpatialReferenceFactory4)Activator.CreateInstance(Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"));
// var geographicCoordinateSystem = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_NAD1983) as IGeographicCoordinateSystem;
var projectedCoordinateSystem = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983UTM_17N);
var geographicCoordinateSystem = projectedCoordinateSystem.GeographicCoordinateSystem;
(geographicCoordinateSystem as IGeographicCoordinateSystemEdit).DefineEx(
geographicCoordinateSystem.Name,
geographicCoordinateSystem.Alias,
geographicCoordinateSystem.Abbreviation,
geographicCoordinateSystem.Remarks,
geographicCoordinateSystem.Usage,
geographicCoordinateSystem.Datum,
geographicCoordinateSystem.PrimeMeridian,
geographicCoordinateSystem.CoordinateUnit);
if (String.IsNullOrEmpty(geographicCoordinateSystem.Name))
numberOfErrors++;
... View more
06-06-2014
12:56 PM
|
0
|
0
|
502
|
POST
|
No we couldn't get the raster calculator to work. We worked around the issue by using other raster processing tools (Con, Int, Plus, Minus, Times, Divide, IsNull, etc.) in series. Regards, Niro
... View more
01-23-2014
05:29 AM
|
0
|
0
|
328
|
POST
|
Hi, We just upgraded from ArcEngine 10 to 10.1 and now the raster calculator does not seem to work anymore. Whenever I execute the geoprocesing tool, we get a LoaderLock was detected error and we are unable to continue. If I turn off the Loader Lock exception in Visual Studio, it get's a bit further and the application throws a C++ Runtime Error R6034 (Application has made an attempt to load the C run time library incorrectly). If I check the geoprocessing message logs I see a ERROR 000539: Runtime error (AttributeError: 'geoprocessing sys.stdout object' object has no attribute 'write') When I try to run the same thing in ArcMap's Raster Calculator it works fine. Any idea what going on? Thanks. Niro I'm using the following code to execute the raster calculator: String expression = @"'C:\Temp\RasterCalc\dem_pre' * 10";
String outputPath = @"C:\Temp\FloodPlain24";
Geoprocessor processor = new Geoprocessor();
RasterCalculator RasterCalc = new RasterCalculator(expression, outputPath);
FileInfo fileInfo = new FileInfo(outputPath);
try
{
if (!fileInfo.Directory.Exists) fileInfo.Directory.Create();
processor.OverwriteOutput = true;
processor.Execute(RasterCalc, null);
}
catch (Exception ex)
{
Debug.Assert(false, ex.ToString());
Debug.Write(GetMessages(processor));
} The full geoprocessing log is as follows: Executing: RasterCalculator "'C:\Temp\RasterCalc\dem_pre' * 10" C:\Temp\FloodPlain24
Start Time: Wed Apr 03 09:52:45 2013
Raster(r'C:\Temp\RasterCalc\dem_pre') * 10
ERROR 000539: Runtime error
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.1\Lib\warnings.py", line 29, in _show_warning
file.write(formatwarning(message, category, filename, lineno, line))
AttributeError: 'geoprocessing sys.stdout object' object has no attribute 'write'
Failed to execute (RasterCalculator).
Failed at Wed Apr 03 09:54:26 2013 (Elapsed Time: 1 minutes 41 seconds)
... View more
04-03-2013
06:09 AM
|
0
|
3
|
2534
|
POST
|
I think what the OP is asking is if it is possible to create packages in runtime without Arcmap. From what I read, it's not possible, but maybe in a future version of the SDK. Niroshan
... View more
01-23-2013
08:48 AM
|
0
|
0
|
534
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|