0

Following on from Records of shapefile do not contain every field, where @scruss provided some very helpful Python code.

I seem to have a fundamental inability to understand a shapefile (reader object).

Each Pyshp shape consists of a record plus a geometry (bounding box).

However, each record also has “north, south, west, east” items, which have a granularity of one degree.

And the min/max/mean elevations never change over that one degree. Every record in that one degree seems ot have the same elevation values, although each has a different bbox.

I need more detail, and had hoped/expected that those elevations would reflect the bbox.

Am I out of luck? I want to extract the highest elevation for each 0.01 degree square.

The field names are

<type 'list'>: 
['ID', 
 'SOURCE_ORG', 
 'SOURCE', 
 'EL_SURFACE', 
 'NORTH', 
 'SOUTH', 
 'WEST', 
 'EAST', 
 'X_SRCE_RES', 
 'Y_SRCE_RES', 
 'HORZ_UNIT', 
 'COORD_SYS', 
 'HORZ_DATUM', 
 'VERT_DATUM', 
 'VERT_UNIT', 
 'MIN_ELEV', 
 'MAX_ELEV', 
 'MEAN_ELEV', 
 'SDEV_ELEV', 
 'PROD_DATE']

and here are the first two records, followed by their bboxes.

<type 'list'>: 
[268, 
 'Univ of Bristol', 
 'Ant Radar and Laser Alt DEM', 
 'Reflective', 
 -55,    <===== these four don't change for many records, but the booxes do
 -90, 
 -180, 
 180, 
 1000.0, 
 1000.0, 
 'Meter', 
 'Polar Sterographic', 
 'WGS 84', 
 'WGS 84', 
 'Meter', 
 -82,     <=== these are the elvations
 4211,    <=== which remain constant for the 1 dgeree square
 2152.694, 
 1127.631, 
 '31Aug2011']


<type 'list'>: 
[269,     <=== a new record number
 'Univ of Bristol', 
 'Ant Radar and Laser Alt DEM', 
 'Reflective', 
 -55,     <=== stil the same 1 degree square
 -90, 
 -180, 
 180, 
 1000.0, 
 1000.0, 
 'Meter', 
 'Polar Sterographic', 
 'WGS 84', 
 'WGS 84', 
 'Meter', 
 -82,    <=== still the same elevation data
 4211, 
 2152.694, 
 1127.631, 
 '31Aug2011']

and the two bboxes :

[-103.71666666971798, -72.74206576893341, -103.58333333639, -72.71706576893436]

[-126.75833333546299, -73.17539910224943, -126.64166666880098, -73.14206576891738]

Here is the code that produces the above data

            data = shapefile.Reader(arguments.data_path + '\\' + fileName)

            # get field names, skipping deleted flag
            field_names = []
            for f in data.fields[1:]:
                field_names.append((f[0]))

            shapeRecords = data.iterShapeRecords()

            for shape in shapeRecords:
                geometry = shape.shape
                record = shape.record
  • 3
    While referencing another question is okay, it shouldn't be necessary to read the other question to understand this one. Please edit the question to stand independently. You will certainly need a description of the geometry type and field definitions, since your question is more likely particular to that one dataset than to all shapefiles. – Vince Sep 27 '16 at 15:05
  • The only question asked here is "Am I out of luck?". Can you state your focussed question more clearly, pleased? I suspect it would help to include a code snippet that illustrates what you have tried and where you are stuck too. – PolyGeo Sep 28 '16 at 21:16
  • I will post the code. To show willing. B but doubt if it will help, as you can see the data which it produces. So, yes, it probably is an "am I SOL?" question. BUT, I am a GIS n00b, but cannot believe that the SRTM only gives the highest point in a one degree square. Since SRTM sounds like it could be a popular dataset, I was really hoping that several people here would be very familiar with it and could offer me some advice. Can you suggest how I could reword the question? Thanks – Mawg Sep 29 '16 at 7:26
  • 1
    @Mawg It's pretty unclear what you're trying to do. SRTM data is available at 0.00028 degree resolution, but why are you trying to read it as a shapefile? If you just want SRTM data, get it as a raster, e.g. from here: earthexplorer.usgs.gov. – Nat Wilson Oct 1 '16 at 0:51
  • Since I know nothing about GIS data formats, I took the first that I found. I have now got the data as TIF and am struggling trying to install GDAL on Windows, as that seems to be the way to go. Thanks for pointing that out, – Mawg Oct 1 '16 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.