From dd4d3c01ac4770bfc5b2f2ccba9a92f36722eb62 Mon Sep 17 00:00:00 2001 From: tchervec Date: Fri, 23 Oct 2020 18:00:33 +0200 Subject: [PATCH] removed all init: in pyproj calls, now just directly used epsg string without init as the old syntax is deprecated --- config.yml | 5 +++-- data/constants.py | 6 +++--- data/spatial/municipalities.py | 2 +- data/spatial/nuts.py | 6 +++--- data/spatial/ovgk.py | 2 +- data/spatial/postal_codes.py | 2 +- data/spatial/quarters.py | 2 +- data/spatial/swiss_border.py | 2 +- data/spatial/utils.py | 6 +++--- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/config.yml b/config.yml index 179a7d6..9e90624 100644 --- a/config.yml +++ b/config.yml @@ -3,8 +3,9 @@ working_directory: /home/tchervec/Documents/data/switzerland/cache # Requested stages run: - - data.statpop.projections.households - - data.statpop.scaled + - data.microcensus.trips +# - data.statpop.projections.households +# - data.statpop.scaled # These are configuration options that we use in the pipeline config: diff --git a/data/constants.py b/data/constants.py index 4fbfb89..2bfaeec 100644 --- a/data/constants.py +++ b/data/constants.py @@ -3,11 +3,11 @@ import pyproj # TODO: Pandas is quite good at working with categorical data. Refactor everything to make use of that. # It will not only be more readable but will also bring a speedup! -CH1903 = pyproj.Proj(init = "EPSG:21781") +CH1903 = pyproj.Proj("EPSG:21781") LV05 = CH1903 -CH1903_PLUS = pyproj.Proj(init = "EPSG:2056") +CH1903_PLUS = pyproj.Proj("EPSG:2056") LV95 = CH1903_PLUS -WGS84 = pyproj.Proj(init = "EPSG:4326") +WGS84 = pyproj.Proj("EPSG:4326") MAXIMUM_HOUSEHOLD_SIZE = 12 MINIMUM_AGE_PER_HOUSEHOLD = 16 diff --git a/data/spatial/municipalities.py b/data/spatial/municipalities.py index 110f7fe..1dafdfc 100644 --- a/data/spatial/municipalities.py +++ b/data/spatial/municipalities.py @@ -35,7 +35,7 @@ def execute(context): df = gpd.read_file( "%s/%s" % (data_path, shapefile), encoding="latin1" - ).to_crs({'init': 'EPSG:2056'}) + ).to_crs("EPSG:2056") df.loc[:, "municipality_id"] = df[id_field] df.loc[:, "municipality_name"] = df[name_field] df.loc[:, "year"] = year diff --git a/data/spatial/nuts.py b/data/spatial/nuts.py index efcc2da..2f1bce0 100644 --- a/data/spatial/nuts.py +++ b/data/spatial/nuts.py @@ -33,9 +33,9 @@ def execute(context): df = gpd.read_file( "%s/%s" % (data_path, shapefile), encoding="utf-8" - ) # .to_crs({'init': 'EPSG:2056'}) - df.crs = {'init': 'EPSG:4326'} - df = df.to_crs({'init': 'EPSG:2056'}) + ) + df.crs = "EPSG:4326" + df = df.to_crs("EPSG:2056") df.loc[:, "nuts_id"] = df[id_field] df.loc[:, "nuts_name"] = df[name_field] diff --git a/data/spatial/ovgk.py b/data/spatial/ovgk.py index 17c611e..c49f9c0 100644 --- a/data/spatial/ovgk.py +++ b/data/spatial/ovgk.py @@ -11,7 +11,7 @@ def configure(context): def execute(context): input_path = "%s/ov_guteklasse/LV95/Oev_Gueteklassen_ARE.shp" % context.config("data_path") df = gpd.read_file(input_path) - df.crs = {"init": "EPSG:2056"} + df.crs = "EPSG:2056" df = df[["KLASSE", "geometry"]].rename({"KLASSE": "ovgk"}, axis=1) return df diff --git a/data/spatial/postal_codes.py b/data/spatial/postal_codes.py index f936c1a..263f373 100644 --- a/data/spatial/postal_codes.py +++ b/data/spatial/postal_codes.py @@ -9,7 +9,7 @@ def execute(context): df = gpd.read_file( "%s/postal_codes/PLZO_SHP_LV95/PLZO_PLZ.shp" % data_path, encoding = "latin1" - ).to_crs({'init': 'EPSG:2056'}) + ).to_crs("EPSG:2056") df["postal_code"] = df["PLZ"] df = df.sort_values(by="postal_code").reset_index() diff --git a/data/spatial/quarters.py b/data/spatial/quarters.py index 788692b..3a0d285 100644 --- a/data/spatial/quarters.py +++ b/data/spatial/quarters.py @@ -12,7 +12,7 @@ def execute(context): df = gpd.read_file( "%s/statistical_quarter_borders/shp/quart17.shp" % data_path, encoding = "latin1" - ).to_crs({'init': 'EPSG:2056'}) + ).to_crs("EPSG:2056") df["quarter_id"] = df["GMDEQNR"] df["quarter_name"] = df["NAME"] diff --git a/data/spatial/swiss_border.py b/data/spatial/swiss_border.py index 1960d24..a236c9b 100644 --- a/data/spatial/swiss_border.py +++ b/data/spatial/swiss_border.py @@ -9,6 +9,6 @@ def execute(context): df = gpd.read_file( "%s/municipality_borders/gd-b-00.03-875-gg18/ggg_2018-LV95/shp/g1l18.shp" % data_path, encoding = "latin1" - ).to_crs({'init': 'EPSG:2056'}) + ).to_crs("EPSG:2056") return df["geometry"] \ No newline at end of file diff --git a/data/spatial/utils.py b/data/spatial/utils.py index 11000ba..7610625 100644 --- a/data/spatial/utils.py +++ b/data/spatial/utils.py @@ -19,7 +19,7 @@ def sample_coordinates(row, count): return np.array(list(map(lambda p: (p.x, p.y), samples[:count]))) -def to_gpd(context, df, x="x", y="y", crs={"init": "EPSG:2056"}): +def to_gpd(context, df, x="x", y="y", crs="EPSG:2056"): df["geometry"] = [ geo.Point(*coord) for coord in context.progress( zip(df[x], df[y]), total=len(df), @@ -28,8 +28,8 @@ def to_gpd(context, df, x="x", y="y", crs={"init": "EPSG:2056"}): df = gpd.GeoDataFrame(df) df.crs = crs - if not crs == {"init": "EPSG:2056"}: - df = df.to_crs({"init": "EPSG:2056"}) + if not crs == "EPSG:2056": + df = df.to_crs("EPSG:2056") return df -- GitLab