Raster to DGGS
Raster to DGGS conversion functions.
This submodule provides functions to convert raster data to various discrete global grid systems (DGGS).
raster2olc_cli()
¶
Command line interface for raster to OLC conversion
Source code in vgrid/conversion/raster2dggs/raster2olc.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
raster2qtm_cli()
¶
Command line interface for raster2qtm conversion
Source code in vgrid/conversion/raster2dggs/raster2qtm.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
raster2rhealpix_cli()
¶
Command line interface for raster2rhealpix
Source code in vgrid/conversion/raster2dggs/raster2rhealpix.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
Raster to H3 Module
This module provides functionality to convert raster data to H3 (Hierarchical Hexagonal Grid) DGGS format with automatic resolution determination and multi-band support.
Key Functions
get_nearest_h3_resolution(raster_path)
¶
Automatically determine the optimal H3 resolution for a given raster.
Analyzes the raster's pixel size and determines the most appropriate H3 resolution that best matches the raster's spatial resolution.
Parameters¶
raster_path : str Path to the raster file to analyze.
Returns¶
tuple A tuple containing (cell_size, resolution) where: - cell_size: The calculated cell size in square meters - resolution: The optimal H3 resolution level
Examples¶
cell_size, resolution = get_nearest_h3_resolution("data.tif") print(f"Cell size: {cell_size} m², Resolution: {resolution}") Cell size: 1000000.0 m², Resolution: 5
Source code in vgrid/conversion/raster2dggs/raster2h3.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
raster2h3(raster_path, resolution=None, output_format='gpd', fix_antimeridian=None)
¶
Convert raster data to H3 DGGS format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raster_path
|
str
|
Path to the raster file |
required |
resolution
|
int
|
H3 resolution [0..15]. If None, automatically determined |
None
|
output_format
|
str
|
Output format. Options: - None: Returns GeoPandas GeoDataFrame (default) - "gpd": Returns GeoPandas GeoDataFrame - "csv": Returns CSV file path - "geojson": Returns GeoJSON file path - "geojson_dict": Returns GeoJSON FeatureCollection as Python dict - "parquet": Returns Parquet file path - "shapefile"/"shp": Returns Shapefile file path - "gpkg"/"geopackage": Returns GeoPackage file path |
'gpd'
|
Source code in vgrid/conversion/raster2dggs/raster2h3.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
Raster to S2 Module
This module provides functionality to convert raster data to S2 DGGS format with automatic resolution determination and multi-band support.
Key Functions
get_nearest_s2_resolution(raster_path)
¶
Automatically determine the optimal S2 resolution for a given raster.
Analyzes the raster's pixel size and determines the most appropriate S2 resolution that best matches the raster's spatial resolution.
Parameters¶
raster_path : str Path to the raster file to analyze.
Returns¶
tuple A tuple containing (cell_size, resolution) where: - cell_size: The calculated cell size in square meters - resolution: The optimal S2 resolution level
Examples¶
cell_size, resolution = get_nearest_s2_resolution("data.tif") print(f"Cell size: {cell_size} m², Resolution: {resolution}") Cell size: 1000000.0 m², Resolution: 5
Source code in vgrid/conversion/raster2dggs/raster2s2.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
raster2s2(raster_path, resolution=None, output_format='gpd', fix_antimeridian=None)
¶
Convert raster data to S2 DGGS format.
Converts raster data to S2 DGGS format with automatic resolution determination and multi-band support. Each pixel is assigned to an S2 cell and the first sample value per cell is preserved.
Parameters¶
raster_path : str Path to the raster file to convert. resolution : int, optional S2 resolution level. If None, automatically determined based on raster pixel size. Valid range: 0-30. output_format : str, default "gpd" Output format. Options: - "gpd": Returns GeoPandas GeoDataFrame (default) - "csv": Returns CSV file path - "geojson": Returns GeoJSON file path - "geojson_dict": Returns GeoJSON FeatureCollection as Python dict - "parquet": Returns Parquet file path - "shapefile"/"shp": Returns Shapefile file path - "gpkg"/"geopackage": Returns GeoPackage file path fix_antimeridian : str, optional Antimeridian fixing method: shift, shift_balanced, shift_west, shift_east, split, none Defaults to None when omitted. Returns
geopandas.GeoDataFrame or str or dict The converted data in the specified format. Each row represents an S2 cell with geometry and band values from the original raster.
Examples¶
Convert with automatic resolution¶
result = raster2s2("data.tif") print(f"Converted {len(result)} S2 cells")
Convert with specific resolution¶
result = raster2s2("data.tif", resolution=10)
Convert to GeoJSON file¶
result = raster2s2("data.tif", output_format="geojson") print(f"Saved to: {result}")
Source code in vgrid/conversion/raster2dggs/raster2s2.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
Raster to A5 Module
This module provides functionality to convert raster data to A5 DGGS format with automatic resolution determination and multi-band support.
Key Functions
get_nearest_a5_resolution(raster_path)
¶
Automatically determine the optimal A5 resolution for a given raster.
Analyzes the raster's pixel size and determines the most appropriate A5 resolution that best matches the raster's spatial resolution.
Parameters¶
raster_path : str Path to the raster file to analyze.
Returns¶
tuple A tuple containing (cell_size, resolution) where: - cell_size: The calculated cell size in square meters - resolution: The optimal A5 resolution level
Examples¶
cell_size, resolution = get_nearest_a5_resolution("data.tif") print(f"Cell size: {cell_size} m², Resolution: {resolution}") Cell size: 1000000.0 m², Resolution: 5
Source code in vgrid/conversion/raster2dggs/raster2a5.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
raster2a5(raster_path, resolution=None, output_format='gpd', options=None, split_antimeridian=False)
¶
Convert raster data to A5 DGGS format.
Converts raster data to A5 (Adaptive 5) DGGS format with automatic resolution determination and multi-band support. Each pixel is assigned to an A5 cell and the first sample value per cell is preserved.
Parameters¶
raster_path : str Path to the raster file to convert. resolution : int, optional A5 resolution level. If None, automatically determined based on raster pixel size. Valid range: 0-15. output_format : str, default "gpd" Output format. Options: - "gpd": Returns GeoPandas GeoDataFrame (default) - "csv": Returns CSV file path - "geojson": Returns GeoJSON file path - "geojson_dict": Returns GeoJSON FeatureCollection as Python dict - "parquet": Returns Parquet file path - "shapefile"/"shp": Returns Shapefile file path - "gpkg"/"geopackage": Returns GeoPackage file path options : dict, optional Options for a52geo. split_antimeridian : bool, optional When True, apply antimeridian fixing to the resulting polygons. Defaults to False when None or omitted. Returns
geopandas.GeoDataFrame or str or dict The converted data in the specified format. Each row represents an A5 cell with geometry and band values from the original raster.
Examples¶
Convert with automatic resolution¶
result = raster2a5("data.tif") print(f"Converted {len(result)} A5 cells")
Convert with specific resolution¶
result = raster2a5("data.tif", resolution=5)
Convert to GeoJSON file¶
result = raster2a5("data.tif", output_format="geojson") print(f"Saved to: {result}")
Source code in vgrid/conversion/raster2dggs/raster2a5.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
Raster to RHEALPix Module
This module provides functionality to convert raster data to RHEALPix (Rectified HEALPix) DGGS format with automatic resolution determination and multi-band support.
Key Functions
get_nearest_rhealpix_resolution(raster_path)
¶
Automatically determine the optimal RHEALPix resolution for a given raster.
Analyzes the raster's pixel size and determines the most appropriate RHEALPix resolution that best matches the raster's spatial resolution.
Parameters¶
raster_path : str Path to the raster file to analyze.
Returns¶
tuple A tuple containing (cell_size, resolution) where: - cell_size: The calculated cell size in square meters - resolution: The optimal RHEALPix resolution level
Examples¶
cell_size, resolution = get_nearest_rhealpix_resolution("data.tif") print(f"Cell size: {cell_size} m², Resolution: {resolution}") Cell size: 1000000.0 m², Resolution: 5
Source code in vgrid/conversion/raster2dggs/raster2rhealpix.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
raster2rhealpix(raster_path, resolution=None, output_format='gpd', fix_antimeridian=None)
¶
Convert raster data to RHEALPix DGGS format.
Converts raster data to RHEALPix (Rectified HEALPix) DGGS format with automatic resolution determination and multi-band support. Each pixel is assigned to a RHEALPix cell and the first sample value per cell is preserved.
Parameters¶
raster_path : str Path to the raster file to convert. resolution : int, optional RHEALPix resolution level. If None, automatically determined based on raster pixel size. Valid range: 0-30. output_format : str, default "gpd" Output format. Options: - "gpd": Returns GeoPandas GeoDataFrame (default) - "csv": Returns CSV file path - "geojson": Returns GeoJSON file path - "geojson_dict": Returns GeoJSON FeatureCollection as Python dict - "parquet": Returns Parquet file path - "shapefile"/"shp": Returns Shapefile file path - "gpkg"/"geopackage": Returns GeoPackage file path fix_antimeridian : Antimeridian fixing method: shift, shift_balanced, shift_west, shift_east, split, none When True, apply antimeridian fixing to the resulting polygons. Defaults to False when None or omitted.
Returns¶
geopandas.GeoDataFrame or str or dict The converted data in the specified format. Each row represents a RHEALPix cell with geometry and band values from the original raster.
Examples¶
Convert with automatic resolution¶
result = raster2rhealpix("data.tif") print(f"Converted {len(result)} RHEALPix cells")
Convert with specific resolution¶
result = raster2rhealpix("data.tif", resolution=10)
Convert to GeoJSON file¶
result = raster2rhealpix("data.tif", output_format="geojson") print(f"Saved to: {result}")
Source code in vgrid/conversion/raster2dggs/raster2rhealpix.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
raster2rhealpix_cli()
¶
Command line interface for raster2rhealpix
Source code in vgrid/conversion/raster2dggs/raster2rhealpix.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
Raster to ISEA4T Module
This module provides functionality to convert raster data to ISEA4T DGGS format with automatic resolution determination and multi-band support.
Key Functions
get_nearest_isea4t_resolution(raster_path)
¶
Automatically determine the optimal ISEA4T resolution for a given raster.
Analyzes the raster's pixel size and determines the most appropriate ISEA4T resolution that best matches the raster's spatial resolution.
Parameters¶
raster_path : str Path to the raster file to analyze.
Returns¶
tuple A tuple containing (cell_size, resolution) where: - cell_size: The calculated cell size in square meters - resolution: The optimal ISEA4T resolution level
Examples¶
cell_size, resolution = get_nearest_isea4t_resolution("data.tif") print(f"Cell size: {cell_size} m², Resolution: {resolution}") Cell size: 1000000.0 m², Resolution: 5
Source code in vgrid/conversion/raster2dggs/raster2isea4t.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
raster2isea4t(raster_path, resolution=None, output_format='gpd', fix_antimeridian=None)
¶
Convert raster data to ISEA4T DGGS format.
Converts raster data to ISEA4T DGGS format with automatic resolution determination and multi-band support. Each pixel is assigned to an ISEA4T cell and the first sample value per cell is preserved.
Parameters¶
raster_path : str Path to the raster file to convert. resolution : int, optional ISEA4T resolution level. If None, automatically determined based on raster pixel size. Valid range: 0-39. output_format : str, default "gpd" Output format. Options: - "gpd": Returns GeoPandas GeoDataFrame (default) - "csv": Returns CSV file path - "geojson": Returns GeoJSON file path - "geojson_dict": Returns GeoJSON FeatureCollection as Python dict - "parquet": Returns Parquet file path - "shapefile"/"shp": Returns Shapefile file path - "gpkg"/"geopackage": Returns GeoPackage file path fix_antimeridian : str, optional Antimeridian fixing method: shift, shift_balanced, shift_west, shift_east, split, none
Returns¶
geopandas.GeoDataFrame or str or dict The converted data in the specified format. Each row represents an ISEA4T cell with geometry and band values from the original raster.
Examples¶
Convert with automatic resolution¶
result = raster2isea4t("data.tif") print(f"Converted {len(result)} ISEA4T cells")
Convert with specific resolution¶
result = raster2isea4t("data.tif", resolution=10)
Convert to GeoJSON file¶
result = raster2isea4t("data.tif", output_format="geojson") print(f"Saved to: {result}")
Source code in vgrid/conversion/raster2dggs/raster2isea4t.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
Raster to DGGAL Module
This module provides functionality to convert raster data to DGGAL (Discrete Global Grids with Adaptive Localization) DGGS format with automatic resolution determination and multi-band support.
Key Functions
get_nearest_dggal_resolution(dggs_type, raster_path)
¶
Automatically determine the optimal DGGAL resolution for a given raster.
Analyzes the raster's pixel size and determines the most appropriate DGGAL resolution that best matches the raster's spatial resolution for the specified DGGS type.
Parameters¶
dggs_type : str DGGAL DGGS type (e.g., "isea3h", "isea4t", "rhealpix"). raster_path : str Path to the raster file to analyze.
Returns¶
tuple A tuple containing (cell_size, resolution) where: - cell_size: The calculated cell size in square meters - resolution: The optimal DGGAL resolution level
Examples¶
cell_size, resolution = get_nearest_dggal_resolution("isea3h", "data.tif") print(f"Cell size: {cell_size} m², Resolution: {resolution}") Cell size: 1000000.0 m², Resolution: 5
Source code in vgrid/conversion/raster2dggs/raster2dggal.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
raster2dggal(dggs_type, raster_path, resolution=None, output_format='gpd', split_antimeridian=False)
¶
Convert raster data to DGGAL DGGS format.
Converts raster data to DGGAL DGGS format with automatic resolution determination and multi-band support. Each pixel is assigned to a DGGAL cell and the first sample value per cell is preserved.
Parameters¶
dggs_type : str DGGAL DGGS type (e.g., "isea3h", "isea4t", "rhealpix"). raster_path : str Path to the raster file to convert. resolution : int, optional DGGAL resolution level. If None, automatically determined based on raster pixel size. Valid range depends on the DGGS type. output_format : str, default "gpd" Output format. Options: - "gpd": Returns GeoPandas GeoDataFrame (default) - "csv": Returns CSV file path - "geojson": Returns GeoJSON file path - "geojson_dict": Returns GeoJSON FeatureCollection as Python dict - "parquet": Returns Parquet file path - "shapefile"/"shp": Returns Shapefile file path - "gpkg"/"geopackage": Returns GeoPackage file path split_antimeridian : bool, optional When True, apply antimeridian fixing to the resulting polygons. Defaults to False when None or omitted.
Returns¶
geopandas.GeoDataFrame or str or dict The converted data in the specified format. Each row represents a DGGAL cell with geometry and band values from the original raster.
Examples¶
Convert with automatic resolution¶
result = raster2dggal("isea3h", "data.tif") print(f"Converted {len(result)} DGGAL cells")
Convert with specific resolution¶
result = raster2dggal("isea3h", "data.tif", resolution=5)
Convert to GeoJSON file¶
result = raster2dggal("isea3h", "data.tif", output_format="geojson") print(f"Saved to: {result}")
Source code in vgrid/conversion/raster2dggs/raster2dggal.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
Raster to DGGRID Module
This module provides functionality to convert raster data to DGGRID DGGS format with automatic resolution determination and multi-band support.
Key Functions
get_nearest_dggrid_resolution(dggrid_instance, dggs_type, raster_path)
¶
Automatically determine the optimal DGGRID resolution for a given raster.
Analyzes the raster's pixel size and determines the most appropriate DGGRID resolution that best matches the raster's spatial resolution for the specified DGGS type.
Parameters¶
dggrid_instance : object DGGRID instance for processing. dggs_type : str DGGRID DGGS type (e.g., "ISEA7H", "ISEA4T"). raster_path : str Path to the raster file to analyze.
Returns¶
tuple A tuple containing (cell_size, resolution) where: - cell_size: The calculated cell size in square meters - resolution: The optimal DGGRID resolution level
Examples¶
cell_size, resolution = get_nearest_dggrid_resolution(instance, "ISEA7H", "data.tif") print(f"Cell size: {cell_size} m², Resolution: {resolution}") Cell size: 1000000.0 m², Resolution: 5
Source code in vgrid/conversion/raster2dggs/raster2dggrid.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
raster2dggrid(dggrid_instance, dggs_type, raster_path, resolution=None, output_format='gpd', split_antimeridian=False, aggregate=False)
¶
Convert raster data to DGGRID DGGS format.
Converts raster data to DGGRID DGGS format with automatic resolution determination and multi-band support. Each pixel is assigned to a DGGRID cell and the first sample value per cell is preserved.
Parameters¶
dggrid_instance : object DGGRID instance for processing. dggs_type : str DGGRID DGGS type (e.g., "ISEA7H", "ISEA4T"). raster_path : str Path to the raster file to convert. resolution : int, optional DGGRID resolution level. If None, automatically determined based on raster pixel size. Valid range depends on the DGGS type. output_format : str, default "gpd" Output format. Options: - "gpd": Returns GeoPandas GeoDataFrame (default) - "csv": Returns CSV file path - "geojson": Returns GeoJSON file path - "geojson_dict": Returns GeoJSON FeatureCollection as Python dict - "parquet": Returns Parquet file path - "shapefile"/"shp": Returns Shapefile file path - "gpkg"/"geopackage": Returns GeoPackage file path split_antimeridian : bool, optional When True, apply antimeridian fixing to the resulting polygons. Defaults to False when None or omitted. aggregate : bool, optional When True, aggregate the resulting polygons. Defaults to False when None or omitted. Returns
geopandas.GeoDataFrame or str or dict The converted data in the specified format. Each row represents a DGGRID cell with geometry and band values from the original raster.
Examples¶
Convert with automatic resolution¶
result = raster2dggrid(instance, "ISEA7H", "data.tif") print(f"Converted {len(result)} DGGRID cells")
Convert with specific resolution¶
result = raster2dggrid(instance, "ISEA7H", "data.tif", resolution=5)
Convert to GeoJSON file¶
result = raster2dggrid(instance, "ISEA7H", "data.tif", output_format="geojson") print(f"Saved to: {result}")
Source code in vgrid/conversion/raster2dggs/raster2dggrid.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
Raster to QTM Module
This module provides functionality to convert raster data to QTM (Quaternary Triangular Mesh) DGGS format with automatic resolution determination and multi-band support.
Key Functions
get_nearest_qtm_resolution(raster_path)
¶
Automatically determine the optimal QTM resolution for a given raster.
Analyzes the raster's pixel size and determines the most appropriate QTM resolution that best matches the raster's spatial resolution.
Parameters¶
raster_path : str Path to the raster file to analyze.
Returns¶
tuple A tuple containing (cell_size, resolution) where: - cell_size: The calculated cell size in square meters - resolution: The optimal QTM resolution level
Examples¶
cell_size, resolution = get_nearest_qtm_resolution("data.tif") print(f"Cell size: {cell_size} m², Resolution: {resolution}") Cell size: 1000000.0 m², Resolution: 5
Source code in vgrid/conversion/raster2dggs/raster2qtm.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
raster2qtm(raster_path, resolution=None, output_format='gpd')
¶
Convert raster data to QTM DGGS format.
Converts raster data to QTM (Quaternary Triangular Mesh) DGGS format with automatic resolution determination and multi-band support. Each pixel is assigned to a QTM cell and the first sample value per cell is preserved.
Parameters¶
raster_path : str Path to the raster file to convert. resolution : int, optional QTM resolution level. If None, automatically determined based on raster pixel size. Valid range: 1-30. output_format : str, default "gpd" Output format. Options: - "gpd": Returns GeoPandas GeoDataFrame (default) - "csv": Returns CSV file path - "geojson": Returns GeoJSON file path - "geojson_dict": Returns GeoJSON FeatureCollection as Python dict - "parquet": Returns Parquet file path - "shapefile"/"shp": Returns Shapefile file path - "gpkg"/"geopackage": Returns GeoPackage file path
Returns¶
geopandas.GeoDataFrame or str or dict The converted data in the specified format. Each row represents a QTM cell with geometry and band values from the original raster.
Examples¶
Convert with automatic resolution¶
result = raster2qtm("data.tif") print(f"Converted {len(result)} QTM cells")
Convert with specific resolution¶
result = raster2qtm("data.tif", resolution=10)
Convert to GeoJSON file¶
result = raster2qtm("data.tif", output_format="geojson") print(f"Saved to: {result}")
Source code in vgrid/conversion/raster2dggs/raster2qtm.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
raster2qtm_cli()
¶
Command line interface for raster2qtm conversion
Source code in vgrid/conversion/raster2dggs/raster2qtm.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
Raster to OLC Module
This module provides functionality to convert raster data to OLC (Open Location Code) DGGS format with automatic resolution determination and multi-band support.
Key Functions
get_nearest_olc_resolution(raster_path)
¶
Automatically determine the optimal OLC resolution for a given raster.
Analyzes the raster's pixel size and determines the most appropriate OLC resolution that best matches the raster's spatial resolution.
Parameters¶
raster_path : str Path to the raster file to analyze.
Returns¶
tuple A tuple containing (cell_size, resolution) where: - cell_size: The calculated cell size in square meters - resolution: The optimal OLC resolution level
Examples¶
cell_size, resolution = get_nearest_olc_resolution("data.tif") print(f"Cell size: {cell_size} m², Resolution: {resolution}") Cell size: 1000000.0 m², Resolution: 8
Source code in vgrid/conversion/raster2dggs/raster2olc.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
raster2olc(raster_path, resolution=None, output_format='gpd')
¶
Convert raster data to OLC DGGS format.
Converts raster data to OLC (Open Location Code) DGGS format with automatic resolution determination and multi-band support. Each pixel is assigned to an OLC cell and the first sample value per cell is preserved.
Parameters¶
raster_path : str Path to the raster file to convert. resolution : int, optional OLC resolution level. If None, automatically determined based on raster pixel size. Valid values: [2, 4, 6, 8, 10, 11, 12, 13, 14, 15]. output_format : str, default "gpd" Output format. Options: - "gpd": Returns GeoPandas GeoDataFrame (default) - "csv": Returns CSV file path - "geojson": Returns GeoJSON file path - "geojson_dict": Returns GeoJSON FeatureCollection as Python dict - "parquet": Returns Parquet file path - "shapefile"/"shp": Returns Shapefile file path - "gpkg"/"geopackage": Returns GeoPackage file path
Returns¶
geopandas.GeoDataFrame or str or dict The converted data in the specified format. Each row represents an OLC cell with geometry and band values from the original raster.
Examples¶
Convert with automatic resolution¶
result = raster2olc("data.tif") print(f"Converted {len(result)} OLC cells")
Convert with specific resolution¶
result = raster2olc("data.tif", resolution=8)
Convert to GeoJSON file¶
result = raster2olc("data.tif", output_format="geojson") print(f"Saved to: {result}")
Source code in vgrid/conversion/raster2dggs/raster2olc.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
raster2olc_cli()
¶
Command line interface for raster to OLC conversion
Source code in vgrid/conversion/raster2dggs/raster2olc.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
Raster to Geohash Module
This module provides functionality to convert raster data to Geohash DGGS format with automatic resolution determination and multi-band support.
Key Functions
get_nearest_geohash_resolution(raster_path)
¶
Automatically determine the optimal Geohash resolution for a given raster.
Analyzes the raster's pixel size and determines the most appropriate Geohash resolution that best matches the raster's spatial resolution.
Parameters¶
raster_path : str Path to the raster file to analyze.
Returns¶
tuple A tuple containing (cell_size, resolution) where: - cell_size: The calculated cell size in square meters - resolution: The optimal Geohash resolution level
Examples¶
cell_size, resolution = get_nearest_geohash_resolution("data.tif") print(f"Cell size: {cell_size} m², Resolution: {resolution}") Cell size: 1000000.0 m², Resolution: 5
Source code in vgrid/conversion/raster2dggs/raster2geohash.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
raster2geohash(raster_path, resolution=None, output_format='gpd')
¶
Convert raster data to Geohash DGGS format.
Converts raster data to Geohash DGGS format with automatic resolution determination and multi-band support. Each pixel is assigned to a Geohash cell and the first sample value per cell is preserved.
Parameters¶
raster_path : str Path to the raster file to convert. resolution : int, optional Geohash resolution level. If None, automatically determined based on raster pixel size. Valid range: 1-12. output_format : str, default "gpd" Output format. Options: - "gpd": Returns GeoPandas GeoDataFrame (default) - "csv": Returns CSV file path - "geojson": Returns GeoJSON file path - "geojson_dict": Returns GeoJSON FeatureCollection as Python dict - "parquet": Returns Parquet file path - "shapefile"/"shp": Returns Shapefile file path - "gpkg"/"geopackage": Returns GeoPackage file path
Returns¶
geopandas.GeoDataFrame or str or dict The converted data in the specified format. Each row represents a Geohash cell with geometry and band values from the original raster.
Examples¶
Convert with automatic resolution¶
result = raster2geohash("data.tif") print(f"Converted {len(result)} Geohash cells")
Convert with specific resolution¶
result = raster2geohash("data.tif", resolution=5)
Convert to GeoJSON file¶
result = raster2geohash("data.tif", output_format="geojson") print(f"Saved to: {result}")
Source code in vgrid/conversion/raster2dggs/raster2geohash.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
Raster to Tilecode Module
This module provides functionality to convert raster data to Tilecode DGGS format with automatic resolution determination and multi-band support.
Key Functions
get_nearest_tilecode_resolution(raster_path)
¶
Automatically determine the optimal Tilecode resolution for a given raster.
Analyzes the raster's pixel size and determines the most appropriate Tilecode resolution that best matches the raster's spatial resolution.
Parameters¶
raster_path : str Path to the raster file to analyze.
Returns¶
tuple A tuple containing (cell_size, resolution) where: - cell_size: The calculated cell size in square meters - resolution: The optimal Tilecode resolution level
Examples¶
cell_size, resolution = get_nearest_tilecode_resolution("data.tif") print(f"Cell size: {cell_size} m², Resolution: {resolution}") Cell size: 1000000.0 m², Resolution: 5
Source code in vgrid/conversion/raster2dggs/raster2tilecode.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
raster2tilecode(raster_path, resolution=None, output_format='gpd')
¶
Convert raster data to Tilecode DGGS format.
Converts raster data to Tilecode DGGS format with automatic resolution determination and multi-band support. Each pixel is assigned to a Tilecode cell and the first sample value per cell is preserved.
Parameters¶
raster_path : str Path to the raster file to convert. resolution : int, optional Tilecode resolution level. If None, automatically determined based on raster pixel size. Valid range: 0-26. output_format : str, default "gpd" Output format. Options: - "gpd": Returns GeoPandas GeoDataFrame (default) - "csv": Returns CSV file path - "geojson": Returns GeoJSON file path - "geojson_dict": Returns GeoJSON FeatureCollection as Python dict - "parquet": Returns Parquet file path - "shapefile"/"shp": Returns Shapefile file path - "gpkg"/"geopackage": Returns GeoPackage file path
Returns¶
geopandas.GeoDataFrame or str or dict The converted data in the specified format. Each row represents a Tilecode cell with geometry and band values from the original raster.
Examples¶
Convert with automatic resolution¶
result = raster2tilecode("data.tif") print(f"Converted {len(result)} Tilecode cells")
Convert with specific resolution¶
result = raster2tilecode("data.tif", resolution=10)
Convert to GeoJSON file¶
result = raster2tilecode("data.tif", output_format="geojson") print(f"Saved to: {result}")
Source code in vgrid/conversion/raster2dggs/raster2tilecode.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
Raster to Quadkey Module
This module provides functionality to convert raster data to Quadkey DGGS format with automatic resolution determination and multi-band support.
Key Functions
get_nearest_quadkey_resolution(raster_path)
¶
Automatically determine the optimal Quadkey resolution for a given raster.
Analyzes the raster's pixel size and determines the most appropriate Quadkey resolution that best matches the raster's spatial resolution.
Parameters¶
raster_path : str Path to the raster file to analyze.
Returns¶
tuple A tuple containing (cell_size, resolution) where: - cell_size: The calculated cell size in square meters - resolution: The optimal Quadkey resolution level
Examples¶
cell_size, resolution = get_nearest_quadkey_resolution("data.tif") print(f"Cell size: {cell_size} m², Resolution: {resolution}") Cell size: 1000000.0 m², Resolution: 5
Source code in vgrid/conversion/raster2dggs/raster2quadkey.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
raster2quadkey(raster_path, resolution=None, output_format='gpd')
¶
Convert raster data to Quadkey DGGS format.
Converts raster data to Quadkey DGGS format with automatic resolution determination and multi-band support. Each pixel is assigned to a Quadkey cell and the first sample value per cell is preserved.
Parameters¶
raster_path : str Path to the raster file to convert. resolution : int, optional Quadkey resolution level. If None, automatically determined based on raster pixel size. Valid range: 0-29. output_format : str, default "gpd" Output format. Options: - "gpd": Returns GeoPandas GeoDataFrame (default) - "csv": Returns CSV file path - "geojson": Returns GeoJSON file path - "geojson_dict": Returns GeoJSON FeatureCollection as Python dict - "parquet": Returns Parquet file path - "shapefile"/"shp": Returns Shapefile file path - "gpkg"/"geopackage": Returns GeoPackage file path
Returns¶
geopandas.GeoDataFrame or str or dict The converted data in the specified format. Each row represents a Quadkey cell with geometry and band values from the original raster.
Examples¶
Convert with automatic resolution¶
result = raster2quadkey("data.tif") print(f"Converted {len(result)} Quadkey cells")
Convert with specific resolution¶
result = raster2quadkey("data.tif", resolution=10)
Convert to GeoJSON file¶
result = raster2quadkey("data.tif", output_format="geojson") print(f"Saved to: {result}")
Source code in vgrid/conversion/raster2dggs/raster2quadkey.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |