![]() Public Sub Test() ' This code expects the first layer in the TOC to be a raster ' Get map Dim pMXD As IMxDocument Set pMXD = ThisDocument Dim pMap As IMap Set pMap = pMXD.FocusMap ' Get raster Dim pLayer As ILayer Set pLayer = pMap.Layer(0) Dim pRasterLayer As IRasterLayer Set pRasterLayer = pLayer ' Get extent Dim pGeoDataset As IGeoDataset Set pGeoDataset = pRasterLayer Dim pEnv As IEnvelope Set pEnv = pGeoDataset.Extent ' Test minimum value, assumes rasters are not in decimal degrees If pEnv.XMin = -0.5 Then Debug.Print "This raster has no extent so can't be geo-referenced!" Else Debug.Print "This raster is geo-referenced!" End If End Sub The limitation with this example is that it is assumed that the raster is not in a geographical coordinate system. I leave it up to you to wrap it up into a loop. So knowing that, the VBA code below demonstrates how to test for this. You could have a scenario where an image has a world file but no projection information but it would return an extent. If am image has been geo-referenced then it should return an extent. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |