bounds
Syntax
Description
Examples
Calculate the bounds of shapes in geographic coordinates. When you pass geographic shapes to the bounds function, the function calculates latitude and longitude limits.
Read a shapefile of US states into the workspace as a geospatial table. The table represents the states using polygon shapes in geographic coordinates. Extract the polygon shapes.
states = readgeotable("usastatehi.shp");
geoshp = states.Shapegeoshp=51×1 geopolyshape array with properties:
              NumRegions: [51×1 double]
                NumHoles: [51×1 double]
                Geometry: "polygon"
    CoordinateSystemType: "geographic"
           GeographicCRS: [1×1 geocrs]
      ⋮
Find the bounds of each polygon shape. By default, the function returns a set of latitude and longitude limits for each shape object.
[latlim,lonlim] = bounds(geoshp);
Store the latitude and longitude limits in the geospatial table by creating new table variables.
states.LatitudeLimits = latlim; states.LongitudeLimits = lonlim;
View the first eight rows of the table. Note that each shape object has a corresponding set of latitude and longitude limits.
head(states)
       Shape            Name         LabelLat    LabelLon     LatitudeLimits      LongitudeLimits  
    ____________    _____________    ________    ________    ________________    __________________
    geopolyshape    "Alabama"         32.283     -86.921     30.221    35.008    -88.473    -84.889
    geopolyshape    "Alaska"           64.61     -152.46     51.217    71.333    -187.54    -130.03
    geopolyshape    "Arizona"         34.345     -112.07     31.332    37.004    -114.81    -109.04
    geopolyshape    "Arkansas"        34.835     -91.886     33.004    36.499    -94.618    -89.645
    geopolyshape    "California"      36.822     -119.66     32.535     42.01    -124.41    -114.13
    geopolyshape    "Colorado"         39.03     -105.54     36.992    41.003    -109.06    -102.04
    geopolyshape    "Connecticut"     41.511     -72.763     40.986     42.05    -73.728    -71.787
    geopolyshape    "Delaware"        39.107     -75.494     38.452    39.838    -75.789    -75.049
Calculate the bounds of shapes in planar coordinates. When you pass planar shapes to the bounds function, the function calculates xy-limits.
Read hydrography data for an area in Concord, MA as a geospatial table. The table represents the states using polygon shapes in planar coordinates. Extract the polygon shapes.
hydro = readgeotable("concord_hydro_area.shp");
mapshp = hydro.Shapemapshp=98×1 mappolyshape array with properties:
              NumRegions: [98×1 double]
                NumHoles: [98×1 double]
                Geometry: "polygon"
    CoordinateSystemType: "planar"
            ProjectedCRS: [1×1 projcrs]
      ⋮
Find the bounds of each polygon shape. By default, the function returns a set of xy-limits for each shape object.
[xlimits,ylimits] = bounds(mapshp);
Store the xy-limits in the geospatial table by creating new table variables.
hydro.XLimits = xlimits; hydro.YLimits = ylimits;
View the first eight rows of the table. Note that each shape object has a corresponding set of xy-limits.
head(hydro)
       Shape           AREA       PERIMETER            XLimits                     YLimits         
    ____________    __________    _________    ________________________    ________________________
    mappolyshape        2456.4     289.22      2.0759e+05    2.0763e+05    9.1336e+05    9.1349e+05
    mappolyshape    1.2685e+05      11264      2.0748e+05    2.1032e+05    9.1101e+05    9.1344e+05
    mappolyshape        2075.4     207.37      2.0763e+05    2.0767e+05    9.1321e+05     9.133e+05
    mappolyshape        814.05     117.55      2.0927e+05    2.0931e+05    9.1325e+05    9.1329e+05
    mappolyshape         10754     633.93      2.0861e+05    2.0882e+05    9.1309e+05    9.1326e+05
    mappolyshape        5894.2     370.54      2.1023e+05    2.1032e+05    9.1309e+05    9.1323e+05
    mappolyshape         48368     3378.7      2.0657e+05    2.0743e+05    9.1241e+05    9.1318e+05
    mappolyshape         27673     1650.6      2.0707e+05    2.0746e+05    9.1272e+05    9.1318e+05
By default, when you pass multiple shapes to the bounds function, the function calculates a set of bounds for each shape object. Calculate the bounds over all the shapes by using the "all" option.
Read a shapefile containing the coordinates of locations in Boston as a geospatial table. The table represents the locations using point shapes in geographic coordinates. Extract the point shapes.
places = readgeotable("boston_placenames.gpx");
geoshp = places.Shapegeoshp = 
  13×1 geopointshape array with properties:
               NumPoints: [13×1 double]
                Latitude: [13×1 double]
               Longitude: [13×1 double]
                Geometry: "point"
    CoordinateSystemType: "geographic"
           GeographicCRS: [1×1 geocrs]
Find the bounds over all the point shapes.
[latlim,lonlim] = bounds(geoshp,"all")latlim = 1×2
   42.3459   42.3668
lonlim = 1×2
  -71.0995  -71.0495
Input Arguments
Shape in geographic coordinates, specified as a geopointshape,
              geolineshape, or
              geopolyshape
            object or as a vector of geopointshape, geolineshape,
            or geopolyshape objects. When you specify an array, you can include a
            combination of point, line, and polygon shape objects.
Shape in geographic coordinates, specified as a mappointshape,
              maplineshape, or
              mappolyshape
            object or as a vector of mappointshape, maplineshape,
            or mappolyshape objects. When you specify an array, you can include a
            combination of point, line, and polygon shape objects.
Output Arguments
Latitude limits, returned as a two-column matrix. The first column of the matrix contains the northern latitude limits, and the second column of the matrix contains the southern latitude limits. For each row of the matrix, the first limit is less than or equal to the second limit.
When you do not specify the "all" option, the number of rows in
            the matrix matches the number of shapes in geoshp. When you do
            specify the "all" option, the matrix has one row.
The units of latlim match the units of
              geoshp. If the GeographicCRS property of
              geoshp contains a geocrs object,
            you can find the units by querying the AngleUnit property of the
              geocrs object, for example
              geoshp.GeographicCRS.AngleUnit.
Longitude limits, returned as a two-column matrix. The first column of the matrix contains the western longitude limits, and the second column of the matrix contains the eastern longitude limits. For each row of the matrix, the first limit is less than or equal to the second limit.
When you do not specify the "all" option, the number of rows in
            the matrix matches the number of shapes in geoshp. When you do
            specify the "all" option, the matrix has one row.
The units of lonlim match the units of
              geoshp. If the GeographicCRS property of
              geoshp contains a geocrs object,
            you can find the units by querying the AngleUnit property of the
              geocrs object, for example
              geoshp.GeographicCRS.AngleUnit.
x-limits, returned as a two-column matrix. The first column of the matrix contains the lower x-limits, and the second column of the matrix contains the upper x-limits. For each row of the matrix, the first limit is less than or equal to the second limit.
When you do not specify the "all" option, the number of rows in
            the matrix matches the number of shapes in mapshp. When you do
            specify the "all" option, the matrix has one row.
The units of xlimits match the units of
              mapshp. If the ProjectedCRS property of
              mapshp contains a projcrs object,
            you can find the units by querying the LengthUnit property of the
              projcrs object, for example
              mapshp.ProjectedCRS.LengthUnit.
y-limits, returned as a two-column matrix. The first column of the matrix contains the lower y-limits, and the second column of the matrix contains the upper y-limits. For each row of the matrix, the first limit is less than or equal to the second limit.
When you do not specify the "all" option, the number of rows in
            the matrix matches the number of shapes in mapshp. When you do
            specify the "all" option, the matrix has one row.
The units of ylimits match the units of
              mapshp. If the ProjectedCRS property of
              mapshp contains a projcrs object,
            you can find the units by querying the LengthUnit property of the
              projcrs object, for example
              mapshp.ProjectedCRS.LengthUnit.
Version History
Introduced in R2024b
See Also
Functions
Objects
Topics
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)