Creating a shapefile...

Hi all,
I've a bunch of data that I would like to store in a shapefile using matlab, but this is being really tricky.
My data has 149 elements and 6 fields. The fields are "Geometry" (char), "Latitude" (vector changing for each element), "Longitude" (vector same size as Latitutde), "Prop 1" (vector same size as latitute), "Prop2" (constant value), "Prop3" (constant value). So far:
1 - I've created an structed array to use shapewrite:
Error using makedbfspec>validateAttributes (line 350)
Attribute field Latitude of S contains at least one value that is not a scalar.
2 - If tried using geoshape to convert my structed array to a format that could be used by shapewrite:
Only Lat and Long were written not the other fields
Can someone help me with this please.
Thanks in advance

Answers (1)

Jacob Halbrooks
Jacob Halbrooks about 22 hours ago

0 votes

The recommended workflow for this example is to create a geospatial table using your input data and then writing to a shapefile using shapewrite. The Create Geospatial Tables documentation page shows how spatial data and attribute data are represented and stored in this format. More specifically, please see the section on creating a geospatial table from arrays for adapting the data in your example.
Based on the error related to dbspec, it appears the attribute data may not be structured as expected. In particular, the attributes are likely being assigned on a per vertex basis rather than per geographic feature or geometry. Without seeing the code used to construct the geoshape object, it is difficult to determine the exact cause of the issue. However, geoshape also has specific requirements for attribute assignment to each geometry and naming conventions are particularly important when creating a geoshape using a struct.
The shapewrite documentation describes the supported input types and the requirements for constructing each type. The shapewrite examples may be helpful for comparing the structure of your data with the formats expected by shapewrite.

Asked:

on 7 Dec 2018

Answered:

about 22 hours ago

Community Treasure Hunt

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

Start Hunting!