-
Notifications
You must be signed in to change notification settings - Fork 0
/
import_osm.py
42 lines (38 loc) · 1.49 KB
/
import_osm.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
42
'''Import an OSM file into PostGIS/RUM.
Parses an OSM file and creates several layers in the defined RUM analysis
schema. Uses a temporary SQLite database to resolve geometries.
'''
import rum
import rum.input
argparser = rum.defaultArgumentParser(__doc__)
argparser.add_argument('-t', '--transform-conf', metavar='conffile',
help='OSM transformation configuration file', type=int, default=None
)
argparser.add_argument('-T', '--tmpdb', action='store_true',
help='the file to import is a temporary SQLite database created in the previous run'
)
argparser.add_argument('-u', '--uncompressed', action='store_true',
help='the file is an uncompressed OSM file (not BZ2 compressed)'
)
argparser.add_argument('-e', '--clip-extent', action='store_true',
help='import only features overlapping the analysis extent'
)
argparser.add_argument('-r', '--target-srid', metavar='srid',
help='SRID to be used in the imported tables (default: use extent)', type=int, default=None
)
argparser.add_argument('-o', '--overwrite', action='store_true',
help='overwrite existing table'
)
argparser.add_argument('osmfile', help='path to OSM file')
if __name__ == '__main__':
args = argparser.parse_args()
rum.input.OSMImporter.fromConfig(
args.dbconf, args.transform_conf, args.schema
).run(
path=args.osmfile,
targetSRID=args.target_srid,
clipExtent=args.clip_extent,
overwrite=args.overwrite,
isTmpDB=args.tmpdb,
isBZ2=(not args.uncompressed),
)