How to read shape file in matlab?
I am using following matlab code to read shape file. I am attaching the shape file also as zip file.
% pickup the shape files
d = uigetdir(pwd, ‘Select a folder’);
shapefiles = dir(fullfile(d, ‘*.shp’));
for n = 1:length(shapefiles)
shapefile = shapefiles(n);
disp(shapefile.name);
S = shaperead(shapefile.name);
polygon = polyshape([S.X], [S.Y]);
% Create a logical mask
logical_mask = inpolygon(lon, lat, polygon.Vertices(:, 1), polygon.Vertices(:, 2));
end
This is giving the following errors;
>> testrnAchi Khurd.shp
Error using openShapeFiles>checkSHP (line 82)
Unable to open file ‘Achi Khurd.shp’. Check the path and filename or file permissions.
Error in openShapeFiles (line 19)
[basename, ext] = checkSHP(basename,shapeExtensionProvided);
Error in shaperead (line 212)
= openShapeFiles(filename,’shaperead’);
Error
in test (line 9)
S = shaperead(shapefile.name);
>>
Please suggest me how to fix it? I would be highly obliged for kind help.
DaveI am using following matlab code to read shape file. I am attaching the shape file also as zip file.
% pickup the shape files
d = uigetdir(pwd, ‘Select a folder’);
shapefiles = dir(fullfile(d, ‘*.shp’));
for n = 1:length(shapefiles)
shapefile = shapefiles(n);
disp(shapefile.name);
S = shaperead(shapefile.name);
polygon = polyshape([S.X], [S.Y]);
% Create a logical mask
logical_mask = inpolygon(lon, lat, polygon.Vertices(:, 1), polygon.Vertices(:, 2));
end
This is giving the following errors;
>> testrnAchi Khurd.shp
Error using openShapeFiles>checkSHP (line 82)
Unable to open file ‘Achi Khurd.shp’. Check the path and filename or file permissions.
Error in openShapeFiles (line 19)
[basename, ext] = checkSHP(basename,shapeExtensionProvided);
Error in shaperead (line 212)
= openShapeFiles(filename,’shaperead’);
Error
in test (line 9)
S = shaperead(shapefile.name);
>>
Please suggest me how to fix it? I would be highly obliged for kind help.
Dave I am using following matlab code to read shape file. I am attaching the shape file also as zip file.
% pickup the shape files
d = uigetdir(pwd, ‘Select a folder’);
shapefiles = dir(fullfile(d, ‘*.shp’));
for n = 1:length(shapefiles)
shapefile = shapefiles(n);
disp(shapefile.name);
S = shaperead(shapefile.name);
polygon = polyshape([S.X], [S.Y]);
% Create a logical mask
logical_mask = inpolygon(lon, lat, polygon.Vertices(:, 1), polygon.Vertices(:, 2));
end
This is giving the following errors;
>> testrnAchi Khurd.shp
Error using openShapeFiles>checkSHP (line 82)
Unable to open file ‘Achi Khurd.shp’. Check the path and filename or file permissions.
Error in openShapeFiles (line 19)
[basename, ext] = checkSHP(basename,shapeExtensionProvided);
Error in shaperead (line 212)
= openShapeFiles(filename,’shaperead’);
Error
in test (line 9)
S = shaperead(shapefile.name);
>>
Please suggest me how to fix it? I would be highly obliged for kind help.
Dave how to read shape file in matlab? MATLAB Answers — New Questions