Tuesday, 5 February 2019

arcgis 10.0 - Creating JPEG images of geoprocessing output using ArcObjects?


I'm running batch processing on several datasets using a standalone EXE written in .NET. There are many output files for each dataset (>25 featureclasses/rasters). For every dataset I would like to grab a few specific outputs and create JPEG images of them for simple quality control. Ideally I would combine a few of the featureclasses together and create an image of the combination as if I were exporting an image of several layers as you can do using the Arc UI. I imagine that there will be a few steps involved in accomplishing this - can someone point me in the right direction?


For the sake of simplicity, you can assume that I have the full path to the files I want, which are stored in a FGDB on a drive. I can also derive the approximate extent of these featureclasses from the largest of them, so I can set a view extent.


For example:


I have just run the extension and created a series of output files which are stored in a FGDB. These featureclasses/rasters all cover the same discrete area and are projected.


Outputs (making these up for simplicity):


1) DEM of the area (represents the full extent).


2) Polyline road network.


3) Polygon building footprints.


4) Point featureclass representing manhole covers.



What to accomplish:


Combine all of the files in the correct order (featureclasses overtop of the DEM) and save a JPEG file.


EDIT:


My extension runs as an EXE (not a toolbar) and doesn't actually open the Arc UI - it merely consumes the licenses and does the processing in the background. So, do I have access to ActiveView if I haven't "launched" the UI? Essentially, I don't have a TOC to populate with layers.



Answer



If you are using ArcObjects to add and arrange the order of layers in the ArcMap TOC, I would first search for the specific names that you want to export out as a group. Then turn off all the layers except for those that you want to export out e.g.


'Search for MyLayer1 and MyLayer2 in the ArcMap TOC
Dim pFLayer As IFeatureLayer = Nothing
Dim pLayer As ILayer
Dim pEnumLayer As IEnumLayer


m_pMap2 = m_pMxDoc2.ActiveView.FocusMap
pEnumLayer = m_pMap2.Layers

pLayer = pEnumLayer.Next
Do Until pLayer Is Nothing
If pLayer.Name = "MyLayer1" AND pLayer.Name = "MyLayer2" Then
TurnOffLayers()
ExportActiveView()
Else

Exit Sub
End If
pLayer = pEnumLayer.Next
Loop
End Sub

If those layers are present then you can use the ExportActiveView code to export out the jpg images. Here is the link for the ExportActiveView Code.


Edit


You could add those layers into an ArcMap project, save the mxd, and export out the map using python/arcpy script.


Add Layers



Export Map


OR


if you have access to the extension code you could use 'Call Shell' code to open up ArcMap, and add your layers in the TOC using ArcObjects.


A python script might be a better option.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...