Zoom to Raster resolution

Source: Internet
Author: User

Don ' t execute the ESRI command, just find out and write codes to zoom to the raster resolution. Here they is, I hope they would help.

Unfortunately (to) I wrote these codes under C #. I hope you could manage the transfer these codes to VB. If not, feel free to contact me for further help. Because of this I'll write here some theory of mine too.

There is possible the solve this question.
1. You want to run this under ARCMAP (ArcCatalog) environment.
2. Want to use this under your own Mapcontrol and Toolbarcontrol with a raster (picture) where the Spatial Reference W ASN ' t set.

My Solutions:
1.
You can work with Mxdoc and you has set up Spatial Reference for the Map. Therefore You can use the Irasteroutputsettings::rasterratio method, which'll give back the necessary ratio (number).
In this case you can cast (QI in VB) to this interface from Idisplaytransformation.
Finally the formula here to calculate the raster resolution is:

New map scale = old map Scale/raster ratio.

See the code later.

2.
If you use a raster or a picture (in my case it is a raster from a raster field directly) and the Spatial Reference wasn ' T set for the layer or a map the raster ratio would give back 1, and it isn ' t so useful in the previous dividing formula. In the the the Mapcontrol, the size of the raster layer and use them in this relation form Ula

Map control Width/raster width = wanted map Scale/known, full extent map scale.

(If you want to use this later and you have to store the very first or the necessary raster full extent ' s scale! In the sample code below I didn ' t does that.)

From this:

Wanted map scale = map Control width/raster Width * Known, full extent map scale.


I hope these would help.

and the (C #) code cores is ...
 
1.://get mxdocumnet, cast (QI in VB), under VBA you can use it instantlyimxdocument Mxdoc = M_app. Document as Imxdocument;//get the Activeviewiactiveview Pactiveview = Mxdoc.activeview;//get the Displaytransformationidisplaytransformation pdisplaytransformation = Pactiveview.screendisplay.displaytransformation;//the Scale of the map (the Imap::mapscale was a shortcut to this method) does Uble Mapscale = Pdisplaytransformation.scaleratio;//get The rasteroutputsettings, with a cast (QI in VB) from Idisplaytran Sformationirasteroutputsettings prasteroutputsettings = pdisplaytransformation as irasteroutputsettings; Raster ratio, see the Help for discussion of the ratio numberdouble Rasterratio = prasteroutputsettings.rasterratio;//th E formula for the raster Resolutionpdisplaytransformation.scaleratio = (mapscale/rasterratio)//refreshing the MappActiv Eview.partialrefresh (esriviewdrawphase.esriviewgeography, NULL, NULL); 2.:/ /get the Mapimap pMap = m_hookhelper.focusmap;//get the raster layer,With cast (QI in VB) from ILayer, in my map it is the layer at 0 indexirasterlayer prasterlayer = pmap.get_layer (0) as Irasterlayer;//width of the Mapcontrol control on the formint controlwidth = Pmapcontrol.width;//because in the formula, Y  The OU has to use the width as a explicitly converted double number in c#double CONTROLW = convert.todouble (controlwidth); The formula for the raster Resolutionpmap.mapscale = (Controlw/prasterlayer.columncount * pmap.mapscale)//get the ACT Iveviewiactiveview Pactiveview = m_hookhelper.activeview;//refreshing the Mappactiveview.partialrefresh ( Esriviewdrawphase.esriviewgeography, NULL, NULL);

Zoom to Raster resolution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.