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 need to be able to convert a lat/long coordinate into a point coordinate and am having trouble getting my code to work. I created a test app isloating the code that is giving me problems. I'm running ArcSDE 9.3.1 SP2 on my local machine and also have it running on another box on the network, Jester. If I run my test code with passing in "localhost" to be the host, it works fine. If I pass in "Jester", I get the error: System.UnauthorizedAccessException: Access is Denied (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) and it occurs on the line where I do geom.ProjectEx. The S4_SPATIAL geodataService is created from the same database on both boxes.

In the code this snippet came from, I use the same server context created from the same geodata service on Jester and it works fine ( I can get to all my tables, feature classes and locators, I can query them, etc.), except when I try to do geom.ProjectEx. I've looked online for this error and haven't been able to find anything helpful. Apparently its a pretty generic message.

Does anyone have any idea why it would work on my local server but not on the other? What am I missing?

static void Main(string[] args)

    double latitude = 25.73338;
    double longitude = -80.3207233333334;

    IGISServerConnection conn = new GISServerConnection();

    string host = args[0];;

    IServerObjectManager som = conn.ServerObjectManager;
    IServerContext gdbContext = som.CreateServerContext("S4_Spatial", "GeodataServer");

    IPoint pt = (IPoint)gdbContext.CreateObject("esriGeometry.Point");
    pt.Y = latitude;
    pt.X = longitude;

    // Create spatial reference for the latitude and longitude point
    SpatialReferenceEnvironment spatialReferenceEnv = (SpatialReferenceEnvironment)gdbContext.CreateObject("esriGeometry.SpatialReferenceEnvironment");
    ISpatialReference latlongRef = spatialReferenceEnv.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
    pt.SpatialReference = latlongRef;

    // Get spatial reference of the map 
    ISpatialReference outgoingCoordSystem = spatialReferenceEnv.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_NAD1983HARN);

    NADCONTransformation datumConversion = new NADCONTransformation(spatialReferenceEnv.CreateGeoTransformation((int)esriSRGeoTransformation2Type.esriSRGeoTransformation_NAD_1983_TO_HARN_FL));

    IGeometry2 geom = (IGeometry2)pt;
    geom.SpatialReference = latlongRef;

    // Project the latitude and longitude to map coordinate system
    geom.ProjectEx(outgoingCoordSystem, esriTransformDirection.esriTransformForward, (IGeoTransformation)datumConversion, false, 0.0, 0.0);

    IPoint newPt = (IPoint)geom;
    Console.WriteLine(newPt.X + " , " + newPt.Y);
share|improve this question
did you try using gdbContext.CreateObject to create datumConversion (instead of new)? –  Kirk Kuykendall May 24 '11 at 18:56
I had thought of that but couldn't figure out how! I mean I could figure out how to create a new one using CreateObject but I didn't know what to do with the parameters. I couldn't find any help on that. –  mfowler May 24 '11 at 19:02
try setting nadcontransformation = spatialReferenceEnv.CreateGeoTransformation(...) directly, I think it should return a nadcon transformation. –  Kirk Kuykendall May 24 '11 at 19:38
Kirk - that fixed it! –  mfowler May 24 '11 at 20:54
add comment

1 Answer

up vote 3 down vote accepted

try setting nadcontransformation = spatialReferenceEnv.CreateGeoTransformation(...) directly, I think it should return a nadcon transformation.

share|improve this answer
add comment

Your Answer


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.