creating an Envelope in Kilometer unit ?

524
3
08-30-2010 08:59 AM
AbdulrahmanAlqasim
New Contributor
guys , i need to create an envelope 10 x 10 kilometers.


pEnvelope.PutCoords(pCenter.X - tenKM_X, pCenter.Y - tenKM_Y, pCenter.X + tenKM_X, pCenter.Y + tenKM_Y);


the problem is that pCenter.X and pCenter.Y is in decimal degrees. is there away to do this ??

thank you
0 Kudos
3 Replies
ThavitinaiduGulivindala
Occasional Contributor
Hi,

You can convert KM to DecimalDegrees and pass the values to the PutCoords method as shown below.

IUnitConverter unitConvertorObj = new UnitConverter();

double kmInDecimalDegrees = unitConvertorObj.ConvertUnits(10, esriUnits.esriKilometers, esriUnits.esriDecimalDegrees);
//This gives u the 10KM equivalent in DecimalDegrees.

pEnvelope.PutCoords(pCenter.X - kmInDecimalDegrees , pCenter.Y - kmInDecimalDegrees , pCenter.X + kmInDecimalDegrees , pCenter.Y + kmInDecimalDegrees );

Beware that above statement seems to create and envelope of 20km x 20km. If u want to create 10km x 10km envelope then pass 5 in ConvertUnits method.
http://edndoc.esri.com/arcobjects/9.0/ComponentHelp/esriSystem/IUnitConverter.htm
0 Kudos
AbdulrahmanAlqasim
New Contributor
hi thaviti
thank you very much, i thought that will solve my problem. however now im facing strange problem which is:

(using ArcMap editor) i created a horizontal  polyline of 10 km at the northern hemisphere , when i copy or move this line to the area of the equator then it gets longer , around 11.5 km. im using WGS1984 as coordinate system.
in other words, when i move this line to south it get bigger.
i need to have same length . how i can solve this problem

this is not the case when i use vertical line.
thank you
0 Kudos
NeilClemmons
Regular Contributor III
Because the earth isn't flat, conversion from a linear unit to decimal degrees (and vice versa) isn't constant.  One decimal degree converted to kilometers will vary depending on where you are on the earth's surface.  One way to do a realistic conversion is to use a projected coordinate system.  Which PCS you use depends on where you are.  The process would be to project your center point to a PCS that makes sense for where you are.  Since you are wanting to convert to kilometers, a PCS that uses meters for its linear unit would make things easier (UTM for example).  After your point is projected, you can create your envelope by adding/subtracting from the center point's x,y coordinates.  Once the envelope is created, you can project it back to the original geographic coordinate system if you need to.
0 Kudos