Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
scalar double problem with shapewrite

Subject: scalar double problem with shapewrite

From: Jonathan

Date: 9 Mar, 2010 19:29:27

Message: 1 of 5

I continued to be puzzled with this problem of trying to convert a matrix using the shapewrite function. I have the following matrix...

A = [1,2,3,4];
lon = [-123.412482300000, -123.349197000000, -123.387645500000,-123.499196100000];
lat = [48.1177411000000,48.1170438000000,48.1850616000000,48.2661300000000];
[test2.Geometry] = deal('MultiPoint');
test2.id = A;
test2.lon = lon;
test2.lat = lat;
shapewrite(test2, 'test2');

when I run shapewrite I get the following error...

??? Error using ==> makedbfspec at 116
Attribute field id of geographic data structure S contains at least
one value that is not a scalar double.

Error in ==> shapewrite>parseInputs at 555
    dbfspec = makedbfspec(S);

Error in ==> shapewrite at 77
[S, basename, dbfspec] = parseInputs(varargin{:});

If I eliminate id I still get the same error, now using the lon matrix and so on. I would really appreciate any help on this problem.

Thanks
Jon

Subject: scalar double problem with shapewrite

From: Jon Reades

Date: 20 Jul, 2010 14:26:06

Message: 2 of 5

I think you'll find that there's a NULL value of some sort, or that your struct isn't populated in the way that you expect -- I had the same issue with outputting the results of a clustering operation to a shape file and it was only when I printed out everything in the geographical object that I noticed this:

S(8).CLUSTER_ID = 1
S(9).CLUSTER_ID = 2
S(10).CLUSTER_ID =
S(11).CLUSTER_ID =
S(12).CLUSTER_ID =
...
S(28).CLUSTER_ID = 3

Changing my code so that the output now looked like:

S(8).CLUSTER_ID = 1
S(9).CLUSTER_ID = 2
S(10).CLUSTER_ID = 0
S(11).CLUSTER_ID = 0
S(12).CLUSTER_ID = 0
...
S(26).CLUSTER_ID = 0
S(27).CLUSTER_ID = 0
S(28).CLUSTER_ID = 3

allowed me to write the shape file without an error.

Since some types of NULL values/non-values are (as I understand it) technically allowed in DBF files (and, moreover, since this field had already been populated in the original shape file) this seems to be a small quirk of the Geographic Toolbox.

Subject: scalar double problem with shapewrite

From: andrew joros

Date: 30 Apr, 2011 01:44:04

Message: 3 of 5

"Jon Reades" wrote in message <i24blu$4tk$1@fred.mathworks.com>...
> I think you'll find that there's a NULL value of some sort, or that your struct isn't populated in the way that you expect -- I had the same issue with outputting the results of a clustering operation to a shape file and it was only when I printed out everything in the geographical object that I noticed this:
>
> S(8).CLUSTER_ID = 1
> S(9).CLUSTER_ID = 2
> S(10).CLUSTER_ID =
> S(11).CLUSTER_ID =
> S(12).CLUSTER_ID =
> ...
> S(28).CLUSTER_ID = 3
>
> Changing my code so that the output now looked like:
>
> S(8).CLUSTER_ID = 1
> S(9).CLUSTER_ID = 2
> S(10).CLUSTER_ID = 0
> S(11).CLUSTER_ID = 0
> S(12).CLUSTER_ID = 0
> ...
> S(26).CLUSTER_ID = 0
> S(27).CLUSTER_ID = 0
> S(28).CLUSTER_ID = 3
>
> allowed me to write the shape file without an error.
>
> Since some types of NULL values/non-values are (as I understand it) technically allowed in DBF files (and, moreover, since this field had already been populated in the original shape file) this seems to be a small quirk of the Geographic Toolbox.


How did you change your code so your output is new without any errors? I dont see any null values in my struct array. Im stumped. I just need to get past this stage and then I will be able to create that shape file.

Subject: scalar double problem with shapewrite

From: andrew joros

Date: 30 Apr, 2011 01:45:05

Message: 4 of 5

"Jon Reades" wrote in message <i24blu$4tk$1@fred.mathworks.com>...
> I think you'll find that there's a NULL value of some sort, or that your struct isn't populated in the way that you expect -- I had the same issue with outputting the results of a clustering operation to a shape file and it was only when I printed out everything in the geographical object that I noticed this:
>
> S(8).CLUSTER_ID = 1
> S(9).CLUSTER_ID = 2
> S(10).CLUSTER_ID =
> S(11).CLUSTER_ID =
> S(12).CLUSTER_ID =
> ...
> S(28).CLUSTER_ID = 3
>
> Changing my code so that the output now looked like:
>
> S(8).CLUSTER_ID = 1
> S(9).CLUSTER_ID = 2
> S(10).CLUSTER_ID = 0
> S(11).CLUSTER_ID = 0
> S(12).CLUSTER_ID = 0
> ...
> S(26).CLUSTER_ID = 0
> S(27).CLUSTER_ID = 0
> S(28).CLUSTER_ID = 3
>
> allowed me to write the shape file without an error.
>
> Since some types of NULL values/non-values are (as I understand it) technically allowed in DBF files (and, moreover, since this field had already been populated in the original shape file) this seems to be a small quirk of the Geographic Toolbox.


How did you change your code so your output is new without any errors? I dont see any null values in my struct array. Im stumped. I just need to get past this stage and then I will be able to create that shape file.

Subject: scalar double problem with shapewrite

From: Liang kuang

Date: 10 Sep, 2012 15:12:07

Message: 5 of 5

"Jonathan" <jkakiwi@yahoo.co.uk> wrote in message <hn67in$abl$1@fred.mathworks.com>...
> I continued to be puzzled with this problem of trying to convert a matrix using the shapewrite function. I have the following matrix...
>
> A = [1,2,3,4];
> lon = [-123.412482300000, -123.349197000000, -123.387645500000,-123.499196100000];
> lat = [48.1177411000000,48.1170438000000,48.1850616000000,48.2661300000000];
> [test2.Geometry] = deal('MultiPoint');
> test2.id = A;
> test2.lon = lon;
> test2.lat = lat;
> shapewrite(test2, 'test2');
>
> when I run shapewrite I get the following error...
>
> ??? Error using ==> makedbfspec at 116
> Attribute field id of geographic data structure S contains at least
> one value that is not a scalar double.
>
> Error in ==> shapewrite>parseInputs at 555
> dbfspec = makedbfspec(S);
>
> Error in ==> shapewrite at 77
> [S, basename, dbfspec] = parseInputs(varargin{:});
>
> If I eliminate id I still get the same error, now using the lon matrix and so on. I would really appreciate any help on this problem.
>
> Thanks
> Jon

If you change to
for i=1:length(A)
test2(i).id = A;
 test2(i).lon = lon;
test2(i).lat = lat;
end
It will work.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us