From 46d368efb476b2ba277c3b8b67369a9bb37a53b7 Mon Sep 17 00:00:00 2001 From: Rohith Reddy Mandala <51315286+rohith4444@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:00:33 -0400 Subject: [PATCH] Update cgazBuild.py Properly imported all libraries this time --- geoBoundaryBuilder/cgazBuild.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/geoBoundaryBuilder/cgazBuild.py b/geoBoundaryBuilder/cgazBuild.py index ce1c3a2..b97b08a 100644 --- a/geoBoundaryBuilder/cgazBuild.py +++ b/geoBoundaryBuilder/cgazBuild.py @@ -6,6 +6,8 @@ import geopandas import pandas as pd import shutil +from shapely.validation import make_valid +from shapely.geometry import shape, mapping GB_DIR = "/sciclone/geograd/geoBoundaries/database/geoBoundaries/" LOG_DIR = "/sciclone/geograd/geoBoundaries/logs/gbCGAZ/" @@ -14,10 +16,10 @@ + # ignore warnings about using '()' in str.contains https://stackoverflow.com/a/39902267/697964 warnings.filterwarnings("ignore", "This pattern has match groups") - class cgazBuilder(): def __init__(self, GB_DIR, LOG_DIR, BOT_DIR, TMP_DIR): self.stdGeom = BOT_DIR + "dta/usDoSLSIB_Mar2020.geojson" @@ -309,7 +311,7 @@ def geo_valid(self): self.TMP_DIR+ 'geoBoundariesCGAZ_ADM1.geojson', self.TMP_DIR+ 'geoBoundariesCGAZ_ADM2.geojson'] for file in files: - gdf = gpd.read_file(file) + gdf = geopandas.read_file(file) gdf['geometry'] = gdf['geometry'].apply(lambda x: shape(x)) gdf['geometry'] = gdf['geometry'].apply(lambda row: shape(mapping(make_valid(row))['geometries'][0]) if not row.is_valid else row) if "ADM0.geojson" in file: