Shapefile field problem
Abe Gillespie
agillesp at VT.EDU
Tue Dec 7 08:50:03 PST 2004
Sorry, somehow I missed this. I just tried it though and it seems to
work fine; the first record contains the field names with all the other
records following. Albeit with a lot of (NULL)'s. :)
-Abe
On Dec 7, 2004, at 11:17 AM, Jeff McKenna wrote:
> earlier in the thread i suggested dbfdump:
>
> Jeff McKenna wrote:
> > Frank would know way more about this than me...but are any of the
> > Shapelib utilities (http://shapelib.maptools.org/) useful for you?
> > (shpdump, dbfdump)
> >
> > jeff
>
>
>
>
>
> Abe Gillespie wrote:
>> Attached is the problematic shapefile. I don't create it, I get it
>> from a customer. However, if the need arises, I should be able to get
>> detailed information on how the shapefile comes to be. Using the
>> following PHP script should reveal the problem. I have not tried
>> DBFDUMP; I don't know where to get it.
>>
>> for ($i = 0; $i < $map->numlayers; $i++)
>> {
>> $l = $map->getLayer($i);
>> putBrLine($l->name.", type: ".$l->type);
>> if ($l->data != null) // Shape files with
>> data.
>> {
>> $l->open();
>> $s = $l->getShape(-1, 0);
>> $vals = $s->values;
>> putBrLine("field count:
>> ".count($vals));
>> while ($fld = current($vals))
>> {
>>
>> putBrLine(" ".key($vals));
>> next($vals);
>> }
>> $s->free();
>> $l->close();
>> }
>> }
>>
>> Thanks.
>> -Abe
>>
>>
>>
>> On Dec 6, 2004, at 9:13 PM, Ed McNierney wrote:
>>
>>> Abe -
>>>
>>> Can you post the shapefile somewhere we can look at it?
>>>
>>> The field definitions for a shapefile (DBF) are stored in a separate
>>> header, describing each field; you can't get the field definitions
>>> from
>>> the first record. In fact, you can't read the first record properly
>>> until *after* you've figured out the field definitions.
>>>
>>> Are you creating this shapefile yourself? Could you be creating a
>>> defective file? Have you tried running DBFDUMP on it?
>>>
>>> - Ed
>>>
>>> Ed McNierney
>>> President and Chief Mapmaker
>>> TopoZone.com / Maps a la carte, Inc.
>>> 73 Princeton Street, Suite 305
>>> North Chelmsford, MA 01863
>>> Phone: +1 978 251-4242 Fax: +1 978 251-1396
>>>
>>> -----Original Message-----
>>> From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU]
>>> On
>>> Behalf Of Abe Gillespie
>>> Sent: Monday, December 06, 2004 8:14 PM
>>> To: MAPSERVER-USERS at LISTS.UMN.EDU
>>> Subject: Re: [UMN_MAPSERVER-USERS] Shapefile field problem
>>>
>>> It's a regular shapefile. I think I've mostly narrowed it down. It
>>> seems to me (though I may be completely off) that MapServer loads the
>>> first record of the DBF in order to get the field definitions. If
>>> the
>>> first record has a string field and the value is zero length it won't
>>> give me the field (though the field count is always correct). In
>>> addition, it won't give me any fields after that either. If,
>>> however,
>>> I
>>> make sure that field has some value (a dash, an "x", whatever) then
>>> the
>>> field definition will come in correctly. I still haven't narrowed
>>> down
>>> a problematic number field though. Mind you, this is all done in
>>> MapServer PHP v. 4.2.0.
>>>
>>> -Abe
>>>
>>> On Dec 6, 2004, at 6:15 PM, Daniel Morissette wrote:
>>>
>>>> Abe Gillespie wrote:
>>>>
>>>>> A good amount of fields aren't showing up in MapServer for me. I
>>>>> use
>>>
>>>
>>>>> the following PHP script to dump out all layers and their fields
>>>>> for
>>>>> debugging. Does MapServer have problems with certain data types or
>>>>> certain values in a row?
>>>>>
>>>>
>>>> Are you using a tiled shapefile layer or is this a regular shapefile
>>>> layer?
>>>>
>>>> --
>>>> ------------------------------------------------------------
>>>> Daniel Morissette dmorissette at dmsolutions.ca
>>>> DM Solutions Group http://www.dmsolutions.ca/
>>>> ------------------------------------------------------------
>>>>
>>>
>
>
> --
> Jeff McKenna
> GIS Specialist
> DM Solutions Group Inc.
> http://www.dmsolutions.ca
>
More information about the MapServer-users
mailing list