You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **Tip**: In most cases, it is recommended to install Raster Loader in a virtual environment. Use [venv](https://docs.python.org/3/library/venv.html) to create and manage your virtual environment.
32
+
33
+
The above will install the dependencies required to work with all cloud providers (BigQuery, Snowflake, Databricks). If you only want to work with one of them, you can install the dependencies for each separately:
34
+
35
+
```bash
36
+
pip install -U raster-loader[bigquery]
37
+
pip install -U raster-loader[snowflake]
38
+
pip install -U raster-loader[databricks]
39
+
```
40
+
41
+
For Databricks, you will also need to install the [databricks-connect](https://pypi.org/project/databricks-connect/) package corresponding to your Databricks Runtime Version. For example, if your cluster uses DBR 15.1, install:
42
+
43
+
```bash
44
+
pip install databricks-connect==15.1
45
+
```
46
+
47
+
You can find your cluster's DBR version in the Databricks UI under Compute > Your Cluster > Configuration > Databricks Runtime version.
48
+
Or you can run the following SQL query from your cluster:
49
+
50
+
```sql
51
+
SELECT current_version();
52
+
```
53
+
54
+
To verify the installation was successful, run:
55
+
56
+
```bash
57
+
carto info
32
58
```
33
59
60
+
This command will display system information including the installed Raster Loader version.
61
+
62
+
## Prerequisites
63
+
64
+
Before using Raster Loader with each platform, you need to have the following set up:
65
+
66
+
**BigQuery:**
67
+
- A [GCP project](https://cloud.google.com/resource-manager/docs/creating-managing-projects)
68
+
- A [BigQuery dataset](https://cloud.google.com/bigquery/docs/datasets-intro)
69
+
- The `GOOGLE_APPLICATION_CREDENTIALS` environment variable set to the path of a JSON file containing your BigQuery credentials. See the [GCP documentation](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-key) for more information.
70
+
71
+
**Snowflake:**
72
+
- A Snowflake account
73
+
- A Snowflake database
74
+
- A Snowflake schema
75
+
76
+
**Databricks:**
77
+
- A [Databricks server hostname](https://docs.databricks.com/aws/en/integrations/compute-details)
78
+
- A [Databricks cluster id](https://learn.microsoft.com/en-us/azure/databricks/workspace/workspace-details#cluster-url)
79
+
- A [Databricks token](https://docs.databricks.com/aws/en/dev-tools/auth/pat)
80
+
81
+
**Raster files**
82
+
83
+
The input raster must be a `GoogleMapsCompatible` raster. You can make your raster compatible by converting it with the following GDAL command:
Your raster file must be in a format that can be [read by GDAL](https://gdal.org/drivers/raster/index.html) and processed with [rasterio](https://rasterio.readthedocs.io/en/latest/).
90
+
34
91
## Usage
35
92
36
93
There are two ways you can use Raster Loader:
@@ -42,105 +99,164 @@ There are two ways you can use Raster Loader:
42
99
43
100
After installing Raster Loader, you can run the CLI by typing `carto` in your terminal.
44
101
45
-
Currently, Raster Loader supports uploading raster data to [BigQuery](https://cloud.google.com/bigquery).
46
-
Accessing BigQuery with Raster Loader requires the
47
-
`GOOGLE_APPLICATION_CREDENTIALS` environment variable to be set to the path of a JSON
48
-
file containing your BigQuery credentials. See the
Currently, Raster Loader allows you to upload a local raster file to BigQuery, Snowflake, or Databricks tables. You can also download and inspect raster files from these platforms.
53
103
54
-
#### Uploading to BigQuery
104
+
#### Uploading Raster Data
55
105
56
-
`carto bigquery upload` loads raster data from a local file to a BigQuery table.
57
-
At a minimum, the `carto bigquery upload` command requires a `file_path` to a local
58
-
raster file that can be [read by GDAL](https://gdal.org/drivers/raster/index.html) and processed with [rasterio](https://rasterio.readthedocs.io/en/latest/). It also requires
59
-
the `project` (the [GCP project name](https://cloud.google.com/resource-manager/docs/creating-managing-projects))
60
-
and `dataset` (the [BigQuery dataset name](https://cloud.google.com/bigquery/docs/datasets-intro))
61
-
parameters. There are also additional parameters, such as `table` ([BigQuery table
62
-
name](https://cloud.google.com/bigquery/docs/tables-intro)) and `overwrite` (to
63
-
overwrite existing data).
64
-
65
-
For example:
66
-
67
-
```bash
106
+
Examples for each platform:
68
107
108
+
**BigQuery:**
109
+
```bash
69
110
carto bigquery upload \
70
111
--file_path /path/to/my/raster/file.tif \
71
112
--project my-gcp-project \
72
113
--dataset my-bigquery-dataset \
73
114
--table my-bigquery-table \
74
115
--overwrite
116
+
```
75
117
118
+
**Snowflake:**
119
+
```bash
120
+
carto snowflake upload \
121
+
--file_path /path/to/my/raster/file.tif \
122
+
--database my-snowflake-database \
123
+
--schema my-snowflake-schema \
124
+
--table my-snowflake-table \
125
+
--account my-snowflake-account \
126
+
--username my-snowflake-user \
127
+
--password my-snowflake-password \
128
+
--overwrite
76
129
```
77
130
78
-
This command uploads the TIFF file from `/path/to/my/raster/file.tif` to a BigQuery
79
-
project named `my-gcp-project`, a dataset named `my-bigquery-dataset`, and a table
80
-
named `my-bigquery-table`. If the table already contains data, this data will be
81
-
overwritten because the `--overwrite` flag is set.
131
+
Note that authentication parameters are explicitly required since they are not set up in the environment.
82
132
83
-
#### Inspecting a raster file on BigQuery
133
+
**Databricks:**
134
+
```bash
135
+
carto databricks upload \
136
+
--file_path /path/to/my/raster/file.tif \
137
+
--catalog my-databricks-catalog \
138
+
--schema my-databricks-schema \
139
+
--table my-databricks-table \
140
+
--server-hostname my-databricks-server-hostname \
141
+
--cluster-id my-databricks-cluster-id \
142
+
--token my-databricks-token \
143
+
--overwrite
144
+
```
84
145
85
-
Use the `carto bigquery describe` command to retrieve information about a raster file
86
-
stored in a BigQuery table.
146
+
Note that authentication parameters are explicitly required since they are not set up in the environment.
- Specifying bands with `--band` and `--band_name`
150
+
- Enabling compression with `--compress` and `--compression-level`
151
+
- Chunking large uploads with `--chunk_size`
92
152
93
-
For example:
153
+
#### Inspecting Raster Data
94
154
95
-
```bash
155
+
To inspect a raster file stored in any platform, use the `describe` command:
156
+
157
+
**BigQuery:**
158
+
```bash
96
159
carto bigquery describe \
97
160
--project my-gcp-project \
98
161
--dataset my-bigquery-dataset \
99
162
--table my-bigquery-table
100
163
```
101
164
165
+
**Snowflake:**
166
+
```bash
167
+
carto snowflake describe \
168
+
--database my-snowflake-database \
169
+
--schema my-snowflake-schema \
170
+
--table my-snowflake-table \
171
+
--account my-snowflake-account \
172
+
--username my-snowflake-user \
173
+
--password my-snowflake-password
174
+
```
175
+
176
+
Note that authentication parameters are explicitly required since they are not set up in the environment.
177
+
178
+
**Databricks:**
179
+
```bash
180
+
carto databricks describe \
181
+
--catalog my-databricks-catalog \
182
+
--schema my-databricks-schema \
183
+
--table my-databricks-table \
184
+
--server-hostname my-databricks-server-hostname \
185
+
--cluster-id my-databricks-cluster-id \
186
+
--token my-databricks-token
187
+
```
188
+
189
+
Note that authentication parameters are explicitly required since they are not set up in the environment.
190
+
191
+
For a complete list of options and commands, run `carto --help` or see the [full documentation](https://raster-loader.readthedocs.io/en/latest/user_guide/cli.html).
192
+
102
193
### Using Raster Loader as a Python library
103
194
104
-
After installing Raster Loader, you can import the package into your Python project. For
105
-
example:
195
+
After installing Raster Loader, you can use it in your Python project.
196
+
197
+
First, import the corresponding connection class for your platform:
198
+
199
+
```python
200
+
# For BigQuery
201
+
from raster_loader import BigQueryConnection
202
+
203
+
# For Snowflake
204
+
from raster_loader import SnowflakeConnection
205
+
206
+
# For Databricks
207
+
from raster_loader import DatabricksConnection
208
+
```
209
+
210
+
Then, create a connection object with the appropriate parameters:
211
+
212
+
```python
213
+
# For BigQuery
214
+
connection = BigQueryConnection('my-project')
106
215
107
-
```python
108
-
from raster_loader import rasterio_to_bigquery, bigquery_to_records
Currently, Raster Loader supports uploading raster data to [BigQuery](https://cloud.google.com/bigquery). Accessing BigQuery with Raster Loader requires the
112
-
`GOOGLE_APPLICATION_CREDENTIALS` environment variable to be set to the path of a JSON
113
-
file containing your BigQuery credentials. See the
0 commit comments