Main Content

camheight

Set or query height of camera for Site Viewer

Since R2025a

    Description

    Geographic Coordinates

    camheight(viewer,height) sets the ellipsoidal height of the camera for the specified Site Viewer. You can set the camera height using geographic coordinates when the CoordinateSystem property of the Site Viewer object is "geographic".

    example

    camheight(viewer) displays the ellipsoidal height of the camera. The function displays the ellipsoidal height when the CoordinateSystem property of the Site Viewer is "geographic".

    heightOut = camheight(___) returns the ellipsoidal height of the camera when the CoordinateSystem property of the Site Viewer is "geographic". You can return the ellipsoidal height using any of the input argument combinations from the previous syntaxes.

    Cartesian Coordinates

    camheight(viewer,z) sets the z-coordinate of the camera for the specified Site Viewer. You can set the camera height using Cartesian coordinates when the CoordinateSystem property of the Site Viewer object is "cartesian".

    example

    camheight(viewer) displays the z-coordinate of the camera. The function displays the z-coordinate when the CoordinateSystem property of the Site Viewer is "cartesian".

    zOut = camheight(___) returns the z-coordinate of the camera when the CoordinateSystem property of the Site Viewer is "cartesian". You can return the z-coordinate using any of the input argument combinations from the previous syntaxes.

    example

    Examples

    collapse all

    Create a Site Viewer. By default, Site Viewer displays a 3-D globe using satellite imagery.

    viewer = siteviewer;

    Query the CoordinateSystem property of the Site Viewer object. The result, "geographic", indicates that the camheight function sets and queries the ellipsoidal height of the camera.

    viewer.CoordinateSystem
    ans = 
    "geographic"
    

    Specify the latitude and longitude of Mount Washington, and specify a height that is 2400 meters above the WGS84 reference ellipsoid. Move the camera to this location by using the campos function.

    lat = 44.2706;
    lon = -71.3033;
    h = 2400;
    campos(viewer,lat,lon,h)

    Satellite imagery of Mount Washington

    Change only the height of the camera by using the camheight function. Increase the camera height to 4000 meters above the WGS84 reference ellipsoid.

    camheight(viewer,4000)

    Zoomed-out view of Mount Washington

    Create a Site Viewer that displays a 3-D model from an STL file. The file models a small conference room with one table and four chairs.

    viewer = siteviewer(SceneModel="conferenceroom.stl");

    Query the CoordinateSystem property of the Site Viewer object. The result, "cartesian", indicates that the camheight function sets and queries the z-coordinate of the camera.

    viewer.CoordinateSystem
    ans = 
    "cartesian"
    

    3-D model of a table and four chairs

    Query the z-coordinate of the camera. The camheight function returns a value in meters.

    zOut = camheight(viewer)
    zOut = 
    1.2500
    

    Move the camera up one meter by specifying a new z-coordinate.

    z = zOut + 1;
    camheight(viewer,z)

    The same 3-D model. The new camera position removes the bottom of the model from the view.

    Input Arguments

    collapse all

    Site Viewer, specified as a siteviewer object.1

    Ellipsoidal height of the camera, in meters, specified as a numeric scalar. Site Viewer objects use the WGS84 reference ellipsoid. For more information about ellipsoidal height, see Find Ellipsoidal Height from Orthometric Height (Mapping Toolbox).

    If you specify the height so that the camera is level with or below the terrain, then the campos function sets the height to a value one meter above the terrain.

    z-coordinate of the camera, in meters, specified as a numeric scalar.

    Output Arguments

    collapse all

    Ellipsoidal height of the camera, in meters, returned as a numeric scalar. Site Viewer objects use the WGS84 reference ellipsoid. For more information about ellipsoidal height, see Find Ellipsoidal Height from Orthometric Height (Mapping Toolbox).

    z-coordinate of the camera, in meters, returned as a numeric scalar.

    Version History

    Introduced in R2025a

    See Also

    Functions

    Objects


    1 Alignment of boundaries and region labels are a presentation of the feature provided by the data vendors and do not imply endorsement by MathWorks®.