+ Reply to Thread
Results 1 to 6 of 6

Thread: convert point xy coordinate from degree to metres

  1. #1
    long cui
    Join Date
    Jul 2010
    Posts
    11
    Points
    0
    Answers Provided
    0


    0

    Default convert point xy coordinate from degree to metres

    Hi folks,

    I have a map service which coordinate is in GDA94 and unit is in metre. I have created a point which performs spatial query.

    my code is simple

    localhost.PointN pPoint = new localhost.PointN();
    pPoint.X = m_x;
    pPoint.Y = m_y;

    when the point xy coordinate input is in metre, it works fine.

    my requirement right now is xy coordinate should be in degree.

    Does arcgis server soap api provide interface to transfer degree to metre.

    thanks

  2. #2
    Deepak V
    Join Date
    Feb 2012
    Posts
    7
    Points
    0
    Answers Provided
    0


    0

    Default Re: convert point xy coordinate from degree to metres

    Hi choilon ,

    In Geometry service there is a method called "Project". With this method we can convert xy coordinates from Decimal Degrees to meters.
    public ESRI.ArcGIS.ADF.Web.Geometry.Point projection(ESRI.ArcGIS.ADF.Web.Geometry.Point point)
    {
    #region projection DECIMAL DEGREES TO METERS
    string conection = ConfigurationManager.ConnectionStrings["geom"].ToString();

    GeometryServerProxy gsp = new GeometryServerProxy("<geometryserver url>");
    SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
    // WGS_1984(world) to Mercator
    inputSpatialReference.WKID = 4326;// esriSRProjCS_WGS1984WorldMercator WGS 1984 World Mercator.
    inputSpatialReference.WKIDSpecified = true;
    SpatialReference outputSpatialReference = new ProjectedCoordinateSystem();
    outputSpatialReference.WKID = 54004;
    outputSpatialReference.WKIDSpecified = true;
    GeoTransformation transformation = new GeoTransformation();
    // esriSRProjCS_WGS1984WorldMercator TO WGS 1984 World Mercator. AND VICEVERSA
    transformation.WKID = 1156;
    transformation.WKIDSpecified = true;
    ESRI.ArcGIS.ADF.ArcGISServer.Geometry[] inputGeometry = new ESRI.ArcGIS.ADF.ArcGISServer.Geometry[] { ESRI.ArcGIS.ADF.ArcGISServer.Converter.FromAdfPoint((point)) };
    bool transformForward = false;
    EnvelopeN extent = null;
    ESRI.ArcGIS.ADF.ArcGISServer.Geometry[] outputGeometry = gsp.Project(inputSpatialReference, outputSpatialReference, transformForward, transformation, extent, inputGeometry);
    ESRI.ArcGIS.ADF.Web.Geometry.Point webpt = ESRI.ArcGIS.ADF.ArcGISServer.Converter.ToAdfPoint(outputGeometry[0] as PointN);
    return webpt;
    #endregion
    }

    Try this by changing the input spatial reference and output spatial reference WKID

    Regards,
    Deepak.

  3. #3
    Tanu Hoque
    Join Date
    Dec 2009
    Posts
    139
    Points
    87
    Answers Provided
    15


    0

    Default Re: convert point xy coordinate from degree to metres

    Choilon,
    You don't need to project your search shape for query operation.
    All you need to do is to define the spatialReference for the search shape.

    In you case, it should be something like
    Code:
    pPoint.SpatialReference = aGCSProjection;
    When a search shape's (i.e. pPoint) SpatialReference is not defined, MapServer assumes it is in layer's projection. That's the reason your query is not returning any result.

    Tanu

  4. #4
    long cui
    Join Date
    Jul 2010
    Posts
    11
    Points
    0
    Answers Provided
    0


    0

    Default Re: convert point xy coordinate from degree to metres

    Thanks for reply. Actually I have tried to create a new geographiccoodinatesystem and sign to point's spatial reference. It still does not work.

    SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
    inputSpatialReference.WKID = 4326;
    inputSpatialReference.WKIDSpecified = true;
    pPoint.spatialreference = inputSpatialReference

    The basic problem is my input point and map service use same coordinate system, but point's xy coordinate is in degree. Because the map service unit is in metre, it automatically take x,y input as metre rather than degree.

    Point.x = X; --- X is input in degree.

    Is there an interface or function can convert degree to metre in the same coordinate system?

    thanks,
    choilon

  5. #5
    Tanu Hoque
    Join Date
    Dec 2009
    Posts
    139
    Points
    87
    Answers Provided
    15


    0

    Default Re: convert point xy coordinate from degree to metres

    Quote Originally Posted by choilon View Post
    The basic problem is my input point and map service use same coordinate system, but point's xy coordinate is in degree. Because the map service unit is in metre, it automatically take x,y input as metre rather than degree.
    Choilon,
    I'm afraid I haven't understood it correctly. You are saying your 'search point' and mapservice are in same coordinate system, but 'search point's coordinates are in degree whereas mapservice in meter!!

    Can you provide me a sample data/map and your code for me to take a look at?

    Thanks.

    Tanu

  6. #6
    Deepak V
    Join Date
    Feb 2012
    Posts
    7
    Points
    0
    Answers Provided
    0


    0

    Default Re: convert point xy coordinate from degree to metres

    Hi Choilon,


    Try to use the project method once. Convert the decimal degree to Meters.
    You mentioned the GCS as inputspatial reference, provide map spatial reference as Projected Coordinate System. Then Your decimal degree point will convert into meters.

    Regards,
    Deepak.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts