Commit 5803e3ae authored by Danijel Schorlemmer's avatar Danijel Schorlemmer
Browse files

Improved the district import SQL query

parent a6303c05
Pipeline #37794 passed with stage
in 1 minute and 34 seconds
init-hook='import sys; sys.path.append("exposurejapan")'
......@@ -20,7 +20,7 @@ import logging
from exposurelib.database import SpatialiteDatabase
import pandas
import numpy
from exposurejapan import constants
import constants
import shapely.wkt
import pyproj
from shapely.ops import transform
......@@ -650,10 +650,10 @@ class JapanDatabase(SpatialiteDatabase):
# From the boundary database select admin_id, name and geometry
# and insert into Districts table in the Japan database
sql_statement = "INSERT INTO District (id, admin_id, name, geom) "
sql_statement += "SELECT DISTINCT key_code_ward, key_code_ward, CITY_NAME, "
sql_statement += (
"ST_Transform(CastToMultiPolygon(GeomFromText(AsWKT(CastAutomagic(geom)), %d)), "
sql_statement = (
"INSERT INTO District (id, admin_id, name, geom) "
"SELECT key_code_ward, key_code_ward, CITY_NAME, "
"ST_Transform(CastToMultiPolygon(GeomFromWKB(AsBinary(geom), %d)), "
"%d) " % (constants.JGD2000, constants.WGS84)
sql_statement += "FROM BoundaryDatabase.Boundary"
......@@ -20,7 +20,7 @@
import logging
import sys
import sqlite3
from .database import JapanDatabase # pylint: disable=E0611,E0401
from database import JapanDatabase # pylint: disable=E0611,E0401
# Add a logger printing error, warning, info and debug messages to the screen
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment