topo_map_processor 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- topo_map_processor/__init__.py +1844 -0
- topo_map_processor/_version.py +21 -0
- topo_map_processor/tools/__init__.py +0 -0
- topo_map_processor/tools/collect_bounds.py +23 -0
- topo_map_processor/tools/partition.py +361 -0
- topo_map_processor/tools/retile.py +311 -0
- topo_map_processor/tools/tile.py +86 -0
- topo_map_processor/tools/tile_sources.py +170 -0
- topo_map_processor/tools/update_bounds.py +53 -0
- topo_map_processor-0.1.3.dist-info/METADATA +187 -0
- topo_map_processor-0.1.3.dist-info/RECORD +14 -0
- topo_map_processor-0.1.3.dist-info/WHEEL +4 -0
- topo_map_processor-0.1.3.dist-info/entry_points.txt +6 -0
- topo_map_processor-0.1.3.dist-info/licenses/LICENSE +24 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: topo_map_processor
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Library for processing topographic maps
|
|
5
|
+
Project-URL: homepage, https://github.com/ramSeraph/topo_map_processor
|
|
6
|
+
Project-URL: repository, https://github.com/ramSeraph/topo_map_processor.git
|
|
7
|
+
Author-email: Sreeram Kandimalla <kandimalla.sreeram@gmail.com>
|
|
8
|
+
License: This is free and unencumbered software released into the public domain.
|
|
9
|
+
|
|
10
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
11
|
+
distribute this software, either in source code form or as a compiled
|
|
12
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
13
|
+
means.
|
|
14
|
+
|
|
15
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
16
|
+
of this software dedicate any and all copyright interest in the
|
|
17
|
+
software to the public domain. We make this dedication for the benefit
|
|
18
|
+
of the public at large and to the detriment of our heirs and
|
|
19
|
+
successors. We intend this dedication to be an overt act of
|
|
20
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
21
|
+
software under copyright law.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
24
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
25
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
26
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
27
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
28
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
29
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
30
|
+
|
|
31
|
+
For more information, please refer to <https://unlicense.org>
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Requires-Python: >=3.12
|
|
34
|
+
Requires-Dist: easyocr>=1.7.2
|
|
35
|
+
Requires-Dist: imgcat>=0.6.0
|
|
36
|
+
Requires-Dist: mercantile>=1.2.1
|
|
37
|
+
Requires-Dist: numpy>=2.3.1
|
|
38
|
+
Requires-Dist: opencv-python-headless>=4.11.0.86
|
|
39
|
+
Requires-Dist: pillow>=11.3.0
|
|
40
|
+
Requires-Dist: pmtiles>=3.4.1
|
|
41
|
+
Requires-Dist: pyproj>=3.7.1
|
|
42
|
+
Requires-Dist: pytesseract>=0.3.13
|
|
43
|
+
Requires-Dist: rasterio>=1.4.3
|
|
44
|
+
Requires-Dist: shapely>=2.1.1
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# Topo Map Processor
|
|
48
|
+
|
|
49
|
+
A Python utility for processing topographic maps.
|
|
50
|
+
|
|
51
|
+
## Description
|
|
52
|
+
|
|
53
|
+
This project provides a collection of command-line tools and a Python library to process, analyze, and manipulate topographic map data, specifically for creating web-mappable tiles from GeoTIFF files. The tools allow you to create tiles, partition large tile sets, and update existing tile sets efficiently.
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
To install the necessary dependencies, it is recommended to use a virtual environment.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
python -m venv .venv
|
|
61
|
+
source .venv/bin/activate
|
|
62
|
+
pip install -e .
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
This project can be used as a library but also provides as a set of command-line tools to help with managing the datasets, tiling and creating `pmtiles` files.
|
|
68
|
+
|
|
69
|
+
### Library Usage
|
|
70
|
+
|
|
71
|
+
The `TopoMapProcessor` class provides a framework for processing individual map sheets. To use it, you need to create a subclass and implement the required methods.
|
|
72
|
+
|
|
73
|
+
Here's an example of how to use the `TopoMapProcessor` class, based on the provided `parse_jica.py` script:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from topo_map_processor import TopoMapProcessor, LineRemovalParams
|
|
77
|
+
|
|
78
|
+
class SampleProcessor(TopoMapProcessor):
|
|
79
|
+
|
|
80
|
+
def __init__(self, filepath, extra, index_map):
|
|
81
|
+
super().__init__(filepath, extra, index_map)
|
|
82
|
+
# ... (additional initialization)
|
|
83
|
+
|
|
84
|
+
def get_inter_dir(self):
|
|
85
|
+
return Path('data/inter')
|
|
86
|
+
|
|
87
|
+
def get_gtiff_dir(self):
|
|
88
|
+
return Path('export/gtiffs')
|
|
89
|
+
|
|
90
|
+
def get_bounds_dir(self):
|
|
91
|
+
return Path('export/bounds')
|
|
92
|
+
|
|
93
|
+
def get_crs_proj(self):
|
|
94
|
+
return '+proj=tmerc +lat_0=0 +lon_0=84 +k=0.9999 +x_0=500000 +y_0=0 +units=m +ellps=evrst30 +towgs84=293.17,726.18,245.36,0,0,0,0 +no_defs'
|
|
95
|
+
|
|
96
|
+
def get_scale(self):
|
|
97
|
+
return 25000
|
|
98
|
+
|
|
99
|
+
def get_intersection_point(self, img, direction, anchor_angle):
|
|
100
|
+
# ... (implementation for finding intersection points which are the corners of the mapframe)
|
|
101
|
+
# you are expected to pick from the various locate intersection points implementations in the library or write your own
|
|
102
|
+
|
|
103
|
+
def locate_grid_lines(self):
|
|
104
|
+
# ... (implementation for locating grid lines so as to remove them)
|
|
105
|
+
# you are expected to pick from the various locate grid lines implementations in the library or write your own
|
|
106
|
+
|
|
107
|
+
# Example of how to run the processor
|
|
108
|
+
def process_files():
|
|
109
|
+
# ... (load image files and special cases)
|
|
110
|
+
for filepath in image_files:
|
|
111
|
+
extra = special_cases.get(filepath.name, {})
|
|
112
|
+
index_map = get_index_map_jica()
|
|
113
|
+
processor = SampleProcessor(filepath, extra, index_map)
|
|
114
|
+
processor.process()
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The library is configurable and most parameters can be overriden at a per sheet level using the `extra` dictionary.
|
|
118
|
+
|
|
119
|
+
The `index_map` is used to map specific file names to their corresponding metadata, which can be useful for processing specific datasets. In particular the index_map is expected to contain the geojson geometry of the map sheet in the `geometry` key, which is used to create the bounds file and georeference the sheet. The geometry is expected to be in counter clockwise order startiung at the top left corner of the map sheet.
|
|
120
|
+
|
|
121
|
+
The end result is a Cloud optimized GeoTIFF file, a bounds file in GeoJSON format from which the tiles can be generated, using the `tile` command-line tool, and a set of tiles in the specified directory.
|
|
122
|
+
|
|
123
|
+
I would recommend looking at the [nepal_survey_maps](https://github.com/ramSeraph/nepal_survey_maps) repository for a sample implementation
|
|
124
|
+
|
|
125
|
+
### Command-Line Tools
|
|
126
|
+
|
|
127
|
+
This project provides several command-line tools to work with topographic maps.
|
|
128
|
+
|
|
129
|
+
#### `tile`
|
|
130
|
+
|
|
131
|
+
Creates tiles from a directory of GeoTIFF files.
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
tile --tiles-dir <tiles-dir> --tiffs-dir <tiffs-dir> --max-zoom <max-zoom> [--min-zoom <min-zoom>]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
- `<tiles-dir>`: Directory to store the output tiles.
|
|
138
|
+
- `<tiffs-dir>`: Directory containing the input GeoTIFF files.
|
|
139
|
+
- `<max-zoom>`: Maximum zoom level for tiling.
|
|
140
|
+
- `<min-zoom>`: Minimum zoom level for tiling (default: 0).
|
|
141
|
+
|
|
142
|
+
#### `partition`
|
|
143
|
+
|
|
144
|
+
Partitions a large set of tiles into smaller PMTiles files, which is useful for managing large datasets.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
partition --to-pmtiles-prefix <prefix> --from-tiles-dir <dir> --name <name> --description <desc> --max-zoom <max-zoom> [--from-pmtiles-prefix <prefix>] [--only-disk] [--min-zoom <min-zoom>] (--attribution <attr> | --attribution-file <file>)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### `retile`
|
|
151
|
+
|
|
152
|
+
Retiles a specific list of sheets (GeoTIFFs) and updates the corresponding tiles.
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
retile --retile-list-file <file> --bounds-file <file> --max-zoom <max-zoom> --tiles-dir <dir> --tiffs-dir <dir> [--min-zoom <min-zoom>] [--from-pmtiles-prefix <prefix>]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### `collect-bounds`
|
|
159
|
+
|
|
160
|
+
Collects individual GeoJSONL bound files into a single GeoJSON FeatureCollection.
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
collect-bounds <bounds-dir> <output-file>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
- `<bounds-dir>`: Directory containing `.geojsonl` files.
|
|
167
|
+
- `<output-file>`: The output GeoJSON file.
|
|
168
|
+
|
|
169
|
+
#### `update-bounds`
|
|
170
|
+
|
|
171
|
+
Updates a GeoJSON bounds file with new information from a directory of individual bounds files.
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
update-bounds <bounds-file> <bounds-dir> <retile-list-file>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
- `<bounds-file>`: The GeoJSON file to update.
|
|
178
|
+
- `<bounds-dir>`: Directory with the new `.geojsonl` files.
|
|
179
|
+
- `<retile-list-file>`: A file containing the list of sheets that have been updated.
|
|
180
|
+
|
|
181
|
+
## Contributing
|
|
182
|
+
|
|
183
|
+
Contributions are welcome! Please feel free to submit a pull request.
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
This project is under UNLICENSE
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
topo_map_processor/__init__.py,sha256=PrXcYA6epqwaibcNTWZJNtuVGqkYCBHbgRybkowoZzQ,68524
|
|
2
|
+
topo_map_processor/_version.py,sha256=NIzzV8ZM0W-CSLuEs1weG4zPrn_-8yr1AwwI1iuS6yo,511
|
|
3
|
+
topo_map_processor/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
topo_map_processor/tools/collect_bounds.py,sha256=9Fsf9177PrhiVGx46MBUSIi6SzBf6ZSNjEBKFVTS9FQ,534
|
|
5
|
+
topo_map_processor/tools/partition.py,sha256=AGMz07R0ZnuZBB9edXPAOJd168wdOVK_xm2tSMW4tK8,11842
|
|
6
|
+
topo_map_processor/tools/retile.py,sha256=HWCt1A9sKWglionqhU8c3QfFhbyVS1mgKCYdYa2PRFk,10328
|
|
7
|
+
topo_map_processor/tools/tile.py,sha256=Qb2RJhlgKARfodGdMyLc9Tzf2XUnTXwNGZ1cqrR4L5E,2770
|
|
8
|
+
topo_map_processor/tools/tile_sources.py,sha256=uvAA42xdPag2uLzrfTY_wzSSrjfrQdxOKsdTsci9rEo,5053
|
|
9
|
+
topo_map_processor/tools/update_bounds.py,sha256=mX9tPUirC2eQrBFmmXuLK8XmJlsjG3XFvV2Br8Xf_78,1842
|
|
10
|
+
topo_map_processor-0.1.3.dist-info/METADATA,sha256=XRHH_Klwoufpd1XjKyP6zLBs6ZxTAmVP8jjUM6yOVaI,7614
|
|
11
|
+
topo_map_processor-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
12
|
+
topo_map_processor-0.1.3.dist-info/entry_points.txt,sha256=f1Q_LFxFrleYthKgws_z34WoYp4grFB1yUUgxxzGX9k,275
|
|
13
|
+
topo_map_processor-0.1.3.dist-info/licenses/LICENSE,sha256=awOCsWJ58m_2kBQwBUGWejVqZm6wuRtCL2hi9rfa0X4,1211
|
|
14
|
+
topo_map_processor-0.1.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
collect-bounds = topo_map_processor.tools.collect_bounds:cli
|
|
3
|
+
partition = topo_map_processor.tools.partition:cli
|
|
4
|
+
retile = topo_map_processor.tools.retile:cli
|
|
5
|
+
tile = topo_map_processor.tools.tile:cli
|
|
6
|
+
update-bounds = topo_map_processor.tools.update_bounds:cli
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org>
|