如何将像素坐标转为地图坐标(转载)

public System.Double ConvertPixelsToMapUnits(ESRI.ArcGIS.Carto.IActiveView activeView, System.Int32 pixelUnits)
{
 
  if(activeView == null)
  {
    return -1;
  }
  //Get the ScreenDisplay
  ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;

  //Get the DisplayTransformation
  ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation;

  //Get the device frame which will give us the number of pixels in the X direction
  ESRI.ArcGIS.Display.tagRECT deviceRECT = displayTransformation.get_DeviceFrame();
  System.Int32 pixelExtent = (deviceRECT.right - deviceRECT.left);

  //Get the map extent of the currently visible area
  ESRI.ArcGIS.Geometry.IEnvelope envelope = displayTransformation.VisibleBounds;
  System.Double realWorldDisplayExtent = envelope.Width;

  //Calculate the size of one pixel
  if(pixelExtent == 0)
  {
    return -1;
  }
  System.Double sizeOfOnePixel = (realWorldDisplayExtent / pixelExtent);

  //Multiply this by the input argument to get the result
  return (pixelUnits * sizeOfOnePixel);
}

 

转载自:ms-help://MS.VSCC.v90/MS.VSIPCC.v90/ESRI.EDNv9.3/Snippets/html/cabbae3d-ccaf-40cb-9bb6-b4fc44fb125e.htm


 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值