Shapefile Load Error

Mar 17, 2011 at 1:54 PM

I have a shapefile (Polyline M) that loads fine in ArcMap.

Using the code below, I try to load it into DotSpatial (latest) using Visual Stuio 2010 (VB.Net).

I am getting the following error. Is there anything I am doing wrong here. The error is:

Value cannot be null. Parameter name: src

If I try to drag the shapefile onto the map I get the error:

One or more of the files was not a valid data type for the map.

My code is:

For Each myShapeFile As String In myShapeFolders

                        '*****************************
                        ' Add Shape To The Map.
                        '*****************************

                        Try

                            Dim myFS As New FeatureSet

                            myFS.Open(myShapeFile)

                            Map1.Layers.Add(myFS)

                        Catch ex As Exception

                            MsgBox(ex.Message)

                        End Try

                    Next myShapeFile

 

 

 

Mar 17, 2011 at 2:29 PM

I have added other layer types (lines, points, etc) with no issues, but all of the Polyline M shape types do not load.

In ArcMap the datatype is:

Data Type: Shapefile Feature Class
Shapefile: N:\DVMS\DVMS Data\Map Layers\Roads.shp
Geometry Type: Line

In the attribute table the Shape is shown as Polyline M.

 

May 22, 2011 at 1:12 PM

Hi

I am getting the same error for PolyLine shapefiles.  "Value cannot be null" and for another "Input string was not in a correct format"

[Using DotSpatial_x86_fw40_20110422]

Oliver

 

May 22, 2011 at 2:16 PM

I have debugged the second error...  The polyline shapefile had been generated afresh and the LBL file had not...  The LBL file had been created by MapWindow at some point.  After deleting the LBL file the PolyLine file loaded...

In the first...

1)  DotSpatial.Data.LineShapeFile.cs: FillLines picks up the header of the shapefile and correctly reads the type, extents etc.  [PolyLine not PolyLineM in my case]

2)  ReadIndexFile picks up 3695 shapes

3)  "Value cannot be null" occurs on the last shape shp = 3694

4)  it fails within the function allCoords.Read ... -> Data.ByteBlock.Read() -> fails at   reader.Read(Blocks[CurrentBlock], Offset, firstLen);

Blocks[CurrentBlock] has length 16000000 and all values are 0, Offset 15032, firstLen = 15984968

In the BufferedBinaryReader it's failing in the Read function because the private variable _buffer is null in the following:

Buffer.BlockCopy(_buffer, _readOffset, buffer, index, bytesInBuffer);


Using a ShapeFile debugger I wrote a long time ago, the Line 3694 has the following values:

Index File .SHX:  Offset = 340160 - Length = 0

.SHP : ContentLength = 0 - ShapeType = 0 (possibly not read) - Shape = NullShape

I hope some of that helps in finding the error...

tposhea, do you know if you have any null shapes in the shapefile?

My simple SHP viewer might help .. it's very basic but might work... http://goo.gl/Xed20

Oliver


May 25, 2011 at 3:29 PM

No NULL values. Shapefile has 258 Polyline M entries. Here is an exported version of the data:

