Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
mapping toolbox

Subject: mapping toolbox

From: Paul

Date: 25 May, 2008 12:48:01

Message: 1 of 4

In the older versions of the mapping toolbox I used:

> load usahi;
> [lats,lons] = extractm(stateline,{'ken' 'ill' 'ten' 'ark'});

to extract the central US state outlines as [x,y] pairs for
plotting and analysis.

Now we have a new toolbox and I tried using:

> s = shaperead('usastatehi.shp');

but the structure 's' does not contain a 'tag' and therefore
the extractm routine fails.

Can anybody provide a simple and clear solution. It is very
troublesome not to have your code backward compatible.

Subject: mapping toolbox

From: Rob Comer

Date: 16 Jul, 2008 17:07:02

Message: 2 of 4

Here's how I would do it:
% Note that all elements of centralStates
% have three characters
centralStates = {'ken' 'ill' 'ten' 'ark'};

% Return true iff NAME corresponds to a "central state";
centralstate = @(name) any(strncmpi(centralStates,name,3));

% Examples
centralstate('Kentucky') % True
centralstate('California') % False

% Down-select data on import from shapefile
S = shaperead('usastatehi.shp', ...
    'Selector',{centralstate,'Name'},...
    'UseGeoCoords',true)

% Concatenate vertices and plot
lats = [S.Lat];
lons = [S.Lon];
plot(lons,lats)

Subject: mapping toolbox

From: Paul

Date: 17 Jul, 2008 04:14:02

Message: 3 of 4

"Rob Comer" <rob.comer.nospam@mathworks.com> wrote in
message <g5l9rm$8vl$1@fred.mathworks.com>...
> Here's how I would do it:
> % Note that all elements of centralStates
> % have three characters
> centralStates = {'ken' 'ill' 'ten' 'ark'};
>
> % Return true iff NAME corresponds to a "central state";
> centralstate = @(name) any(strncmpi(centralStates,name,3));
>
> % Examples
> centralstate('Kentucky') % True
> centralstate('California') % False
>
> % Down-select data on import from shapefile
> S = shaperead('usastatehi.shp', ...
> 'Selector',{centralstate,'Name'},...
> 'UseGeoCoords',true)
>
> % Concatenate vertices and plot
> lats = [S.Lat];
> lons = [S.Lon];
> plot(lons,lats)
>

Thanks for your help. I really miss usahi and worldhi.

Is there a similar solution for worldhi?

Subject: mapping toolbox

From: Rob Comer

Date: 17 Jul, 2008 14:54:03

Message: 4 of 4

> Thanks for your help. I really miss usahi and worldhi.
>
> Is there a similar solution for worldhi?

In place of worldhi.MAT, you could try one of the following
two shapefiles, which are available free from third-party sites:

http://openmap.bbn.com/data/shape/cntry02.tar.gz

http://mappinghacks.com/data/world_borders.zip

Also, make sure to check out the WORLDDATAMAP M-file and
examples that my colleague Kelly Luetkemeyer posted on the
File Exchange to help bridge the gap when worldhi was removed:

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=7550&objectType=file#

In addition, I've been thinking about providing an
EXTRACTM-like capability to work with geostructs -- so that
you could either down-select your shapefile data when
calling SHAPEREAD (as in my example) or later -- after
importing the full content of the shapefile. Basically,
shapefiles and geostructs provide a huge increase in
flexibility over MAT-files like usahi, and they should be
made as easy to work with as possible.

Rob Comer
Mapping Toolbox Development
The MathWorks, Inc.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us