Help please: projection issue.

992
12
09-06-2011 11:14 PM
SanajyJadhav
Occasional Contributor II
Hi,

I have added 3 services as following;
1. Street map : spatial reference WKID 4326 ; added first and map's SR is set to this WKID.
2. Our data map service : spatial reference WKID 102100
3. Editable feature layer : spatial reference WKID 2229.

My requirement is to draw circle of specified size and at specified center point. I am giving center point in map's spatial reference.

When I add services that have same spatial reference ( e.g. WKID 2229), everything works fine.The circle (of radius say,50)gets drawn accurate.I checked it in ArcMap.

When I add World Street Map ( WKID 4326), along with my editable feature layer,I face issues.The drawn circle ( of radius say,50)is so big, that it covers complete America.

I know for sure that, this is projection issue.I just do not understand how to fix this.

I tried convert the center point of my circle to WKID 2229 using Geometry Service, but it is not getting re projected.So, I tried convert my drawn circle ( actually polygon) from 4326 to WKID 2229, again no use.

Can anybody help me fix this issue please? this is a crucial requirement for our project. Any help is appreciated.

Regards,
Sanjay.
0 Kudos
12 Replies
DominiqueBroux
Esri Frequent Contributor
So, I tried convert my drawn circle ( actually polygon) from 4326 to WKID 2229, again no use.


If you map spatial reference is 4326, shouldn't you convert from 2229 to 4326?
0 Kudos
SanajyJadhav
Occasional Contributor II
Thanks dbroux for the reply.

I am little confused here.The circle that I am drawing is already in 4326.Then also, it is not getting drawn properly.Sorry if I mislead in my last post.

The center point of the circle is in 4326.The code to create the polygon is as below.

Code:
[PHP]
ESRI.ArcGIS.Client.Geometry.Polygon polyg = new ESRI.ArcGIS.Client.Geometry.Polygon();
polyg.SpatialReference = map.SpatialReference; //polygon has spatial ref WKID 4326
polyg.Rings.Add(pointColl); //this pointColl has points which are in 4326.
[/PHP]

So, what should I do to get the correct circle? Thanks once again for your help.
-
Sanjay.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
The circle that I am drawing is already in 4326.

You don't show how your 'pointColl' points are initialized.
Is it initialized by using a center in geographical coordinates and a radius in geographical coordinates?
In this case, this should work without any additional projection.
0 Kudos
SanajyJadhav
Occasional Contributor II
Hi,

Below is my code to create point collection object that is run before creating the polygon.

[PHP]
  //create new point collection
            ESRI.ArcGIS.Client.Geometry.PointCollection pc = new ESRI.ArcGIS.Client.Geometry.PointCollection();

            n = n <= 0 ? 152 : n;
            for (int i = 0; i < n; i++)
            {
                //ecah point on the circle, counterclockwise
                double angle = (Math.PI * 2) / n * i;

                MapPoint mp = new MapPoint();
                mp.SpatialReference = map.SpatialReference;
                mp.X = ptCenter.X + dRadius * Math.Cos(angle);
                mp.Y = ptCenter.Y + dRadius * Math.Sin(angle);
                pc.Add(mp);
            }

            //add the last, which is exact the first, point.
            MapPoint lastVrtx = new MapPoint();
            lastVrtx.SpatialReference = map.SpatialReference;
            lastVrtx.X = ptCenter.X + dRadius;
            lastVrtx.Y = ptCenter.Y;
            pc.Add(lastVrtx);
[/PHP]

I am not sure when you say "Is it initialized by using a center in geographical coordinates and a radius in geographical coordinates?". when user clicks on the map, I have hooked to mouseClick event and I get the clicked point.And maps' projection is 4326. And radius is double value that user enters in TextBox.

Am I missing something or following the wrong approach?

Thanks.
Sanjay.
0 Kudos
DominiqueBroux
Esri Frequent Contributor

I have hooked to mouseClick event and I get the clicked point.And maps' projection is 4326.

OK so your circle center is in geographical coordinates --> that's OK.

And radius is double value that user enters in TextBox.

That may be the issue. The radius must be given in geographical coordinates (i.e.very small value in degrees not very intuitive for users).

If the radius is given in another units than degrees (meters, feet, kilometers, miles, ....?). You have to convert it to degrees.
0 Kudos
SanajyJadhav
Occasional Contributor II
Dominique,

Thanks for your continuous help on this issue.

could you tell me how to convert double value (radius)to degrees? Because had it (radius)been any coordinate, I would have converted it to degrees. So, is there any formula for it?I would appreciate help because when i googled I could not find any formula.

Thanks,
Sanjay.
0 Kudos
DominiqueBroux
Esri Frequent Contributor

could you tell me how to convert double value (radius)to degrees?


At equator, 1° is about 111320meters (earth radius * 2 * PI / 360).
But take care that due to the projection distorsion, a circle in geographical coordinates is not a circle in projected coordinates. Thus, you won't get a circle in your feature layer coordinates. It should be closer from an ellipse.
0 Kudos
SanajyJadhav
Occasional Contributor II
Thanks Dominique,

You are right. I am attaching the screen shots of the circles n both spatial references, please have a look at them.

But then question remains, what is the solution for this issue.Even if I convert radius to degrees and draw a circle, it would look like ellipse.Then, what could be solution for this?

-
Sanjay.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
If you want a circle in feature layer coordinates, you can create your circle in these coordinates and project it in the map coordinates before creating your graphic.
The process is not that simple:
    - get the center from the user click (thus in map coordinates)
    - project the center in feature layer coordinates by using a geometry service
    - build the polygon in feature layer coordinates  from the radius given by the user in meters
    - project the polygon in map coordinates
    - create your graphic with the projected polygon.
The graphic should look like an ellipse in map coordinates but should be a perfect circle in feature layer coordinates.
0 Kudos