OBJECTID HWY LEN SHAPE_LEN
4 101 0.00000000 5.89534658435
5 102 0.00000000 0.42120364483
6 105 0.00000000 1.89636490608
7 108 0.00000000 0.41578693140
1 1 0.00000000 1.59605850407
2 10 0.00000000 1.79308819336
3 1000 0.00000000 0.42685187867
8 11 0.00000000 22.19316319720
9 112 0.00000000 0.20163341913
10 115 0.00000000 0.56600218140
11 118 0.00000000 1.93958219551
12 11B 0.00000000 0.26625155074
13 12 0.00000000 1.59700644843
14 124 0.00000000 0.84324677566
15 125 0.00000000 0.16204029998
16 127 0.00000000 0.40052295286
17 129 0.00000000 2.29543771271
18 130 0.00000000 0.17323334612
19 132 0.00000000 0.35132850561
20 137 0.00000000 0.04328218811
21 138 0.00000000 0.38851471276
22 140 0.00000000 0.10101532039
23 141 0.00000000 0.62587474570
24 144 0.00000000 2.72071259156
25 148 0.00000000 0.16880635579
26 15 0.00000000 1.66987659934
27 16 0.00000000 0.03921014391
28 17 0.00000000 23.75523951470
29 17A 0.00000000 0.41080782046
30 17B 0.00000000 0.30938646597
31 19 0.00000000 0.48771890148
32 2 0.00000000 3.12408805477
33 20 0.00000000 0.85409403173
34 21 0.00000000 3.33755678983
35 23 0.00000000 0.96209980654
36 24 0.00000000 0.97417670810
37 26 0.00000000 1.37784817434
38 27 0.00000000 0.02387944363
39 28 0.00000000 1.71638367190
40 3 0.00000000 4.71310268885
41 33 0.00000000 1.54996012133
42 34 0.00000000 0.16026349362
43 35 0.00000000 1.94652253682
44 37 0.00000000 0.45331859422
45 4 0.00000000 1.16066145470
46 40 0.00000000 0.91126985078
48 400A 0.00000000 0.00899959916
50 402 0.00000000 1.22490501521
47 400 0.00000000 2.04570885216
51 403 0.00000000 1.41271138684
59 416 0.00000000 0.75155337892
61 420 0.00000000 0.05608131434
49 401 0.00000000 9.54016867131
52 404 0.00000000 0.34239410965
53 405 0.00000000 0.10148583281
54 406 0.00000000 0.25079822774
55 407 0.00000000 1.16708906708
56 409 0.00000000 0.06324986642
57 41 0.00000000 2.06740363413
58 410 0.00000000 0.18307755551
60 417 0.00000000 2.15258683024
62 427 0.00000000 0.19578518502
63 48 0.00000000 1.32488960872
64 49 0.00000000 0.26454688043
65 5 0.00000000 0.95653692924
66 502 0.00000000 1.62567545141
67 510 0.00000000 0.02603124688
68 516 0.00000000 1.33720635387
69 518 0.00000000 1.03444001484
70 519 0.00000000 0.37324184663
71 52 0.00000000 0.09653073096
72 520 0.00000000 0.80473545772
73 522 0.00000000 1.33164468426
74 522B 0.00000000 0.02032627296
75 523 0.00000000 0.20342455860
76 524 0.00000000 0.04629929809
77 525 0.00000000 0.40093201028
78 526 0.00000000 0.04063219168
79 527 0.00000000 2.41660283736
80 528 0.00000000 0.16901340590
81 528A 0.00000000 0.06111065310
82 529 0.00000000 0.27432336433
83 529A 0.00000000 0.05438275816
84 531 0.00000000 0.03480095540
85 532 0.00000000 0.15286684039
86 533 0.00000000 0.59532264853
87 534 0.00000000 0.51152765542
88 535 0.00000000 0.44450222344
89 537 0.00000000 0.19766970647
90 538 0.00000000 0.06669336341
91 539 0.00000000 0.41254166716
92 539A 0.00000000 0.06070548102
93 540 0.00000000 1.49095708563
94 540A 0.00000000 0.06774905540
95 540B 0.00000000 0.05014533225
96 542 0.00000000 0.75143904645
97 542A 0.00000000 0.03022964985
98 546 0.00000000 0.84859982532
99 547 0.00000000 0.05586583785
100 548 0.00000000 0.81464131065
101 550 0.00000000 0.26811076133
102 551 0.00000000 0.29068065058
103 552 0.00000000 0.20934723946
104 553 0.00000000 0.36120998165
105 554 0.00000000 0.17741282504
106 556 0.00000000 1.22494475256
107 557 0.00000000 0.25150028538
108 558 0.00000000 0.34458654395
109 559 0.00000000 0.21875482825
110 560 0.00000000 2.21693543404
111 560A 0.00000000 0.11234554320
112 562 0.00000000 0.17900971464
113 563 0.00000000 0.05650089033
114 564 0.00000000 0.08959339477
115 565 0.00000000 0.03985644086
116 566 0.00000000 0.28289552428
117 567 0.00000000 0.40016879717
118 568 0.00000000 0.03098195464
119 569 0.00000000 0.29946579107
120 570 0.00000000 0.05385950322
121 571 0.00000000 0.05226145682
122 572 0.00000000 0.17298351102
123 573 0.00000000 0.18743158710
124 574 0.00000000 0.18007751842
125 575 0.00000000 0.20337322633
126 577 0.00000000 0.22910182207
127 579 0.00000000 0.33796371753
128 58 0.00000000 0.33725095980
129 580 0.00000000 0.15751446362
130 581 0.00000000 0.10356150093
131 582 0.00000000 0.07244645199
132 583 0.00000000 0.50546244883
133 584 0.00000000 0.71565025083
134 585 0.00000000 0.37538863020
135 586 0.00000000 0.06811086917
136 587 0.00000000 0.43371873773
137 588 0.00000000 0.67127811423
138 589 0.00000000 0.30073352187
139 58A 0.00000000 0.05460467179
140 590 0.00000000 0.26716892834
141 591 0.00000000 0.08261877417
142 592 0.00000000 0.17090405809
143 593 0.00000000 0.52953141641
144 594 0.00000000 0.46494651450
145 595 0.00000000 0.41460893985
146 596 0.00000000 0.56711874128
147 597 0.00000000 0.16396058226
148 599 0.00000000 3.13262283622
149 6 0.00000000 5.50190316150
216 7 0.00000000 6.79181974516
220 7042 0.00000000 0.16399947447
221 7044 0.00000000 0.25527996117
222 7048 0.00000000 0.01146916984
223 7057 0.00000000 0.01464689825
224 7059 0.00000000 0.05416096987
225 7082 0.00000000 0.02729224283
226 71 0.00000000 2.14338648838
227 7102 0.00000000 0.00471114104
228 7104 0.00000000 0.03194178760
229 7125 0.00000000 0.00609906389
230 7146 0.00000000 0.02085435639
231 7181 0.00000000 0.00843504834
232 7182 0.00000000 0.20253910050
233 7186 0.00000000 0.01005424625
234 7187 0.00000000 0.03761836860
235 7189 0.00000000 0.02235445230
236 7191 0.00000000 0.02028480573
237 7195 0.00000000 0.00806713313
238 72 0.00000000 0.79715585553
239 7202 0.00000000 0.09993341376
240 7236 0.00000000 0.02486912100
241 7237 0.00000000 0.01208491960
242 7241 0.00000000 0.09007624879
243 7273 0.00000000 0.06845742685
244 7274 0.00000000 0.00647458811
245 7277 0.00000000 0.11549545086
246 77 0.00000000 0.22352793204
247 7A 0.00000000 0.58527596735
249 801 0.00000000 0.15290743081
250 802 0.00000000 0.16870489116
248 8 0.00000000 2.32891341809
251 804 0.00000000 0.28673403471
252 805 0.00000000 0.48734743446
253 810 0.00000000 0.43771226792
254 811 0.00000000 0.71451034570
255 85 0.00000000 0.10472391294
256 89 0.00000000 1.36383140102
257 9 0.00000000 2.28656966683
258 93 0.00000000 0.40373451492
259 94 0.00000000 0.13055424108
150 60 0.00000000 2.96843836773
151 600 0.00000000 1.01001898582
152 601 0.00000000 0.28177928810
153 602 0.00000000 0.55283315235
154 603 0.00000000 0.04795695003
155 605 0.00000000 0.11248761346
156 607 0.00000000 0.09362950091
157 607A 0.00000000 0.02914574773
158 608 0.00000000 0.24164044136
159 609 0.00000000 0.17748037511
160 61 0.00000000 0.65037913146
161 611 0.00000000 0.22040751021
162 612 0.00000000 0.03984953690
163 613 0.00000000 0.37707453851
164 614 0.00000000 0.52219562248
165 615 0.00000000 0.23195230700
166 617 0.00000000 0.23214657740
167 618 0.00000000 0.13576259950
168 619 0.00000000 0.39017257399
169 62 0.00000000 1.62621854243
170 621 0.00000000 0.49565859657
171 622 0.00000000 1.48247982032
172 623 0.00000000 0.04989288268
173 624 0.00000000 0.42416528126
174 625 0.00000000 0.34518219648
175 627 0.00000000 0.12328603853
176 628 0.00000000 0.08493814646
177 63 0.00000000 0.70411309287
178 630 0.00000000 0.29653211836
179 631 0.00000000 1.79066141107
180 632 0.00000000 0.11554347292
181 633 0.00000000 0.05596295886
182 634 0.00000000 0.80952784870
183 636 0.00000000 0.04299156560
184 637 0.00000000 0.81087017722
185 638 0.00000000 0.59007414928
186 639 0.00000000 0.24393251618
187 64 0.00000000 1.61250666003
188 641 0.00000000 0.16280603242
189 642 0.00000000 0.89806010648
190 643 0.00000000 0.24213236714
191 644 0.00000000 0.00898030733
192 645 0.00000000 0.04800234418
193 647 0.00000000 0.09899326325
194 65 0.00000000 1.42478718366
195 650 0.00000000 0.09683981128
196 651 0.00000000 0.56075465871
197 652 0.00000000 1.71019205902
198 654 0.00000000 0.26327457879
199 655 0.00000000 0.70902396013
200 656 0.00000000 0.03731519018
201 657 0.00000000 0.06981134099
202 658 0.00000000 0.30706064803
203 66 0.00000000 1.26907168787
204 661 0.00000000 0.04847660783
205 663 0.00000000 0.04979890920
206 664 0.00000000 0.22221592138
207 665 0.00000000 0.20093345089
208 667 0.00000000 0.45849504095
209 668 0.00000000 0.12144724730
210 67 0.00000000 0.13076475564
211 670 0.00000000 0.11698422454
212 671 0.00000000 0.80020675256
213 672 0.00000000 0.46046770710
214 673 0.00000000 0.08272588370
215 69 0.00000000 2.14335817433
217 7036 0.00000000 0.05813106711
218 7037 0.00000000 0.09762194389
219 7041 0.00000000 0.01536438281

 

