2

I have a script that calculates kernel density for several sets of points, adds the output to a base map, updates the added layer to use the same color scheme and resampling function of a template layer, then zooms to the extent of the new layer.

This works fine for some of the resulting maps; the density output shows on the map, the color is as it should be, and it is sampled using bilinear interpolation as I wanted. The problem is that most of the resulting maps do not show the kernel output at all; only the basemap is visible.

I have isolated the code I am using and have altered it to compute one simple test case. Here is what I have:

SubjectLyr = arcpy.mapping.Layer(r"F:\\testFiles\\output\\Population23_KDens.lyr")
mxd = arcpy.mapping.MapDocument("F:\\testFiles\\testMap.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0] 
wPath = "F:\\testFiles\\output\\" # same as in line 1

#Add the layer to basemap
arcpy.mapping.AddLayer(df, SubjectLyr,"AUTO_ARRANGE") 

#Update the layer
SubjectLyr = arcpy.mapping.ListLayers(mxd, SubjectLyr.name, df)[0] # change reference to layer in mxd
sourceLayer = arcpy.mapping.Layer(wPath+"templates\\template.lyr") # get template layer
arcpy.mapping.UpdateLayer(df, SubjectLyr, sourceLayer, True)

###Zoom to selection
df.zoomToSelectedFeatures()
lyrExtent = SubjectLyr.getSelectedExtent()
df.extent = lyrExtent
arcpy.mapping.ExportToPDF(mxd, r"F:\\testFiles\\output\\Population23_KDens_Map.pdf")
print('DONE!')

I have read that there is some existing issue with UpdateLayer in ArcMap 10.1, though I am using 10.0. As shown, my code is practically identical to the code that is a "workaround" to this problem described in the above linked forum. This code works for some, but not all of my datasets.

I have also tried using the ApplySymbologyFromLayer_management() function, which does make all the kdens output layers appera; however, this does not change the resampling function used when drawing the output, and I need to to use bilinear interpolation.

Does anyone know what could be going on? Are there any other functions I could use?

3
  • You say the kernel output is not showing so I am wondering whether it is in the TOC and not visible on the map or missing from the TOC?
    – PolyGeo
    Commented Oct 31, 2012 at 21:42
  • I tried similar code in the Python Window in the ArcMap GUI, and the layer is showing in the TOC. The TOC is showing that it has the proper updated colors, but nothing shows up on the actual map.
    – N-C
    Commented Oct 31, 2012 at 22:26
  • It could be worth posting to same thread from ArcGIS Discussion Forum you reference in Question because Jeff Barrette seems to be well on top of UpdateLayer there.
    – PolyGeo
    Commented Oct 31, 2012 at 22:32

1 Answer 1

2

I finally figured out the problem, and I feel decidedly silly for not thinking of it before.

My template layer, from which the symbology was being taken in UpdateLayer, was using the "classified" symbology method with "no color" for values falling between 0 and 104. The default kernel density output uses the "stretched" symbol, and when being forced into the "classified" scheme, many of the values fell within the "no color" range. As a result, the density output from many of my datasets did not show up at all.

Now after changing the template layer to the "stretched" symbology scheme and using UpdateLayer again, everything works fine!

0

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.