Question

I'm using Pyshp to extract information from a shapefile. Using the the shapefile.Reader() program, I am able to get the following output:

    [('DeletionFlag', 'C', 1, 0), ['Id', 'N', 11, 0], ['Hrapx', 'N', 6, 0], ['Hrapy','N', 6, 0], ['Lat', 'N', 7, 4], ['Lon', 'N', 9, 4], ['Globvalue', 'N', 16, 2]]

How can I extract all of the values for the last index in the list (i.e., 'Globvalue').

This should also be easy to extract the Lat and Lon fields too right?

I'm assuming it is something along the lines of points = shaperecs[:].shape.points[:] but I have been spending hours trying to figure out the exact syntax.

Any help would be great!

Was it helpful?

Solution

I was able to solve this by using basemap (which uses Pyshp):

   val = []
   s = m.readshapefile('last_500','last_500')
   for shapedict in m.last_500_info:
       val.append(shapedict['fieldname'])
   print val
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top