Mapping Toolbox | ![]() ![]() |
Simplifying Vector Data
Sometimes you may need to reduce the number of points in your vector data, while still maintaining an accurate representation of the geographical data. A quick and easy method would be to throw out every other element or set of elements in each vector. However, the result may be a very crude representation of the original data. Another option exists. The Mapping Toolbox provides a function implementing a powerful line simplification algorithm that selectively deletes points.
For example, reduce the number of points in the state of Massachusetts with the reducem
function:
load usahi whos
Name |
Size |
Bytes |
Class |
|
|
|
|
stateline |
1x51 |
837656 |
struct array |
statepatch |
1x51 |
837758 |
struct array |
statetext |
1x51 |
51190 |
struct array |
The stateline
structure contains vector data for all 50 U.S. states and the District of Columbia. We are only interested in the state of Massachusetts, the 19th entry in the structure:
Now simplify your vector data:
[newlat,newlong,cerr,tol] = reducem(lat,long); whos
Name |
Size |
Bytes |
Class |
|
|
|
|
cerr |
1x1 |
8 |
double array |
lat |
958x1 |
7664 |
double array |
long |
958x1 |
7664 |
double array |
newlat |
253x1 |
2024 |
double array |
newlong |
253x1 |
2024 |
double array |
tol |
1x1 |
8 |
double array |
The Massachusetts vector data has been reduced to almost a quarter of its original size:
Plots of the datasets, however, show two virtually identical maps.
![]() | Trimming Vector Data to a Defined Region | Working with Matrix Maps | ![]() |