Skip to content
Snippets Groups Projects
Commit 034d96fe authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Use function `open_shpc`

parent fbb09dd4
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,8 @@ import shapefile
from os import path
import pprint
import sys
sys.path.append(path.join(sys.path[0], "../../Common"))
import util_detect_eddies
parser = argparse.ArgumentParser()
parser.add_argument("directory", help = "containing the three shapefiles")
......@@ -19,27 +21,24 @@ reply = input("days_1950, eddy_index = ? ").split(",")
days_1950 = int(reply[0])
eddy_index = int(reply[1])
# Find ishape:
filename = path.join(args.directory, "extremum")
readers, d_init, ishape_last = util_detect_eddies.open_shpc(args.directory)
with shapefile.Reader(filename) as f:
for ishape, rec in enumerate(f.iterRecords()):
if rec["days_1950"] == days_1950 and rec["eddy_index"] == eddy_index:
break
else:
sys.exit("Not found")
# Find ishape:
for ishape, rec in enumerate(readers["extremum"].iterRecords()):
if rec["days_1950"] == days_1950 and rec["eddy_index"] == eddy_index:
break
else:
sys.exit("Not found")
#--
for basename in ["extremum", "outermost_contour", "max_speed_contour"]:
filename = path.join(args.directory, basename)
with shapefile.Reader(filename) as f:
shapeRec = f.shapeRecord(ishape)
print("\n", filename, ":")
if shapeRec.shape.shapeType == shapefile.NULL:
dct = shapeRec.record.as_dict()
pprint.pprint(dct)
print("null shape")
else:
pprint.pprint(shapeRec.__geo_interface__)
shapeRec = readers[basename].shapeRecord(ishape)
print("\n", filename, ":")
if shapeRec.shape.shapeType == shapefile.NULL:
dct = shapeRec.record.as_dict()
pprint.pprint(dct)
print("null shape")
else:
pprint.pprint(shapeRec.__geo_interface__)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment