from __future__ import absolute_import from __future__ import division import argparse import os from scipy import ndimage import numpy as np from raster_tools import datasets from raster_tools import datasources from raster_tools import groups from raster_tools import gdal GTIF = gdal.GetDriverByName(str('gtiff')) DTYPE = np.dtype('i8, i8') COURSES = np.array([(64, 128, 1), (32, 0, 2), (16, 8, 4)], 'u1') INDICES = COURSES.nonzero() NUMBERS = COURSES[INDICES][np.newaxis, ...] OFFSETS = np.array(INDICES).transpose()[np.newaxis] - 1 def fill_simple_depressions(values): """ Fill simple depressions in-place. """ footprint = np.array([(1, 1, 1), (1, 0, 1), (1, 1, 1)], dtype='b1') edge = ndimage.minimum_filter(values, footprint=footprint) locs = edge > values values[locs] = edge[locs]
import argparse import subprocess import os import re import numpy as np from raster_tools import gdal from raster_tools import ogr from raster_tools import osr from raster_tools import datasets from raster_tools import datasources DRIVER_OGR_MEMORY = ogr.GetDriverByName(str('Memory')) DRIVER_GDAL_MEM = gdal.GetDriverByName(str('mem')) DRIVER_GDAL_GTIFF = gdal.GetDriverByName(str('gtiff')) WKT_RD = osr.GetUserInputAsWKT(str('epsg:28992')) PROJ4_RD = osr.SpatialReference(WKT_RD).ExportToProj4().strip() def command(gardens_path, aerial_image_path, target_path, min_green, max_green, check_rast, part, pk): # open input shapefile shape_gardens = ogr.Open(gardens_path) layer_gardens = shape_gardens[0] # check projection of input shapefile sr = layer_gardens.GetSpatialRef() check_sr = get_projection(sr)
# -*- coding: utf-8 -*- """ TODO Docstring. """ from __future__ import print_function from __future__ import unicode_literals from __future__ import absolute_import from __future__ import division import argparse import os from raster_tools import gdal from raster_tools import ogr from raster_tools import osr DRIVER_GDAL_GTIFF = gdal.GetDriverByName(b'gtiff') DRIVER_GDAL_MEM = gdal.GetDriverByName(b'mem') PROJECTION = osr.GetUserInputAsWKT(str('epsg:28992')) NO_DATA_VALUE = 3.4028234663852886e+38 DATA_TYPE = gdal.GDT_Float32 OPTIONS = ['compress=deflate', 'tiled=yes'] def get_geo_transform(geometry, cellsize=(0.5, -0.5)): """ Return geotransform. """ a, b, c, d = cellsize[0], 0.0, 0.0, cellsize[1] x1, x2, y1, y2 = geometry.GetEnvelope() return x1, a, b, y2, c, d
from __future__ import division import argparse import math import os import numpy as np from raster_tools import datasets from raster_tools import gdal from raster_tools import osr WIDTH = 0.5 HEIGHT = 0.5 NO_DATA_VALUE = np.finfo('f4').min.item() DRIVER = gdal.GetDriverByName(str('gtiff')) OPTIONS = ['compress=deflate', 'tiled=yes'] PROJECTION = osr.GetUserInputAsWKT(str('epsg:28992')) def rasterize(points): """ Create array. """ xmin, ymin = points[:, :2].min(0) xmax, ymax = points[:, :2].max(0) p = math.floor(xmin / WIDTH) * WIDTH q = math.floor(ymax / HEIGHT) * HEIGHT geo_transform = p, WIDTH, 0, q, 0, -HEIGHT indices = np.empty((len(points), 3), 'u4')