This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you are working with python module that depends on a custom sqlite3.dll, IPython on startup will load sqlite3.dll from the installation's vendored DLLs. This can cause a conflict resulting in a failed DLL load since the module that needs the custom sqlite3.dll cannot override the currently loaded DLL (DLL HELL). | |
WORKAROUND: copy the custom sqlite3.dll to the installation location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# This tool has been copied from https://github.com/vinayak-mehta/pdftopng/blob/main/scripts/wheel_repair.py | |
# and extended to supported hierarchical folder architecture with mulitple .pyd | |
# to update, and to move all the DLL in a common folder *package*.lib installed | |
# jointly with the package itself, similarly to auditwheel on Linux platform. | |
#(see also https://discuss.python.org/t/delocate-auditwheel-but-for-windows/2589/9). | |
# Additionally adapted from https://github.com/Wandercraft/jiminy/blob/648c0ec918ca2c2f734a32bada1dbfaf6226de48/build_tools/wheel_repair.py | |
# added sorting of pyd and dll files such that repaired dlls pointing to their own |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import os | |
>>> os.add_dll_directory('C:\path\to\dll\dir') | |
>>> import rasterio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
RPC_DEM_SRS only used in GDAL >= 3.2.0, otherwise ignored | |
""" | |
import rasterio | |
import rasterio.warp | |
from rasterio import logging | |
logging.basicConfig(filename='rasterio.log', level=logging.DEBUG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rem https://github.com/OSGeo/PROJ/blob/475e7fd9f11af184e7e1e1618b3e1bb110a79714/src/networkfilemanager.cpp#L1613 | |
set PROJ_UNSAFE_SSL=YES | |
projsync --list-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from osgeo import gdal, osr | |
driver = gdal.GetDriverByName("GTiff") | |
src = driver.Create('/vsimem/test.tif', 32, 32, 1) | |
srs = osr.SpatialReference() | |
srs.ImportFromEPSG(4326) | |
src.SetGCPs((gdal.GCP(0, 0, 0, 0, 0),), srs) | |
dst = gdal.Translate('/vsimem/test.vrt', src) | |
print(dst.GetMetadata('xml:vrt')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from osgeo import gdal | |
import joblib | |
from itertools import cycle, product, chain | |
from more_itertools import ichunked | |
import time | |
import os | |
SRC = 'RS2_OK76385_PK678064_DK606753_F2N_20080419_142127_HH_HV_SLC/RS2_OK76385_PK678064_DK606753_F2N_20080419_142127_HH_HV_SLC' | |
def block_windows(src, xsize, ysize): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product, chain | |
def block_windows(src, xsize, ysize): | |
height, width = src.shape | |
nrows, rmod = divmod(height, ysize) | |
ncols, cmod = divmod(width, xsize) | |
offsets = product(range(0, width, xsize), range(0, height, ysize)) | |
sizes = product(chain([xsize]*ncols, [cmod]), chain([ysize]*nrows, [rmod])) | |
for (xoff, yoff), (xsize, ysize) in zip(offsets, sizes): | |
yield xoff, yoff, xsize, ysize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LINEAR_GEOMS = (shapely.geometry.LineString, shapely.geometry.LinearRing) | |
VALID_GEOMS = (*LINEAR_GEOMS, shapely.geometry.Polygon) | |
def linspace(start, stop, n): | |
assert n >= 0 | |
try: | |
step = (stop - start) / (n-1) | |
except ZeroDivisionError: | |
step = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Segmentize an input shapely polygon | |
For an input polygon, generate a new polygon composed of n points | |
interpolated along the linear geometry of each vertex of the input | |
polygon | |
""" | |
import numpy as np | |
import shapely | |
import shapely.geometry | |
import shapely.ops |
NewerOlder