Hi,I am not sure if this is the correct location for this query, but here it is.I am trying to export data from the data view in ArcMap to a georeferenced JPG or Tiff.I can do it manually, however I would like to automate the process to export based upon a polygon layer.I have been able to get the code working, however, the coordinates of the exported raster (Tiff) have not been preserved.Could someone please point me in a direction of some documentation of how best to do this?Please find my code below:I know its a little rough, its a work in progress I have found some examples online have have spliced things together as I see it could work.Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim pEFeat As IEnumFeature
Dim papp As IApplication
Dim pmxdoc As IMxDocument
Dim pmap As IMap
Dim pFLayer As IFeatureLayer
Dim pFClass As IFeatureClass
papp = My.ArcMap.Application
pmxdoc = papp.Document
pmap = pmxdoc.FocusMap
pFLayer = pmxdoc.SelectedItem
pFClass = pFLayer.FeatureClass
Dim pFCursor As IFeatureCursor
pFCursor = pFLayer.Search(Nothing, False)
Dim pFeature As IFeature
pFeature = pFCursor.NextFeature
Do While Not pFeature Is Nothing
'******************************
Dim MapSheet As String
Dim BatchField As String
Dim pfd As IFeatureLayerDefinition
Dim pActiveView As IActiveView
Dim pExporter As IExporter
Dim pEnv As IEnvelope
Dim exportFrame As tagRECT
Dim pWorldFile As IWorldFileSettings
Dim hdc As Long
Dim pqfilter As IQueryFilter
pfd = pmxdoc.SelectedLayer
BatchField = "TAG"
MapSheet = pFeature.Value(pFeature.Fields.FindField("TAG")) 'pFLayer.value(pFLayer.fields.findfield("MAPSHEET"))
pfd.DefinitionExpression = BatchField & " = '" & MapSheet & "'"
pFClass = pFLayer.FeatureClass
pqfilter = New QueryFilter
pqfilter.WhereClause = BatchField & " = '" & MapSheet & "'"
' pFCursor = pFClass.Search(pqfilter, False)
pmxdoc.ActiveView.Extent = pFeature.Shape.Envelope
pmxdoc.FocusMap.MapScale = 30000
pmxdoc.ActiveView.Refresh()
'Export the view
pActiveView = pmxdoc.ActiveView
pExporter = New TiffExporter
pEnv = New Envelope
Dim BEnv As IEnvelope
BEnv = pmxdoc.ActiveView.Extent
'Setup the exporter
exportFrame = pActiveView.ExportFrame
'pEnv.PutCoords(exportFrame.left, exportFrame.top, exportFrame.right, exportFrame.bottom) <--- Here the coords read 0 , 0 , 940 , 940 (not correct)
pEnv.PutCoords(BEnv.XMin, BEnv.YMin, BEnv.XMax, BEnv.YMax) ' If I use this, I get a "NOT ENOUGH MEMORY ERROR" but the coordinates are correct
Dim outloc As String = "C:\temp\"
Dim out_prefix As String = "MapNumber"
Dim dpi1 As Integer
dpi1 = 800
With pExporter
.PixelBounds = pEnv
.ExportFileName = outloc & "\" & MapSheet & out_prefix & ".tif"
.Resolution = dpi1
End With
'Recalc the export frame to handle the increased number of pixels
pEnv = pExporter.PixelBounds
pWorldFile = pExporter
pWorldFile.MapExtent = pEnv
pWorldFile.OutputWorldFile = True
hdc = pExporter.StartExporting
pActiveView.Output(hdc, dpi1, exportFrame, Nothing, Nothing)
pExporter.FinishExporting()
pFeature = pFCursor.NextFeature ' pFCursor.NextFeature
Loop
End Sub
Regards,K