1

When clicking a point feature I want the html pop-up to not only contain the data of the feature but also an image of the area around the feature (eg. 2 km^2). The image would have the base map 'World Imagery and Place' and also another raster layer 'MultiBeam Bathymetry' (which isn't shown in the workspace), the original feature layer wouldn't be shown.

This is far beyond the scope of what html could do and I wanted to use the tools in the arcpy catalog so I was wondering if it is possible to incorporate the python into the html code.

4
  • What is wrong with using attachments? Why do you need to code this?
    – FelixIP
    Commented Feb 24, 2015 at 19:25
  • @FelixIP Thanks for the response. If you mean just attaching a photo of the area of around the feature thats my back-up plan right now. I have well over a thousand features though so attaching individual photos or even capturing the photos would take far too long. Right now I have the key areas with photos, I was just looking for a way to do it for all the features.
    – Tanner
    Commented Feb 24, 2015 at 20:19
  • I am talking about code that iterate/zooms through each point (data driven pages) and exporting picture of surrounding "World Image' to properly named file. Do the same with Bathymetry layer. With good naming it rather easy to convert thousands of these screen damps into attachments
    – FelixIP
    Commented Feb 24, 2015 at 21:29
  • @FelixIP thats a cool idea. Do you have any attachments in mind that I could look into?
    – Tanner
    Commented Feb 24, 2015 at 22:28

1 Answer 1

1

The script below works on buffers (around points). Layer name in the table of content in open mxd is PRIMARY. It also manipulates visibility of another layer called SECONDARY (you'll have to remove all the references to second one in a script). Script walks/pans through buffers, manipulate scale (scale=df.scale*5) and export everything that is visible in the view to PNG file, named after field in buffers table. In this case field name is UNIQUEID.

# Import arcpy module
import arcpy, traceback, os, sys
from arcpy import env
env.overwriteOutput = True
##infc=arcpy.GetParameterAsText(0)
nameFld='UNIQUEID'
outFolder=arcpy.GetParameterAsText(0)
env.workspace = outFolder
## ERROR HANDLING
def showPyMessage():
    arcpy.AddMessage(str(time.ctime()) + " - " + message)

try:
##  MAIN MODULE
##  GET A,B LOOKUP SHAPES
    mxd = arcpy.mapping.MapDocument("CURRENT")
    infc="PRIMARY"
    fl = arcpy.mapping.ListLayers(mxd,infc)[0]
    fl.definitionQuery=""

    secfc="SECONDARY"
    sf = arcpy.mapping.ListLayers(mxd,secfc)[0]
    sf.definitionQuery=""
    df = arcpy.mapping.ListDataFrames(mxd)[0]
##    'df.scale = 5000

    with arcpy.da.SearchCursor(infc, ["SHAPE@",nameFld]) as cursor:
        for row in cursor:
            shp=row[0]
            anExtent=shp.extent
            df.extent=anExtent
##            df.panToExtent(anExtent)
            scale=df.scale*5
            df.scale=scale
            fN=row[1]
            fName=outFolder+os.sep+fN+".png"
            arcpy.AddMessage(row[1])
            m=arcpy.AddFieldDelimiters(infc, nameFld)
            fp= m+"="+"'"+fN+"'"
            fl.definitionQuery=fp
            fp= m+"<>"+"'"+fN+"'"
            sf.definitionQuery=fp
            arcpy.RefreshActiveView()
##            arcpy.mapping.ExportToPNG(mxd,fName, df,
##                                      df_export_width=1600,
##                                      df_export_height=1200,
##                                      world_file=False)
            arcpy.mapping.ExportToPNG(mxd,fName, "PAGE_LAYOUT",
                                      resolution=144,
                                      world_file=False)
    fl.definitionQuery=""
    sf.definitionQuery=""
    del row, cursor
except:
    message = "\n*** PYTHON ERRORS *** "; showPyMessage()
    message = "Python Traceback Info: " + traceback.format_tb(sys.exc_info()[2])[0]; showPyMessage()
    message = "Python Error Info: " +  str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"; showPyMessage()

Because name of output raster is linked to values in the parent table field, the only thing left is to create correct table to convert all of outputs to attachments. I usually use Excel for this purpose.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.