bcdata 0.14.0__tar.gz → 0.16.0__tar.gz
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.
- bcdata-0.16.0/LICENSE.txt +201 -0
- {bcdata-0.14.0/src/bcdata.egg-info → bcdata-0.16.0}/PKG-INFO +29 -84
- {bcdata-0.14.0 → bcdata-0.16.0}/README.md +25 -81
- {bcdata-0.14.0 → bcdata-0.16.0}/pyproject.toml +1 -1
- {bcdata-0.14.0 → bcdata-0.16.0}/src/bcdata/__init__.py +1 -2
- {bcdata-0.14.0 → bcdata-0.16.0}/src/bcdata/bc2pg.py +2 -3
- {bcdata-0.14.0 → bcdata-0.16.0}/src/bcdata/cli.py +0 -64
- {bcdata-0.14.0 → bcdata-0.16.0}/src/bcdata/wfs.py +3 -7
- {bcdata-0.14.0 → bcdata-0.16.0/src/bcdata.egg-info}/PKG-INFO +29 -84
- {bcdata-0.14.0 → bcdata-0.16.0}/src/bcdata.egg-info/SOURCES.txt +0 -2
- {bcdata-0.14.0 → bcdata-0.16.0}/tests/test_bcdc.py +2 -2
- {bcdata-0.14.0 → bcdata-0.16.0}/tests/test_wfs.py +8 -8
- bcdata-0.14.0/LICENSE.txt +0 -22
- bcdata-0.14.0/src/bcdata/wcs.py +0 -130
- bcdata-0.14.0/tests/test_wcs.py +0 -67
- {bcdata-0.14.0 → bcdata-0.16.0}/setup.cfg +0 -0
- {bcdata-0.14.0 → bcdata-0.16.0}/src/bcdata/bcdc.py +0 -0
- {bcdata-0.14.0 → bcdata-0.16.0}/src/bcdata/database.py +0 -0
- {bcdata-0.14.0 → bcdata-0.16.0}/src/bcdata.egg-info/dependency_links.txt +0 -0
- {bcdata-0.14.0 → bcdata-0.16.0}/src/bcdata.egg-info/entry_points.txt +0 -0
- {bcdata-0.14.0 → bcdata-0.16.0}/src/bcdata.egg-info/requires.txt +0 -0
- {bcdata-0.14.0 → bcdata-0.16.0}/src/bcdata.egg-info/top_level.txt +0 -0
- {bcdata-0.14.0 → bcdata-0.16.0}/tests/test_bc2pg.py +0 -0
- {bcdata-0.14.0 → bcdata-0.16.0}/tests/test_cli.py +0 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Province of British Columbia
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: bcdata
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.16.0
|
|
4
4
|
Summary: Download open data, monitor and report on changes
|
|
5
5
|
Author-email: Simon Norris <snorris@hillcrestgeo.ca>
|
|
6
6
|
Project-URL: Homepage, https://github.com/smnorris/bcdata
|
|
7
7
|
Project-URL: Issues, https://github.com/smnorris/bcdata
|
|
8
|
-
Classifier: Development Status ::
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.9
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.10
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
@@ -29,45 +29,38 @@ Provides-Extra: test
|
|
|
29
29
|
Requires-Dist: pytest; extra == "test"
|
|
30
30
|
Requires-Dist: pre-commit; extra == "test"
|
|
31
31
|
Requires-Dist: requests-mock; extra == "test"
|
|
32
|
+
Dynamic: license-file
|
|
32
33
|
|
|
33
|
-
# bcdata
|
|
34
|
+
# bcdata
|
|
34
35
|
|
|
35
36
|
[](https://github.com/smnorris/bcdata/actions?query=workflow%3Atests)
|
|
36
37
|
[](https://pypi.python.org/pypi/bcdata/)
|
|
37
38
|
|
|
38
|
-
Python and command line tools for quick access to DataBC geo-data available via WFS
|
|
39
|
+
Python and command line tools for quick access to DataBC geo-data available via WFS.
|
|
39
40
|
|
|
40
41
|
There is a [wealth of British Columbia geographic information available as open
|
|
41
42
|
data](https://catalogue.data.gov.bc.ca/dataset?download_audience=Public),
|
|
42
|
-
but
|
|
43
|
+
but most sources are available only via WFS - and the syntax to download WFS data via `ogr2ogr` and/or `curl/wget` can be awkward.
|
|
43
44
|
|
|
44
|
-
This tool attempts to simplify downloads of BC geographic data and smoothly integrate with PostGIS and Python GIS tools like `geopandas`, `fiona` and `rasterio`.
|
|
45
|
+
This tool attempts to simplify downloads of BC geographic data and smoothly integrate with PostGIS and Python GIS tools like `geopandas`, `fiona` and `rasterio`. The tool only accesses geographic data [avialable via WFS](https://bcgov.github.io/data-publication/pages/tips_tricks_webservices.html) - for other BC open data, download the files directly with `requests` / `curl` / `ogr2ogr` / etc (or the [bcdata R package](https://github.com/bcgov/bcdata)).
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
If downloads are failing, consult the [BCGov Data Systems and Services uptime monitor](https://uptime.com/statuspage/bcgov-dss) - this tool depends on BC Open Geospatial Web Services API at [openmaps.gov.bc.ca](https://openmaps.gov.bc.ca/geo/pub/ows?service=WFS&request=Getcapabilities) and the [BC Data Catalogue API](https://catalogue.data.gov.bc.ca/dataset/bc-data-catalogue-api).
|
|
47
48
|
|
|
48
49
|
**Disclaimer**
|
|
49
|
-
*
|
|
50
|
+
*Data are generally licensed as [OGL-BC](http://www2.gov.bc.ca/gov/content/governments/about-the-bc-government/databc/open-data/open-government-license-bc), but it is the user's responsibility to check the licensing for any downloads.*
|
|
50
51
|
|
|
51
|
-
##
|
|
52
|
+
## Installation and dependencies
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
Install with `pip`:
|
|
54
55
|
|
|
55
56
|
$ pip install bcdata
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
$ conda create --name bcdataenv
|
|
60
|
-
$ conda activate bcdataenv
|
|
61
|
-
$ conda config --env --add channels conda-forge
|
|
62
|
-
$ conda config --env --set channel_priority strict
|
|
63
|
-
$ conda install python=3 geopandas
|
|
64
|
-
$ conda install rasterio
|
|
65
|
-
$ pip install bcdata
|
|
58
|
+
Note that `bcdata` requires `gdal` to already be installed to a known location.
|
|
59
|
+
If this is not the case on your system, the [GeoPandas guide](https://geopandas.org/en/stable/getting_started/install.html) is useful for setting up a stand alone environment with `conda`.
|
|
66
60
|
|
|
61
|
+
## Configuration
|
|
67
62
|
|
|
68
|
-
###
|
|
69
|
-
|
|
70
|
-
#### Default PostgreSQL database
|
|
63
|
+
### Default PostgreSQL database
|
|
71
64
|
|
|
72
65
|
The default target database connection (used by `bc2pg`) can be set via the `DATABASE_URL` environment variable (the password parameter should not be required if using a [.pgpass file](https://www.postgresql.org/docs/current/libpq-pgpass.html))
|
|
73
66
|
|
|
@@ -76,7 +69,7 @@ Linux/Mac: `export DATABASE_URL=postgresql://{username}:{password}@{hostname}:{p
|
|
|
76
69
|
Windows: `SET DATABASE_URL=postgresql://{username}:{password}@{hostname}:{port}/{database}`
|
|
77
70
|
|
|
78
71
|
|
|
79
|
-
|
|
72
|
+
### Layer list / layer schema cache
|
|
80
73
|
|
|
81
74
|
To reduce the volume of requests, information about data requested is cached locally.
|
|
82
75
|
Schemas of individual layers that have previously been requested are cached with the cache file name matching the object/table name.
|
|
@@ -123,7 +116,6 @@ AERODROME_STATUS AIRCRAFT_ACCESS_IND AIRPORT_NAME
|
|
|
123
116
|
```
|
|
124
117
|
|
|
125
118
|
### CLI
|
|
126
|
-
|
|
127
119
|
Commands available via the bcdata command line interface are documented with the --help option
|
|
128
120
|
|
|
129
121
|
```
|
|
@@ -139,7 +131,6 @@ Options:
|
|
|
139
131
|
Commands:
|
|
140
132
|
bc2pg Load a DataBC WFS layer to a postgres db
|
|
141
133
|
cat Write DataBC features to stdout as GeoJSON feature objects.
|
|
142
|
-
dem Dump BC DEM to TIFF
|
|
143
134
|
dump Write DataBC features to stdout as GeoJSON feature collection.
|
|
144
135
|
info Print basic metadata about a DataBC WFS layer as JSON.
|
|
145
136
|
list List DataBC layers available via WFS
|
|
@@ -199,7 +190,6 @@ Options:
|
|
|
199
190
|
CRS of provided bounds
|
|
200
191
|
--indent INTEGER Indentation level for JSON output
|
|
201
192
|
--compact / --not-compact Use compact separators (',', ':').
|
|
202
|
-
--dst-crs, --dst_crs TEXT Destination CRS
|
|
203
193
|
-s, --sortby TEXT Name of sort field
|
|
204
194
|
-l, --lowercase Write column/properties names as lowercase
|
|
205
195
|
-m, --promote-to-multi Promote features to multipart
|
|
@@ -208,30 +198,6 @@ Options:
|
|
|
208
198
|
--help Show this message and exit.
|
|
209
199
|
```
|
|
210
200
|
|
|
211
|
-
#### dem
|
|
212
|
-
|
|
213
|
-
```
|
|
214
|
-
$ bcdata dem --help
|
|
215
|
-
|
|
216
|
-
Usage: bcdata dem [OPTIONS]
|
|
217
|
-
|
|
218
|
-
Dump BC DEM to TIFF
|
|
219
|
-
|
|
220
|
-
Options:
|
|
221
|
-
-o, --out_file TEXT Output file
|
|
222
|
-
--bounds TEXT Bounds: "left bottom right top" or "[left,
|
|
223
|
-
bottom, right, top]". Coordinates are BC
|
|
224
|
-
Albers (default) or --bounds_crs [required]
|
|
225
|
-
--dst-crs TEXT CRS of output file
|
|
226
|
-
--bounds-crs TEXT CRS of provided bounds
|
|
227
|
-
-r, --resolution INTEGER
|
|
228
|
-
-a, --align Align provided bounds to provincial standard
|
|
229
|
-
-i, --interpolation [nearest|bilinear|bicubic]
|
|
230
|
-
-v, --verbose Increase verbosity.
|
|
231
|
-
-q, --quiet Decrease verbosity.
|
|
232
|
-
--help Show this message and exit.
|
|
233
|
-
```
|
|
234
|
-
|
|
235
201
|
#### dump
|
|
236
202
|
|
|
237
203
|
```
|
|
@@ -245,7 +211,7 @@ Usage: bcdata dump [OPTIONS] DATASET
|
|
|
245
211
|
$ bcdata dump bc-airports --query "AIRPORT_NAME='Victoria Harbour (Shoal Point) Heliport'"
|
|
246
212
|
$ bcdata dump bc-airports --bounds xmin ymin xmax ymax
|
|
247
213
|
|
|
248
|
-
It can also be combined to read bounds of a feature dataset using Fiona:
|
|
214
|
+
It can also be combined to read bounds of a feature dataset using Fiona:
|
|
249
215
|
$ bcdata dump bc-airports --bounds $(fio info aoi.shp --bounds)
|
|
250
216
|
|
|
251
217
|
Options:
|
|
@@ -351,29 +317,19 @@ The JSON output can be manipulated with [jq](https://stedolan.github.io/jq/). Fo
|
|
|
351
317
|
etc...
|
|
352
318
|
}
|
|
353
319
|
|
|
354
|
-
Dump data
|
|
320
|
+
Dump data as supplied by server (BC Albers):
|
|
355
321
|
|
|
356
322
|
$ bcdata dump bc-airports > bc-airports.geojson
|
|
357
323
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
$ bcdata dump \
|
|
361
|
-
WHSE_IMAGERY_AND_BASE_MAPS.GSR_AIRPORTS_SVW \
|
|
362
|
-
--query "AIRPORT_NAME='Terrace (Northwest Regional) Airport'" \
|
|
363
|
-
| geojsonio
|
|
324
|
+
Dump data to geojson that conforms to [RFC7946](https://tools.ietf.org/html/rfc7946#section-4)):
|
|
364
325
|
|
|
365
|
-
|
|
326
|
+
$ bcdata dump bc-airports | \
|
|
327
|
+
ogr2ogr -f GeoJSON -lco RFC7946=YES /vsistdout/ /vsistdin/ > bc-airports-4326.geojson
|
|
366
328
|
|
|
367
|
-
|
|
368
|
-
| fio collect \
|
|
369
|
-
| fio load -f GPKG --dst-crs EPSG:3005 airports.gpkg
|
|
329
|
+
Dump to Parquet on S3:
|
|
370
330
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
Load to parquet on s3:
|
|
374
|
-
|
|
375
|
-
$ bcdata dump bc-airports \
|
|
376
|
-
| ogr2ogr -f Parquet /vsis3/$BUCKET/airports.parquet -s_srs EPSG:4326 -t_srs EPSG:3005 /vsistdin/
|
|
331
|
+
$ bcdata dump bc-airports | \
|
|
332
|
+
ogr2ogr -f Parquet /vsis3/$BUCKET/airports.parquet /vsistdin/
|
|
377
333
|
|
|
378
334
|
Load data to postgres and run a spatial query:
|
|
379
335
|
|
|
@@ -398,19 +354,8 @@ Load data to postgres and run a spatial query:
|
|
|
398
354
|
|
|
399
355
|
## Projections / CRS
|
|
400
356
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
`bcdata dump` returns GeoJSON in WGS84 (`EPSG:4326`).
|
|
404
|
-
|
|
405
|
-
`bcdata cat` provides the `--dst-crs` option, use any CRS the WFS server supports.
|
|
406
|
-
|
|
407
|
-
`bcdata bc2pg` loads data to PostgreSQL in BC Albers (`EPSG:3005`).
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
**Python module**
|
|
411
|
-
|
|
412
|
-
`bcdata.get_data()` defaults to `EPSG:4236` but any CRS can be specified (that the server will accept).
|
|
413
|
-
|
|
357
|
+
All data are as supplied from the server by default: BC Albers / `EPSG:3005`.
|
|
358
|
+
Use some other tool to reproject the data as required.
|
|
414
359
|
|
|
415
360
|
## Development and testing
|
|
416
361
|
|
|
@@ -421,8 +366,8 @@ Load data to postgres and run a spatial query:
|
|
|
421
366
|
|
|
422
367
|
Create virtualenv and install `bcdata` in development mode:
|
|
423
368
|
|
|
424
|
-
$ git clone git@github.com:
|
|
425
|
-
$ cd
|
|
369
|
+
$ git clone git@github.com:bcgov/bcdata_py.git
|
|
370
|
+
$ cd bcdata_py
|
|
426
371
|
$ python -m venv .venv
|
|
427
372
|
$ source .venv/bin/activate
|
|
428
373
|
(.venv)$ pip install -e .[test]
|
|
@@ -1,41 +1,33 @@
|
|
|
1
|
-
# bcdata
|
|
1
|
+
# bcdata
|
|
2
2
|
|
|
3
3
|
[](https://github.com/smnorris/bcdata/actions?query=workflow%3Atests)
|
|
4
4
|
[](https://pypi.python.org/pypi/bcdata/)
|
|
5
5
|
|
|
6
|
-
Python and command line tools for quick access to DataBC geo-data available via WFS
|
|
6
|
+
Python and command line tools for quick access to DataBC geo-data available via WFS.
|
|
7
7
|
|
|
8
8
|
There is a [wealth of British Columbia geographic information available as open
|
|
9
9
|
data](https://catalogue.data.gov.bc.ca/dataset?download_audience=Public),
|
|
10
|
-
but
|
|
10
|
+
but most sources are available only via WFS - and the syntax to download WFS data via `ogr2ogr` and/or `curl/wget` can be awkward.
|
|
11
11
|
|
|
12
|
-
This tool attempts to simplify downloads of BC geographic data and smoothly integrate with PostGIS and Python GIS tools like `geopandas`, `fiona` and `rasterio`.
|
|
12
|
+
This tool attempts to simplify downloads of BC geographic data and smoothly integrate with PostGIS and Python GIS tools like `geopandas`, `fiona` and `rasterio`. The tool only accesses geographic data [avialable via WFS](https://bcgov.github.io/data-publication/pages/tips_tricks_webservices.html) - for other BC open data, download the files directly with `requests` / `curl` / `ogr2ogr` / etc (or the [bcdata R package](https://github.com/bcgov/bcdata)).
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
If downloads are failing, consult the [BCGov Data Systems and Services uptime monitor](https://uptime.com/statuspage/bcgov-dss) - this tool depends on BC Open Geospatial Web Services API at [openmaps.gov.bc.ca](https://openmaps.gov.bc.ca/geo/pub/ows?service=WFS&request=Getcapabilities) and the [BC Data Catalogue API](https://catalogue.data.gov.bc.ca/dataset/bc-data-catalogue-api).
|
|
15
15
|
|
|
16
16
|
**Disclaimer**
|
|
17
|
-
*
|
|
17
|
+
*Data are generally licensed as [OGL-BC](http://www2.gov.bc.ca/gov/content/governments/about-the-bc-government/databc/open-data/open-government-license-bc), but it is the user's responsibility to check the licensing for any downloads.*
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Installation and dependencies
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Install with `pip`:
|
|
22
22
|
|
|
23
23
|
$ pip install bcdata
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
$ conda create --name bcdataenv
|
|
28
|
-
$ conda activate bcdataenv
|
|
29
|
-
$ conda config --env --add channels conda-forge
|
|
30
|
-
$ conda config --env --set channel_priority strict
|
|
31
|
-
$ conda install python=3 geopandas
|
|
32
|
-
$ conda install rasterio
|
|
33
|
-
$ pip install bcdata
|
|
25
|
+
Note that `bcdata` requires `gdal` to already be installed to a known location.
|
|
26
|
+
If this is not the case on your system, the [GeoPandas guide](https://geopandas.org/en/stable/getting_started/install.html) is useful for setting up a stand alone environment with `conda`.
|
|
34
27
|
|
|
28
|
+
## Configuration
|
|
35
29
|
|
|
36
|
-
###
|
|
37
|
-
|
|
38
|
-
#### Default PostgreSQL database
|
|
30
|
+
### Default PostgreSQL database
|
|
39
31
|
|
|
40
32
|
The default target database connection (used by `bc2pg`) can be set via the `DATABASE_URL` environment variable (the password parameter should not be required if using a [.pgpass file](https://www.postgresql.org/docs/current/libpq-pgpass.html))
|
|
41
33
|
|
|
@@ -44,7 +36,7 @@ Linux/Mac: `export DATABASE_URL=postgresql://{username}:{password}@{hostname}:{p
|
|
|
44
36
|
Windows: `SET DATABASE_URL=postgresql://{username}:{password}@{hostname}:{port}/{database}`
|
|
45
37
|
|
|
46
38
|
|
|
47
|
-
|
|
39
|
+
### Layer list / layer schema cache
|
|
48
40
|
|
|
49
41
|
To reduce the volume of requests, information about data requested is cached locally.
|
|
50
42
|
Schemas of individual layers that have previously been requested are cached with the cache file name matching the object/table name.
|
|
@@ -91,7 +83,6 @@ AERODROME_STATUS AIRCRAFT_ACCESS_IND AIRPORT_NAME
|
|
|
91
83
|
```
|
|
92
84
|
|
|
93
85
|
### CLI
|
|
94
|
-
|
|
95
86
|
Commands available via the bcdata command line interface are documented with the --help option
|
|
96
87
|
|
|
97
88
|
```
|
|
@@ -107,7 +98,6 @@ Options:
|
|
|
107
98
|
Commands:
|
|
108
99
|
bc2pg Load a DataBC WFS layer to a postgres db
|
|
109
100
|
cat Write DataBC features to stdout as GeoJSON feature objects.
|
|
110
|
-
dem Dump BC DEM to TIFF
|
|
111
101
|
dump Write DataBC features to stdout as GeoJSON feature collection.
|
|
112
102
|
info Print basic metadata about a DataBC WFS layer as JSON.
|
|
113
103
|
list List DataBC layers available via WFS
|
|
@@ -167,7 +157,6 @@ Options:
|
|
|
167
157
|
CRS of provided bounds
|
|
168
158
|
--indent INTEGER Indentation level for JSON output
|
|
169
159
|
--compact / --not-compact Use compact separators (',', ':').
|
|
170
|
-
--dst-crs, --dst_crs TEXT Destination CRS
|
|
171
160
|
-s, --sortby TEXT Name of sort field
|
|
172
161
|
-l, --lowercase Write column/properties names as lowercase
|
|
173
162
|
-m, --promote-to-multi Promote features to multipart
|
|
@@ -176,30 +165,6 @@ Options:
|
|
|
176
165
|
--help Show this message and exit.
|
|
177
166
|
```
|
|
178
167
|
|
|
179
|
-
#### dem
|
|
180
|
-
|
|
181
|
-
```
|
|
182
|
-
$ bcdata dem --help
|
|
183
|
-
|
|
184
|
-
Usage: bcdata dem [OPTIONS]
|
|
185
|
-
|
|
186
|
-
Dump BC DEM to TIFF
|
|
187
|
-
|
|
188
|
-
Options:
|
|
189
|
-
-o, --out_file TEXT Output file
|
|
190
|
-
--bounds TEXT Bounds: "left bottom right top" or "[left,
|
|
191
|
-
bottom, right, top]". Coordinates are BC
|
|
192
|
-
Albers (default) or --bounds_crs [required]
|
|
193
|
-
--dst-crs TEXT CRS of output file
|
|
194
|
-
--bounds-crs TEXT CRS of provided bounds
|
|
195
|
-
-r, --resolution INTEGER
|
|
196
|
-
-a, --align Align provided bounds to provincial standard
|
|
197
|
-
-i, --interpolation [nearest|bilinear|bicubic]
|
|
198
|
-
-v, --verbose Increase verbosity.
|
|
199
|
-
-q, --quiet Decrease verbosity.
|
|
200
|
-
--help Show this message and exit.
|
|
201
|
-
```
|
|
202
|
-
|
|
203
168
|
#### dump
|
|
204
169
|
|
|
205
170
|
```
|
|
@@ -213,7 +178,7 @@ Usage: bcdata dump [OPTIONS] DATASET
|
|
|
213
178
|
$ bcdata dump bc-airports --query "AIRPORT_NAME='Victoria Harbour (Shoal Point) Heliport'"
|
|
214
179
|
$ bcdata dump bc-airports --bounds xmin ymin xmax ymax
|
|
215
180
|
|
|
216
|
-
It can also be combined to read bounds of a feature dataset using Fiona:
|
|
181
|
+
It can also be combined to read bounds of a feature dataset using Fiona:
|
|
217
182
|
$ bcdata dump bc-airports --bounds $(fio info aoi.shp --bounds)
|
|
218
183
|
|
|
219
184
|
Options:
|
|
@@ -319,29 +284,19 @@ The JSON output can be manipulated with [jq](https://stedolan.github.io/jq/). Fo
|
|
|
319
284
|
etc...
|
|
320
285
|
}
|
|
321
286
|
|
|
322
|
-
Dump data
|
|
287
|
+
Dump data as supplied by server (BC Albers):
|
|
323
288
|
|
|
324
289
|
$ bcdata dump bc-airports > bc-airports.geojson
|
|
325
290
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
$ bcdata dump \
|
|
329
|
-
WHSE_IMAGERY_AND_BASE_MAPS.GSR_AIRPORTS_SVW \
|
|
330
|
-
--query "AIRPORT_NAME='Terrace (Northwest Regional) Airport'" \
|
|
331
|
-
| geojsonio
|
|
291
|
+
Dump data to geojson that conforms to [RFC7946](https://tools.ietf.org/html/rfc7946#section-4)):
|
|
332
292
|
|
|
333
|
-
|
|
293
|
+
$ bcdata dump bc-airports | \
|
|
294
|
+
ogr2ogr -f GeoJSON -lco RFC7946=YES /vsistdout/ /vsistdin/ > bc-airports-4326.geojson
|
|
334
295
|
|
|
335
|
-
|
|
336
|
-
| fio collect \
|
|
337
|
-
| fio load -f GPKG --dst-crs EPSG:3005 airports.gpkg
|
|
296
|
+
Dump to Parquet on S3:
|
|
338
297
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
Load to parquet on s3:
|
|
342
|
-
|
|
343
|
-
$ bcdata dump bc-airports \
|
|
344
|
-
| ogr2ogr -f Parquet /vsis3/$BUCKET/airports.parquet -s_srs EPSG:4326 -t_srs EPSG:3005 /vsistdin/
|
|
298
|
+
$ bcdata dump bc-airports | \
|
|
299
|
+
ogr2ogr -f Parquet /vsis3/$BUCKET/airports.parquet /vsistdin/
|
|
345
300
|
|
|
346
301
|
Load data to postgres and run a spatial query:
|
|
347
302
|
|
|
@@ -366,19 +321,8 @@ Load data to postgres and run a spatial query:
|
|
|
366
321
|
|
|
367
322
|
## Projections / CRS
|
|
368
323
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
`bcdata dump` returns GeoJSON in WGS84 (`EPSG:4326`).
|
|
372
|
-
|
|
373
|
-
`bcdata cat` provides the `--dst-crs` option, use any CRS the WFS server supports.
|
|
374
|
-
|
|
375
|
-
`bcdata bc2pg` loads data to PostgreSQL in BC Albers (`EPSG:3005`).
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
**Python module**
|
|
379
|
-
|
|
380
|
-
`bcdata.get_data()` defaults to `EPSG:4236` but any CRS can be specified (that the server will accept).
|
|
381
|
-
|
|
324
|
+
All data are as supplied from the server by default: BC Albers / `EPSG:3005`.
|
|
325
|
+
Use some other tool to reproject the data as required.
|
|
382
326
|
|
|
383
327
|
## Development and testing
|
|
384
328
|
|
|
@@ -389,8 +333,8 @@ Load data to postgres and run a spatial query:
|
|
|
389
333
|
|
|
390
334
|
Create virtualenv and install `bcdata` in development mode:
|
|
391
335
|
|
|
392
|
-
$ git clone git@github.com:
|
|
393
|
-
$ cd
|
|
336
|
+
$ git clone git@github.com:bcgov/bcdata_py.git
|
|
337
|
+
$ cd bcdata_py
|
|
394
338
|
$ python -m venv .venv
|
|
395
339
|
$ source .venv/bin/activate
|
|
396
340
|
(.venv)$ pip install -e .[test]
|
|
@@ -13,7 +13,7 @@ authors = [
|
|
|
13
13
|
description = "Download open data, monitor and report on changes"
|
|
14
14
|
requires-python = ">=3.9"
|
|
15
15
|
classifiers = [
|
|
16
|
-
"Development Status ::
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
17
|
"Programming Language :: Python :: 3.9",
|
|
18
18
|
"Programming Language :: Python :: 3.10",
|
|
19
19
|
"Programming Language :: Python :: 3.11",
|
|
@@ -3,7 +3,6 @@ import requests
|
|
|
3
3
|
from .bc2pg import bc2pg as bc2pg
|
|
4
4
|
from .bcdc import get_table_definition as get_table_definition
|
|
5
5
|
from .bcdc import get_table_name as get_table_name
|
|
6
|
-
from .wcs import get_dem as get_dem
|
|
7
6
|
from .wfs import get_count as get_count
|
|
8
7
|
from .wfs import get_data as get_data
|
|
9
8
|
from .wfs import get_sortkey as get_sortkey
|
|
@@ -22,4 +21,4 @@ else:
|
|
|
22
21
|
raise Exception(f"Failed to download primary key database at {PRIMARY_KEY_DB_URL}")
|
|
23
22
|
primary_keys = {}
|
|
24
23
|
|
|
25
|
-
__version__ = "0.
|
|
24
|
+
__version__ = "0.16.0"
|