I am looking for a function to read/write points, lines and polygons from ESRI's shapefile format (as used in Arcview) for use in Matlab
Read the shapefile by using the shaperead function. Indicate that the shapefile uses latitude and longitude coordinates using the 'UseGeoCoords' name-value pair. Note that the shaperead function returns a geographic data structure with latitude and longitude fields (a geostruct ).
A shapefile is an Esri vector data storage format for storing the location, shape, and attributes of geographic features. It is stored as a set of related files and contains one feature class.
If the file is in your current folder or in a folder on the MATLAB® path, then specify the name of the file, such as "myFile. shp" . If the file is not in the current folder or in a folder on the MATLAB path, then specify the full or relative path name, such as "C:\myfolder\myFile. gpx" or "dataDir\myFile.
From the Matlab mapping toolbox, use the shaperead
function
For example download the NOAA Interstate Highway shape file here, extract and then read data into Matlab using the function, S = shaperead('in101503.shp');
If you do not have the Matlab mapping toobox, the very useful m_map package now has an m_shaperead() function which does a good job of reading shapefiles.
X = m_shaperead('filename'); % for filename.(dbf,shp,...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With