This example shows how to use a geographic density plot to view the density of cellular tower placement in California.
Load Cellular Tower Placement Data
Load a table of cellular tower placement data into the workspace. The table includes fields that identify the location of the cellular tower by latitude and longitude, and identify the type of tower.
loadcellularTowers
View the Data as a Geographic Scatter Plot
Plot the cellular tower data using thegeoscatter
function. In the plot, there are clear areas around San Francisco where the number of towers are too dense to be represented using a scatter plot.
lat = cellularTowers.Latitude;朗= cellularTowers.Longitude; geoscatter(lat,lon,'.') text(gca,37.75,-122.75,'San Francisco','HorizontalAlignment','right')
The dense area of towers in the San Francisco area can be shown usinggeodensityplot
.
geodensityplot(lat,lon) text(gca,37.75,-122.75,'San Francisco','HorizontalAlignment','right')
When you create a geographic density plot, by default, the density plot automatically selects a radius value, using the latitude and longitude data. Use theRadius
property to manually select a radius in meters.
radiusInMeters = 50e3;% 50 kmgeodensityplot(lat,lon,'Radius',radiusInMeters)
When set to'interp'
, the density plot'sFaceAlpha
andFaceColor
properties use theAlphamap
andColormap
properties of the underlying geographic axes, respectively. Changing theAlphamap
changes the mapping of the density values to color intensities.
geodensityplot(lat,lon) alphamap(normalize((1:64).^0.5,'range'))
TheAlphaScale
property on the geographic axes can also be used to alter the transparency. This property is particularly useful when trying to show where any density is found, rather than highlighting the most dense areas.
figure dp = geodensityplot(lat,lon)
dp =DensityPlot with properties:FaceColor: [0 0.4470 0.7410] FaceAlpha: 'interp' LatitudeData: [1×1193 double] LongitudeData: [1×1193 double] WeightData: [1×0 double] Radius: 1.8291e+04 Show all properties
gx = gca
gx =GeographicAxes with properties:Basemap: 'streets-light' Position: [0.1300 0.1100 0.7750 0.8150] Units: 'normalized' Show all properties
gx.AlphaScale ='log';
UseDensityPlot
Object Properties to Specify Color
Add color.
dp.FaceColor ='interp'; colormaphot
geodensityplot
|DensityPlot Properties