Getting attributes from a shapefile from Mapscript/PhP (Mapserver)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting attributes from a shapefile from Mapscript/PhP (Mapserver)

swathi v
Hi,

I have a shapefile/vector file as Layer in the .map file.

Now, I want to get all the attributes of that shapefile in my Mapscript/PhP and display them on the browser.

For example, a shapefile has the attributes as Name, Type, Width. Now I want to get these attributes from that layer dynamically from my PhP/Mapscript code.

So please let me know how to get attributes from a shapefile from Mapscript/PhP.


Thanks & Regards,
- swathi.m

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Getting attributes from a shapefile from Mapscript/PhP (Mapserver)

Carlos Ruiz
Swathi,

Have a look here PHP MapScript API — MapServer 7.0.6 documentation at the getShape method.


Cheers




From: swathi v <[hidden email]>
To: [hidden email]
Sent: Thursday, August 3, 2017 5:17 AM
Subject: [mapserver-users] Getting attributes from a shapefile from Mapscript/PhP (Mapserver)

Hi,

I have a shapefile/vector file as Layer in the .map file.

Now, I want to get all the attributes of that shapefile in my Mapscript/PhP and display them on the browser.

For example, a shapefile has the attributes as Name, Type, Width. Now I want to get these attributes from that layer dynamically from my PhP/Mapscript code.

So please let me know how to get attributes from a shapefile from Mapscript/PhP.


Thanks & Regards,
- swathi.m
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users


_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Getting attributes from a shapefile from Mapscript/PhP (Mapserver)

swathi v
In reply to this post by swathi v
Hi,

Thank you. Now, I am able to retrieve the layer attributes using the getItems() method.

Now I want to retrieve the values under each attribute for that layer.

For example, want to retrieve the values under the attribute, Name of a layer by name "states".

Thanks & Regards,
- swathi.m

On Thu, Aug 3, 2017 at 3:47 PM, swathi v <[hidden email]> wrote:
Hi,

I have a shapefile/vector file as Layer in the .map file.

Now, I want to get all the attributes of that shapefile in my Mapscript/PhP and display them on the browser.

For example, a shapefile has the attributes as Name, Type, Width. Now I want to get these attributes from that layer dynamically from my PhP/Mapscript code.

So please let me know how to get attributes from a shapefile from Mapscript/PhP.


Thanks & Regards,
- swathi.m



--
- swathi.m

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Getting attributes from a shapefile from Mapscript/PhP (Mapserver)

Carlos Ruiz
Once you have the shape object, you can access the associative array values to retrieve the desired value by attribute name.

The values array is an associative array with the attribute values for this shape. It is set only on shapes obtained from layer->getShape(). The key to the values in the array is the attribute name, e.g.
$population = $shape->values["Population"];
Taken from




Cheers






From: swathi v <[hidden email]>
To: [hidden email]
Sent: Thursday, August 10, 2017 3:34 AM
Subject: Re: [mapserver-users] Getting attributes from a shapefile from Mapscript/PhP (Mapserver)

Hi,

Thank you. Now, I am able to retrieve the layer attributes using the getItems() method.

Now I want to retrieve the values under each attribute for that layer.

For example, want to retrieve the values under the attribute, Name of a layer by name "states".

Thanks & Regards,
- swathi.m

On Thu, Aug 3, 2017 at 3:47 PM, swathi v <[hidden email]> wrote:
Hi,

I have a shapefile/vector file as Layer in the .map file.

Now, I want to get all the attributes of that shapefile in my Mapscript/PhP and display them on the browser.

For example, a shapefile has the attributes as Name, Type, Width. Now I want to get these attributes from that layer dynamically from my PhP/Mapscript code.

So please let me know how to get attributes from a shapefile from Mapscript/PhP.


Thanks & Regards,
- swathi.m



--
- swathi.m
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users



_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users