From a792e7377b8cc7bf18e7916397c3306d480550be Mon Sep 17 00:00:00 2001 From: "Leaf, Andrew T" Date: Wed, 22 Feb 2023 10:06:23 -0600 Subject: [PATCH] refactor(utils/mfreadnam.py): write crs 'srs' attribute string to namefile header under 'crs' key; read 'proj4' key as crs input --- flopy/utils/mfreadnam.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/flopy/utils/mfreadnam.py b/flopy/utils/mfreadnam.py index 5dc78a403e..0bd0b3eb2d 100644 --- a/flopy/utils/mfreadnam.py +++ b/flopy/utils/mfreadnam.py @@ -212,6 +212,7 @@ def attribs_from_namfile_header(namefile): "xul": None, "yul": None, "rotation": 0.0, + "crs": None, "proj4_str": None, } if namefile is None: @@ -259,7 +260,15 @@ def attribs_from_namfile_header(namefile): proj4 = ":".join(item.split(":")[1:]).strip() if proj4.lower() == "none": proj4 = None - defaults["proj4_str"] = proj4 + defaults["crs"] = proj4 + except: + print(f" could not parse proj4_str in {namefile}") + elif "crs" in item.lower(): + try: + crs = ":".join(item.split(":")[1:]).strip() + if crs.lower() == "none": + proj4 = None + defaults["crs"] = crs except: print(f" could not parse proj4_str in {namefile}") elif "start" in item.lower():