contains
Determine if geographic or map raster contains points
Description
Examples
Check If Single Point Exists Within Bounds of Planar Raster
Create a MapPostingsReference
raster reference object.
xWorldLimits = [207000 208000]; yWorldLimits = [912500 913000]; rasterSize = [11 21]; R = maprefpostings(xWorldLimits,yWorldLimits,rasterSize,'ColumnsStartFrom','north')
R = MapPostingsReference with properties: XWorldLimits: [207000 208000] YWorldLimits: [912500 913000] RasterSize: [11 21] RasterInterpretation: 'postings' ColumnsStartFrom: 'north' RowsStartFrom: 'west' SampleSpacingInWorldX: 50 SampleSpacingInWorldY: 50 RasterExtentInWorldX: 1000 RasterExtentInWorldY: 500 XIntrinsicLimits: [1 21] YIntrinsicLimits: [1 11] TransformationType: 'rectilinear' CoordinateSystemType: 'planar' ProjectedCRS: []
Check if the raster contains the point (207549,912753). The expected result is 1 (true) since the x-coordinate is within R.XWorldLimits
and the y-coordinate is within R.YWorldLimits
.
tf = contains(R,207549,912753)
tf = logical
1
Check If Multiples Points Exist Within Bounds of Geographic Raster
Create a GeographicCellsReference
raster reference object.
latlim = [0 89]; lonlim = [-180 179]; rasterSize = [90 360]; R = georefcells(latlim,lonlim,rasterSize,'ColumnsStartFrom','north')
R = GeographicCellsReference with properties: LatitudeLimits: [0 89] LongitudeLimits: [-180 179] RasterSize: [90 360] RasterInterpretation: 'cells' ColumnsStartFrom: 'north' RowsStartFrom: 'west' CellExtentInLatitude: 0.988888888888889 CellExtentInLongitude: 0.997222222222222 RasterExtentInLatitude: 89 RasterExtentInLongitude: 359 XIntrinsicLimits: [0.5 360.5] YIntrinsicLimits: [0.5 90.5] CoordinateSystemType: 'geographic' GeographicCRS: [] AngleUnit: 'degree'
Check if points exist within the northern hemisphere.
pts_lat = [32 0 -10 32 212]; pts_lon = [-80 0 80 360 -80]; tf = contains(R,pts_lat,pts_lon)
tf = 1x5 logical array
1 1 0 1 0
The first point is in the northern hemisphere. The second point is the origin, and tf(2)
indicates the origin exists within the bounds of the northern hemisphere. The third point is in the southern hemisphere. The fourth point is identical to the first point after longitude wrapping. The element tf(4)
demonstrates that the geographic raster supports wrapping of longitude coordinates. The last element tf(5)
indicates that the geographic raster does not support wrapping of latitude coordinates.
Input Arguments
R
— Geographic or map raster
GeographicCellsReference
,
GeographicPostingsReference
,
MapCellsReference
, or
MapPostingsReference
object
Geographic or map raster, specified as a GeographicCellsReference
,
GeographicPostingsReference
,
MapCellsReference
, or MapPostingsReference
object.
lat
— Latitude coordinates
numeric scalar or vector
Latitude coordinates, specified as a numeric scalar or vector.
Data Types: single
| double
lon
— Longitude coordinates
numeric scalar or vector
Longitude coordinates, specified as a numeric scalar or vector. Elements
of lon
can be wrapped arbitrarily without affecting the
result.
Data Types: single
| double
xWorld
— x-coordinates in the world coordinate system
numeric scalar or vector
x-coordinates in the world coordinate system, specified as a numeric scalar or vector.
Data Types: single
| double
yWorld
— y-coordinates in the world coordinate system
numeric scalar or vector
y-coordinates in the world coordinate system, specified as a numeric scalar or vector.
Data Types: single
| double
Output Arguments
tf
— Flag indicating geographic or map raster vector contains points in the world coordinate system
logical scalar or vector
Version History
Introduced in R2013b
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)