This is using ArcGIS10 arcpy with spatial analyst.
I need to call Viewshed, but with an observer height set. I have tried using a Z-aware point feature set, but that only throws an error. I am feeding an arcpy.PointGeometry object with a Raster object of a dem for my inputs. e.g.
viewshed = arcpy.sa.Viewshed(dem, source_point)
I am using dynamically generated points as the source for my observer points for the viewshed. Feature classes have to be built in memory.
I have tried several ways to build an in-memory feature class with an OFFSETA field, but so far it has not worked.
Anyone have any idea how to use the Viewshed OFFSETA, or another way to set observer height when calling Viewshed inside python using an in memory feature class?
Here is the solution I came up with, using Matthew Snape's advice. dem, source_point, offseta, and offsetb are all inputs to function this is contained in:
# Construct viewshed input arcpy.CreateFeatureclass_management("in_memory", "viewshedinput", "POINT") arcpy.AddField_management("in_memoryviewshedinput", "OFFSETA", "FLOAT") arcpy.AddField_management("in_memoryviewshedinput", "OFFSETB", "FLOAT") rows = arcpy.InsertCursor("in_memoryviewshedinput") row = rows.newRow() row.shape = source_point row.OFFSETA = offseta row.OFFSETB = offsetb rows.insertRow(row) del rows, row # Calculate viewshed for source point viewshed = arcpy.sa.Viewshed(dem, "in_memoryviewshedinput")
The viewshed tool uses feature layers to define observers. The OFFSETA and other parameters are specified using a field.
Create your point as a feature layer and then use arcpy.AddField_management and arcpy.CalculateField_management to create and set the field.