May 25, 2011 at 4:40 PM

if you want to email me the dbf, shx, shp files, i'll run them through the debugger ..   see where they crash...?

mail at oliver slay dot com... 

May 25, 2011 at 4:53 PM

The debugger read the file successfully as shapefile, index, and dbx.

Only thing I noticed was MMin had no value and MMax has a value of 1979.31350092217

XMin, YMin, XMax and YMax are all lat/long values (NAD83).

Any ideas?

Terry

On Wed 25/05/11 16:40 , "zorgster" notifications@codeplex.com sent:

From: zorgster

if you want to email me the dbf, shx, shp files, i'll run them through the debugger .. see where they crash...?

mail at oliver slay dot com...


May 25, 2011 at 7:38 PM

I think you can ignore the fact there's a missing MMin ... ... From ESRI's specification...

"Mmin and Mmax can contain "nodata" values (see Numeric Types on page 2) for shapefiles of measured shape types that contain no measures."

"...shapefiles support the concept of "no data" values, but they are currently used only for measures. Any floating point number smaller than –1038 is considered by a shapefile reader to represent a 'no data' value."

The question is... does DotSpatial ignore the missing MMin value? ... or could it be something else...  the current build looks like it does...

May 25, 2011 at 7:46 PM

The shapefiles are Highway polylines. They are also used with routing events in ESRI. Would this cause any issues?

Terry


On Wed 25/05/11 19:38 , "zorgster" notifications@codeplex.com sent:

From: zorgster

I think you can ignore the fact there's a missing MMin ... ... From ESRI's specification...

"Mmin and Mmax can contain "nodata" values (see Numeric Types on page 2) for shapefiles of measured shape types that contain no measures."

"...shapefiles support the concept of "no data" values, but they are currently used only for measures. Any floating point number smaller than –1038 is considered by a shapefile reader to represent a 'no data' value."

The question is... does DotSpatial ignore the missing MMin value? ... or could it be something else... the current build looks like it does...


May 25, 2011 at 10:02 PM

Does it make a difference if you load the file with:   Map1.AddLayer("file.shp")

Oliver