Clear Filters
Clear Filters

Shape Write Error when attempting to write to .shp

6 views (last 30 days)
Elliot Stevens
Elliot Stevens on 14 Oct 2021
Answered: arushi on 21 Aug 2024 at 5:40
Hi,
working my way through the topotoolbox functions and trying to write a STRUCT to a .shp and it is coming up with the following errors:
>> MS = STREAMobj2mapstruct(S);
shapewrite(MS,'testshape.shp')
Error using shapewrite>writeSHP (line 95)
Unable to open testshape.shp for writing.
Error in shapewrite (line 81)
[shapeType, boundingBox, index] = writeSHP(S,basename);
I have mapping toolbox installed and all other fuctions worked up to thsi point so just abit lost
Thanks

Answers (1)

arushi
arushi on 21 Aug 2024 at 5:40
Hi Elliot,
The error you are encountering suggests that there might be an issue with file permissions, the path where you are trying to save the file, or possibly the structure of the data you are trying to write. Here are some steps to troubleshoot and resolve the issue:
1. Check File Path and Permissions:
- Ensure that you have write permissions to the directory where you are trying to save the `testshape.shp` file.
2. Verify Structure of `MS`:
- Make sure that `MS` is a valid map structure that `shapewrite` can process. The structure should contain fields like `Geometry`, `X`, `Y`, and any other necessary attributes.
- You can inspect the structure by using the `disp` or `struct` commands to ensure it matches the expected format.
3. Close Other Applications:
- Ensure that no other applications are using or locking the file `testshape.shp`. Sometimes, files can be locked by other processes, preventing MATLAB from writing to them.
4. Check MATLAB's Current Directory:
- Confirm that MATLAB's current working directory is set correctly. You can check this by using the `pwd` command and change it with `cd` if necessary.
Hope this helps.

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!