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 want to set extent of the map into envelope which sizes are defined by user in miles(kilometers, whatever human readable unit). How to make it? I wrote the following code:

static void ZoomToPoint(IActiveView focusMap, ExportJson2Feature.Geometry geom)
{
    IPoint point = new PointClass();
    point.PutCoords(geom.X, geom.Y);

    IEnvelope newExtentEnvelope = point.Envelope;
    newExtentEnvelope.Expand(1, 1, false);
    ((IGeometry)newExtentEnvelope).Project( ((IMap)focusMap).SpatialReference );
    focusMap.Extent = newExtentEnvelope;
}

How to make it know that sizeX/sizeY are in miles?

share|improve this question
add comment

2 Answers 2

up vote 7 down vote accepted

Geometry's coordinates are always specified in its spatial reference's units. Unit conversions are best done by using the UnitConverter class.

If that's any help, you can determine the currently used map units by IMap.MapUnits.

If your point coordinates are in lat/lon (such as the WGS84 spatial reference), you probably want to decide on a projected coordinate system first and use that when working with distances.

share|improve this answer
add comment

If your extent will be covering a large range of latitudes or areas near the poles, you may benefit from calculating the extent using a geodesic distance from the centroid.

You can use IConstructGeodetic.ConstructGeodesicCircle to create a polygon. Then you can invoke IGeometry.Envelope to get an envelope.

share|improve this answer
add comment

Your Answer

 
discard

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.