No BSD License  

Highlights from

4.9 | 9 ratings Rate this file 13 Downloads (last 30 days) File Size: 807 KB File ID: #5951 Version: 1.0
image thumbnail



John Evans (view profile)


29 Sep 2004 (Updated )

Reads in common ESRI shapefile formats.

| Watch this File

File Information

This mex-file reads SHPT_POINT, SHPT_MULTIPOINT, SHPT_ARC, and SHPT_POLYGON shapefiles into structures.

MATLAB release MATLAB 7.0.4 (R14SP2)
Other requirements Requires shapelib (
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
23 Sep 2014 Gerbert

Mr. Evans, thanks for the submission. In contrast to what has been said below does my mexfile not work on the 2012b version (with the exact same code, it does work on a 2006b account)

Error in mexshape (line 1)
function [s, t] = mex_shape ( shapefile )

Output argument "s" (and maybe others) not assigned during call to "C:\Program

Error in shape_get (line 66)
[shape_data] = mexshape ( shapefile );

What do I do wrong?

Comment only
18 Feb 2013 Jonathan Epperl

Mr Evans, thank you very much for this extremely useful submission! Also many thanks to Povl Abrahamsen for the comment below. Just to recap, the compilation on my Win7 64bit R2012b machine:
mex -output mexshape -v mex_shape.c shpopen.c dbfopen.c safileio.c

18 Jan 2013 Povl Abrahamsen

Still works great in R2012B. With the latest version of Shapelib you also need to include safileio.c when compiling.

10 Jan 2012 Pavan

Pavan (view profile)

Works without a problem. Great job.

08 Mar 2010 Anthony Kendall

Anthony Kendall (view profile)

The code worked great, I compiled it on a 64-bit machine with the latest version of shapelib, and everything works well. Some of the help is a bit outdated, but I really can't complain.

24 Sep 2007 Seshadri Rajagopal

Great and handy tool. I just saved a bunch of money and time by switching to mexshape :-)) Thank you Mr. Evans

29 Mar 2007 Tim Myers

Great code and documentation. This is exactly what I was looking for. Works great.

27 Aug 2006 Richard Signell

Worked perfectly.

14 Feb 2006 ivica Janekovic

All compliments for done jobe!!

04 Jan 2006 Amer Butt  
29 Oct 2004

Improved documentation, addition of linux mex file. Addition of example shapefile.

17 Dec 2004

Forgot to include file.

27 Dec 2004

Added Mac OS X, WinXP, and Digital Unix mex files.

12 Jan 2005

Minor wording change to the README file. Previous upload did not include all necessary files.

12 Jan 2005

Minor change to wording of README. Last submission did not include all files.

09 Aug 2005

Modified to handle multiregion polygons. This is done by inserting NaNs into the vertex lists where a separate polygon begins.

16 Jan 2006

Cleaned up issues revealed by -Wall compile option. Now handling multipart polygons within a single shape by using NaNs.

26 Apr 2006

Additional windows dll, code cleanup.

05 May 2006

Took into account suggestions by mlint.

Wasn't handling special case where a point shapefile had just one point in an entity.

Contact us