GeoClasses API¶
GeoImageFrame¶
GeoImageFrame
¶
Bases: GeoDataFrame
A GeoDataFrame extension for managing geolocated images.
Attributes:
| Name | Type | Description |
|---|---|---|
image_url |
str
|
URL to the image file. |
name |
str
|
Name or label for the image. |
geometry |
Point
|
Geolocation of the image. |
Example
geo_frame = GeoImageFrame({'image_url': ['http://example.com/image.jpg'], 'name': ['Sample'], 'geometry': [Point(0, 0)]})
Source code in landlensdb/geoclasses/geoimageframe.py
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 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 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 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
__init__(*args, **kwargs)
¶
Initialize the GeoImageFrame object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Positional arguments passed to the GeoDataFrame constructor. |
()
|
|
**kwargs
|
Keyword arguments passed to the GeoDataFrame constructor. |
{}
|
Source code in landlensdb/geoclasses/geoimageframe.py
79 80 81 82 83 84 85 86 87 | |
_create_table_row(label, value)
staticmethod
¶
Internal method to create an HTML table row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label for the row. |
required |
value
|
str
|
The value for the row. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
An HTML string representing the table row. |
Source code in landlensdb/geoclasses/geoimageframe.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
_download_image_from_url(url, dest_path, max_retries=3, retry_delay=1)
staticmethod
¶
Internal method to download an image from a URL with retries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the image to download. |
required |
dest_path
|
str
|
The destination path to save the downloaded image. |
required |
max_retries
|
int
|
Maximum number of retry attempts. |
3
|
retry_delay
|
int
|
Delay between retries in seconds. |
1
|
Returns:
| Type | Description |
|---|---|
str | None
|
The local path where the image was downloaded, or None if failed. |
Source code in landlensdb/geoclasses/geoimageframe.py
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 | |
_popup_html(row, image_url, additional_properties)
¶
Internal method to create HTML for a popup on a map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
int
|
The index of the row for which to create the popup. |
required |
image_url
|
str
|
The URL or path of the image to display in the popup. |
required |
additional_properties
|
list
|
Additional properties to display in the popup. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
An HTML string representing the popup. |
Source code in landlensdb/geoclasses/geoimageframe.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
_verify_structure()
¶
Verifies the structure of the GeoImageFrame to ensure it has the required columns and datatypes.
Source code in landlensdb/geoclasses/geoimageframe.py
89 90 91 92 93 94 95 96 97 98 99 100 | |
download_images_to_local(dest_dir, filename_column=None, max_workers=10)
¶
Downloads the images specified in the 'image_url' column of the GeoDataFrame to a local directory using multiple threads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dest_dir
|
str
|
The destination directory where the images will be downloaded. |
required |
filename_column
|
str
|
Column to use for the filename. Defaults to the filename in the URL. |
None
|
max_workers
|
int
|
Maximum number of concurrent download threads. Defaults to 10. |
10
|
Returns:
| Name | Type | Description |
|---|---|---|
GeoImageFrame |
A new GeoImageFrame with the local paths to the downloaded images. |
Example
local_gdf = geo_image_frame.download_images_to_local('images/', max_workers=20)
Source code in landlensdb/geoclasses/geoimageframe.py
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 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
map(tiles='OpenStreetMap', zoom_start=18, max_zoom=19, additional_properties=None, additional_geometries=None)
¶
Maps the GeoImageFrame using Folium.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tiles
|
str
|
Map tileset to use. Default is "OpenStreetMap". |
'OpenStreetMap'
|
zoom_start
|
int
|
Initial zoom level. Default is 18. |
18
|
max_zoom
|
int
|
Maximum zoom level. Default is 19. |
19
|
additional_properties
|
list
|
Additional properties to display in the popup. |
None
|
additional_geometries
|
list
|
Additional geometries to include on the map. |
None
|
Returns:
| Type | Description |
|---|---|
|
folium.Map: A Folium Map object displaying the GeoImageFrame. |
Example
m = geo_frame.map() m.save('map.html')
Source code in landlensdb/geoclasses/geoimageframe.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
to_dict_records()
¶
Converts the GeoImageFrame to a dictionary representation.
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of dictionaries representing the GeoImageFrame rows. |
Source code in landlensdb/geoclasses/geoimageframe.py
102 103 104 105 106 107 108 | |
to_file(filename, **kwargs)
¶
Saves the GeoImageFrame to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The filename or path to save the GeoImageFrame. |
required |
**kwargs
|
Additional keyword arguments for the 'to_file' method. |
{}
|
Source code in landlensdb/geoclasses/geoimageframe.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
to_postgis(name, engine, if_exists='fail', *args, **kwargs)
¶
Saves the GeoImageFrame to a PostGIS database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the table to create or update. |
required |
engine
|
Engine
|
SQLAlchemy engine connected to the database. |
required |
if_exists
|
str
|
Behavior if the table already exists in the database. Default is "fail". |
'fail'
|
*args
|
Additional positional arguments for the 'to_postgis' method. |
()
|
|
**kwargs
|
Additional keyword arguments for the 'to_postgis' method. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If required columns are missing or if the CRS is incorrect. |
TypeError
|
If the columns contain incorrect data types. |
Source code in landlensdb/geoclasses/geoimageframe.py
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 | |
_generate_arrow_icon(compass_angle)
¶
Generates an arrow icon based on the specified compass angle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
compass_angle
|
float
|
The compass angle in degrees to which the arrow points. |
required |
Returns:
| Type | Description |
|---|---|
|
folium.features.CustomIcon: A Folium CustomIcon object representing the arrow. |
Example
icon = generate_arrow_icon(90) marker = folium.Marker(location=[lat, lon], icon=icon)
Source code in landlensdb/geoclasses/geoimageframe.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
_generate_arrow_svg(compass_angle)
¶
Generates an SVG string representing an arrow pointing to the specified compass angle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
compass_angle
|
float
|
The compass angle in degrees to which the arrow points. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
The SVG string of the arrow. |
Example
svg_str = generate_arrow_svg(45)
Source code in landlensdb/geoclasses/geoimageframe.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 | |