[mapserver-users] Reading shapefile's attributes
Pedro Arriondo
pedroaa10 at gmail.com
Wed Apr 21 06:44:23 PDT 2010
Excellent Josh, im really very thankful for your help.
i will try and then i will write to tell how it was.
Please, sorry for my bad english!!!!
2010/4/21 Joshua Hevenor <jhevenor at rogers.com>
> It doesn't say anything in the PHP mapscript doc that would prevent this
> from working but I haven't done it this way.
>
> If I was iterating through all shapes I would have a mapfile with the
> shapefile defined as a layer and use code like the the example the
> LayerObj::nextShape() documentation:
>
> $map = ms_newmapobj("d:/msapps/gmap-ms40/htdocs/gmap75.map");
> $layer = $map->getLayerByName('road');
> $status = $layer->open();
> $status = $layer->whichShapes($map->extent);
> while ($shape = $layer->nextShape())
> {
> echo $shape->index ."<br>\n";
> }
> $layer->close();
>
>
> I think the $layer->open is key to making the attributes available.
> LayerObj::open() states that it will "Open the layer for use with getShape()". Someone else may be able to offer a better explanation,
> but at least this approach has worked for me in the past.
>
>
>
>
> ------------------------------
> *From:* Pedro Arriondo <pedroaa10 at gmail.com>
> *To:* Joshua Hevenor <jhevenor at rogers.com>;
> mapserver-users at lists.osgeo.org
> *Sent:* Wed, April 21, 2010 7:35:59 AM
> *Subject:* Re: [mapserver-users] Reading shapefile's attributes
>
> First, thanks Josh for your answer.
> I tell you that the the file it's good, because i use it in my job with
> Mapserver.
> Too i can access to attributes with library dbase from PHP.
> (dbase_open,...dbase_get_record_with_names,...)
> So.... i don't know how to continue....
>
>
> 2010/4/20 Joshua Hevenor <jhevenor at rogers.com>
>
>> You can check that the shapefile has attributes using the command line
>> tool ogrinfo. http://www.gdal.org/ogrinfo.html
>> You can check on spelling of fields, etc. It might as least get you
>> started.
>>
>> Cheers,
>> Josh
>>
>> ------------------------------
>> *From:* Pedro Arriondo <pedroaa10 at gmail.com>
>> *To:* mapserver-users at lists.osgeo.org
>> *Sent:* Tue, April 20, 2010 2:36:15 PM
>> *Subject:* [mapserver-users] Reading shapefile's attributes
>>
>> Hi friends, i writte from Argentina.
>>
>> I'd like read attributes from a shapefile but i get "nothing", however i
>> can read very good the geometries.
>> My code:
>>
>> $shpFile = ms_newShapeFileObj( $_SERVER["DOCUMENT_ROOT"]."/zonas", -1);
>> //my shapefile in disc
>> echo $shpFile->numshapes; //8 -> it's right!!
>>
>> $oShape = $shpFile->getShape(0); //get first object
>>
>> //..but....:
>> echo $oShape->numvalues; //0, however it has 2 values: "CODIGO" and
>> "NOMBRE"
>> echo $oShape->values["CODIGO"]; //Here get empty (value is 4)
>>
>>
>> Thanks in advance!!!!.
>>
>> Pedro.
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100421/0850f9a0/attachment.htm>
More information about the MapServer-users
mailing list