-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhexgrid_1km_unclipped_postgres2es.py
41 lines (32 loc) · 1.16 KB
/
hexgrid_1km_unclipped_postgres2es.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python3
# =================================================================
# SPDX-License-Identifier: MIT
#
# Copyright (C) 2020-2021 Government of Canada
#
# Main Authors: Drew Rotheram <drew.rotheram-clarke@canada.ca>
# Joost van Ulden <joost.vanulden@canada.ca>
# =================================================================
import utils
def main():
config = utils.get_config_params("config.ini")
version = config.get("es", "version")
table = utils.PostGISdataset(
utils.PostGISConnection(),
utils.ESConnection(
settings={
"settings": {"number_of_shards": 1, "number_of_replicas": 0},
"mappings": {"properties": {"geometry": {"type": "geo_shape"}}},
}
),
view="opendrr_hexgrid_1km_unclipped_{}".format(version),
sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \
FROM boundaries."HexGrid_1km_unclipped" \
ORDER BY "HexGrid_1km_unclipped"."gridid_1" \
LIMIT {limit} \
OFFSET {offset}',
)
table.postgis2es()
return
if __name__ == "__main__":
main()