Shapefile field problem

Jeff McKenna jmckenna at DMSOLUTIONS.CA
Tue Dec 7 11:17:24 EST 2004


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("&nbsp;&nbsp;".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