extent
¶
Classes:
-
Extent–Geographic extent.
Extent
¶
Geographic extent.
The Extent object represents geographic extents of an area and exposes useful methods which depend on those extents. This includes: - Easily representing the boundaries as (xMin, xMax, yMin, yMax) or (xMin, yMin, xMax, yMax) - Casting to another projection system - Padding and shifting the boundaries - "Fitting" the boundaries onto a given resolution - Clipping a given raster file
Initialization:
- Extent(xMin, yMin, xMax, yMax [, srs])
- Extent.from_xyXY( (xMin, yMin, xMax, yMax) [, srs])
- Extent.from_xXyY( (xMin, xMax, yMin, yMax) [, srs])
- Extent.fromGeom( geom [, srs] )
- Extent.fromVector( vector-file-path )
- Extent.fromRaster( raster-file-path )
- Extent.load( args )
Create extent from explicitly defined boundaries.
Usage:
Extent(xMin, yMin, xMax, yMax [, srs=
Where: xMin - The minimal x value in the respective SRS yMin - The minimal y value in the respective SRS xMax - The maximal x value in the respective SRS yMax - The maximal y value in the respective SRS srs - The Spatial Reference system to use
Methods:
-
castTo–Creates a new Extent by transforming an extent from the original Extent's
-
center–Get the Extent's center.
-
clipRaster–Clip a given raster source to the calling Extent.
-
computePixelSize–Finds the pixel resolution which fits to the Extent for a given pixel count.
-
contains–Tests if the extent contains another given extent.
-
containsLoc–Test if the extent contains a location or an iterable of locations.
-
contoursFromRaster–Convenience wrapper for geokit.raster.contours which automatically
-
corners–Returns the four corners of the extent as ogr.gGometry points or as (x,y)
-
createRaster–Convenience function for geokit.raster.createRaster which sets 'bounds'
-
drawSmopyMap–Draws a basemap using the "smopy" python package.
-
exportWKT–Export the extent to a Well-Known_Text string.
-
extractFeatures–Convenience wrapper for geokit.vector.extractFeatures() by setting the
-
extractMatrix–Convenience wrapper around geokit.raster.extractMatrix(). Extracts the
-
filterSources–Filter a list of sources by those whose's envelope overlaps the Extent.
-
findWithin–Finds the indexes of the given extent within the main extent according
-
fit–Fit the extent to a given pixel resolution.
-
fitsResolution–Test if calling Extent first around the given unit(s) (at least within
-
fromGeom–Create extent around a given geometry.
-
fromLocationSet–Create extent around the contents of a LocationSet object.
-
fromRaster–Create extent around the contents of a raster source.
-
fromTile–Generates an Extent corresponding to tiles used for "slippery maps".
-
fromTileAt–Generates an Extent corresponding to tiles used for "slippery maps"
-
fromVector–Create extent around the contemts of a vector source.
-
fromWKT–Create extent from a Well-Known_Text string.
-
from_xXyY–Create an Extent from explicitly defined boundaries.
-
inSourceExtent–Tests if the extent box is at least partially contained in the extent-box
-
load–Attempts to load an Extent from a variety of inputs in the most
-
mutateRaster–Convenience function for geokit.raster.mutateRaster which automatically
-
mutateVector–Convenience function for geokit.vector.mutateVector which automatically
-
overlaps–Tests if the extent overlaps with another given extent.
-
pad–Pad the extent in all directions.
-
rasterMosaic–Create a raster source surrounding the Extent from a collection of other rasters.
-
rasterize–Convenience function for geokit.vector.rasterize() which automatically
-
shift–Shift the extent in the X and/or Y dimensions.
-
subTiles–Generates tile Extents at a given zoom level which encompass the invoking Extent.
-
tileBox–Determine the tile Extent at a given zoom level which surround the invoked Extent.
-
tileIndexBox–Determine the tile indexes at a given zoom level which surround the invoked Extent.
-
tileMosaic–Create a raster source surrounding the Extent from a collection of tiles.
-
tileSources–Get the tiles sources which contribute to the invoking Extent.
-
warp–Convenience function for geokit.raster.warp() which automatically sets the
Attributes:
-
YxyX(tuple[float, float, float, float]) –Returns a tuple of the extent boundaries in order:
-
box–Returns a rectangular ogr.Geometry object representing the extent.
-
xXyY(tuple[float, float, float, float]) –Returns a tuple of the extent boundaries in order:
-
xYXy(tuple[float, float, float, float]) –Returns a tuple of the extent boundaries in order:
-
xlim(tuple[float, float]) –Returns a tuple of the x-axis extent boundaries in order:
-
xyXY(tuple[float, float, float, float]) –Returns a tuple of the extent boundaries in order:
-
ylim(tuple[float, float]) –Returns a tuple of the y-axis extent boundaries in order:
-
yxYX(tuple[float, float, float, float]) –Returns a tuple of the extent boundaries in order:
Source code in geokit/core/extent.py
YxyX
property
¶
Returns a tuple of the extent boundaries in order: yMax, xMin, yMin, xMax.
xXyY
property
¶
Returns a tuple of the extent boundaries in order: xMin, xMax, yMin, yMax.
xYXy
property
¶
Returns a tuple of the extent boundaries in order: xMin, yMax, xMax, yMin.
xlim
property
¶
Returns a tuple of the x-axis extent boundaries in order: xMin, xMax.
xyXY
property
¶
Returns a tuple of the extent boundaries in order: xMin, yMin, xMax, yMax.
ylim
property
¶
Returns a tuple of the y-axis extent boundaries in order: yMin, yMax.
yxYX
property
¶
Returns a tuple of the extent boundaries in order: yMin, xMin, yMax, xMax.
castTo
¶
castTo(srs: srs_input, segments: numeric = 100)
Creates a new Extent by transforming an extent from the original Extent's srs to a target SRS.
Note:
The resulting region spanned by the extent will be equal-to or (almost certainly) larger than the original
Parameters:
-
(srs¶Anything acceptable to geokit.srs.loadSRS()) –The srs to cast the Extent object to
Returns:
-
Extent–
Source code in geokit/core/extent.py
center
¶
Get the Extent's center.
Source code in geokit/core/extent.py
clipRaster
¶
Clip a given raster source to the calling Extent.
Parameters:
-
(source¶Anything acceptable to geokit.raster.loadRaster()) –The source to clip
-
–**kwargs¶All other keyword arguments are passed to gdal.Translate
Returns:
-
* If 'output' is None: gdal.Dataset– -
* If 'output' is a string: None–
Source code in geokit/core/extent.py
computePixelSize
¶
Finds the pixel resolution which fits to the Extent for a given pixel count.
Note:
- If only one integer argument is given, it is assumed to fit to both the X and Y dimensions
- If two integer arguments are given, it is assumed to be in the order X then Y
Returns:
-
tuple -> (pixelWidth, pixelHeight)–
Source code in geokit/core/extent.py
contains
¶
Tests if the extent contains another given extent.
Note:
If an optional resolution ('res') is given, the containment value is also dependent on whether or not the given extent fits within the larger extent AND is situated along the given resolution
Parameters:
-
(extent¶Extent) –The Extent object to test for containment
-
(res¶numeric or tuple, default:None) –The X & Y resolution to enforce
Returns:
-
bool–
Source code in geokit/core/extent.py
containsLoc
¶
containsLoc(locs)
Test if the extent contains a location or an iterable of locations.
Parameters:
-
(locs¶Anything acceptable to LocationSet()) –The locations to be checked
Returns:
-
* If a single location is checker: bool– -
* If multiple locations are checked: numpy.ndarray–
Source code in geokit/core/extent.py
contoursFromRaster
¶
contoursFromRaster(
raster,
contourEdges: list[float],
transformGeoms: bool = True,
**kwargs,
) -> DataFrame
Convenience wrapper for geokit.raster.contours which automatically clips a raster to the invoked Extent.
Parameters:
-
(raster¶The raster datasource to warp from) – -
(contourEdges¶list[float]) –The edges to search for within the raster dataset * This parameter can be set as "None", in which case an additional argument should be given to specify how the edges should be determined - See the documentation of "GDALContourGenerateEx" - Ex. "LEVEL_INTERVAL=10", contourEdges=None
-
(transformGeoms¶bool, default:True) –If True, geometries are transformed to the Extent's SRS, otherwise they are left in their native SRS
-
–kwargs¶Keyword arguments to pass on to the contours function * See geokit.raster.contours
Returns:
-
DataFrame– -
With columns:–'geom' -> The contiguous-valued geometries 'ID' -> The associated contour edge for each object
Source code in geokit/core/extent.py
corners
¶
Returns the four corners of the extent as ogr.gGometry points or as (x,y) coordinates in the extent's srs.
Source code in geokit/core/extent.py
createRaster
¶
createRaster(pixelWidth, pixelHeight, **kwargs)
Convenience function for geokit.raster.createRaster which sets 'bounds' and 'srs' inputs.
- The input resolution MUST fit within the extent
Parameters:
-
(pixelWidth¶numeric) –The pixel width of the raster in units of the input srs * The keyword 'dx' can be used as well and will override anything given assigned to 'pixelWidth'
-
(pixelHeight¶numeric) –The pixel height of the raster in units of the input srs * The keyword 'dy' can be used as well and will override anything given assigned to 'pixelHeight'
-
–**kwargs¶All other keyword arguments are passed on to geokit.raster.createRaster()
Returns:
-
* If 'output' is None: gdal.Dataset– -
* If 'output' is a string: None–
Source code in geokit/core/extent.py
drawSmopyMap
¶
drawSmopyMap(
zoom,
tileserver="https://a.tile.openstreetmap.org/{z}/{x}/{y}.png",
tilesize=256,
maxtiles=100,
ax=None,
**kwargs,
)
Draws a basemap using the "smopy" python package.
- See more details about smopy here: https://github.com/rossant/smopy
Returns:
-
namedtuple–- .ax -> The axes draw on
- .srs -> The SRS used when drawing (will always be EPSG 3857)
- .bounds -> The boundaries of the drawn map
Source code in geokit/core/extent.py
exportWKT
¶
exportWKT(delimiter='|') -> str
Export the extent to a Well-Known_Text string.
- Actually the will be two WKT strings separated by a "|" character
- These correspond to "|
"
Parameters:
-
(delimiter¶The delimiter which separates the two WKT sections, default:'|') –
Returns:
-
string–
Source code in geokit/core/extent.py
extractFeatures
¶
Convenience wrapper for geokit.vector.extractFeatures() by setting the 'geom' input to the extent's box.
Parameters:
-
(source¶str) –The path to the vector file to load
-
–**kwargs¶All other keyword arguments are passed on to vector.extractFeatures()
Returns:
-
* If asPandas is True: pandas.DataFrame or pandas.Series– -
* If asPandas is False: generator–
Source code in geokit/core/extent.py
extractMatrix
¶
Convenience wrapper around geokit.raster.extractMatrix(). Extracts the extent directly from the given raster source as a matrix around the Extent.
Note:
The called extent must fit somewhere within the raster's grid
Parameters:
-
–source¶The raster source to be read
-
–strict¶Whether or not to allow a returned value which does not fit to the given extent !! If this is set to False, it is STRONGLY recommended to also set the argument 'returnBounds' as True so that the new computed boundary can be known
-
–**kwargs¶All keyword arguments are passed to geokit.raster.extractMatrix
Returns:
-
ndarray or tuple–- See geokit.raster.extractMatrix
Source code in geokit/core/extent.py
filterSources
¶
filterSources(sources, error_on_missing=True)
Filter a list of sources by those whose's envelope overlaps the Extent.
Note:
Creates a filter object which can be immediately iterated over, or else can be cast as a list
Parameters:
-
(sources¶list or str) –The sources to filter * An iterable of vector/raster sources * An iterable of paths pointing to vector/raster sources * A glob string which will generate a list of source paths - see glob.glob for more info
-
(error_on_missing¶bool, default:True) –If True, then if a file path is given which does not exist, a RunTime error is raised. Otherwise a warning is given Only performs check when input is a string
Returns:
-
filter–
Source code in geokit/core/extent.py
findWithin
¶
Finds the indexes of the given extent within the main extent according to the given resolution.
Note:
- Use this to compute the index offsets and window sizes of a window within a raster dataset
- The two extents MUST share the same SRS
Parameters:
-
(extent¶Extent) –The extent to find within the calling extent
-
(res¶numeric or tuple, default:100) –A resolution to check containment on
-
(yAtTop¶bool; optional, default:True) –Instructs the offsetting to begin from yMax instead of from yMin
Returns:
-
tuple -> (xOffset, yOffset, xWindowSize, yWindowSize)–
Source code in geokit/core/extent.py
fit
¶
fit(unit, dtype=None, start_raster=None) -> Extent
Fit the extent to a given pixel resolution.
Note:
The extent is always expanded to fit onto the given unit
Parameters:
-
(unit¶numeric or tuple) –The unit value(s) to check * If numeric, a single value is assumed for both X and Y dim * If tuple, resolutions for both dimensions (x, y)
-
(start_raster¶str(left or right), default:None) –If None passed, the extent will be centered on the shape with overlaps left and right depending on individual shape width and raster cell width. If 'left'/'right' passed, extent edges will be matching min/max longitude of shape.
-
(dtype¶Type or dtype, default:None) –The final data type of the boundary values
Returns:
-
Extent–
Source code in geokit/core/extent.py
fitsResolution
¶
Test if calling Extent first around the given unit(s) (at least within an error defined by 'tolerance').
Parameters:
-
(unit¶numeric or tuple) –The unit value(s) to check * If float, a single resolution value is assumed for both X and Y dim * If tuple, resolutions for both dimensions (x, y)
-
(tolerance¶float, default:1e-06) –The tolerance to allow when comparing float values
Returns:
-
Extent–
Examples:
>>> ex = Extent( 100, 100, 300, 500)
>>> ex.fitsResolution(25) # True!
>>> ex.fitsResolution( (25, 10) ) # True!
>>> ex.fitsResolution(33) # False!
>>> ex.fitsResolution( (25, 33) ) # False!
Source code in geokit/core/extent.py
fromGeom
staticmethod
¶
Create extent around a given geometry.
Parameters:
-
(geom¶Geometry) –The geometry from which to extract the extent
Returns:
-
Extent–
Source code in geokit/core/extent.py
fromLocationSet
staticmethod
¶
Create extent around the contents of a LocationSet object.
Parameters:
-
(locs¶LocationSet) –
Returns:
-
Extent–
Source code in geokit/core/extent.py
fromRaster
staticmethod
¶
fromRaster(source)
Create extent around the contents of a raster source.
Parameters:
-
(source¶Anything acceptable by loadRaster()) –The vector datasource to read from
Returns:
-
Extent–
Source code in geokit/core/extent.py
fromTile
staticmethod
¶
Generates an Extent corresponding to tiles used for "slippery maps".
Parameters:
-
(xi¶int) –The tile's X-index - Range depends on zoom value
-
(yi¶int) –The tile's Y-index - Range depends on zoom value
-
(zoom¶int) –The tile's zoom index - Range is between 0 and 18
Returns:
-
Extent–
Source code in geokit/core/extent.py
fromTileAt
staticmethod
¶
Generates an Extent corresponding to tiles used for "slippery maps" at the coordinates ('x','y') in the 'srs' reference system.
Parameters:
-
(x¶float) –The X coordinate to search for a tile around
-
(y¶float) –The Y coordinate to search for a tile around
-
(zoom¶int) –The tile's zoom index - Range is between 0 and 18
-
(srs¶anything acceptable to SRS.loadSRS) –The SRS of the given 'x' & 'y' coordinates
Returns:
-
Extent–
Source code in geokit/core/extent.py
fromVector
staticmethod
¶
Create extent around the contemts of a vector source.
Parameters:
-
(source¶Anything acceptable by loadVector()) –The vector datasource to read from
-
(where¶str; optional, default:None) –An SQL-style filtering string * Can be used to filter the input source according to their attributes * For tips, see "http://www.gdal.org/ogr_sql.html" Ex: where="eye_color='Green' AND IQ>90"
-
(geom¶ogr.Geometry; optional, default:None) –The geometry to search within * All features are extracted which touch this Geometry
Returns:
-
Extent–
Source code in geokit/core/extent.py
fromWKT
staticmethod
¶
Create extent from a Well-Known_Text string.
- Actually the input should be two WKT strings separated by a "|" character
- These correspond to "|
"
Parameters:
-
(wkt¶The string to be processed) – -
(delimiter¶The delimiter which separates the two WKT sections, default:'|') –
Returns:
-
Extent–
Source code in geokit/core/extent.py
from_xXyY
staticmethod
¶
Create an Extent from explicitly defined boundaries.
Parameters:
-
(bounds¶tuple) –The (xMin, xMax, yMin, yMax) values for the extent
-
(srs¶Anything acceptable to geokit.srs.loadSRS(); optional, default:'latlon') –The srs of the input coordinates * If not given, lat/lon coordinates are assumed
Returns:
-
Extent–
Source code in geokit/core/extent.py
inSourceExtent
¶
Tests if the extent box is at least partially contained in the extent-box of the given vector or raster source.
Parameters:
-
(sources¶str) –The sources to test
Source code in geokit/core/extent.py
load
staticmethod
¶
load(source, **kwargs) -> Extent
Attempts to load an Extent from a variety of inputs in the most appropriate manner.
One Extent initializer (.fromXXX) is called depending on the inputs
source is LocationSet -> Extent.fromLocationSet( source )
source is ogr.Geometry -> Extent.fromGeom( source )
source is not a string: -> Extent(*source, **kwargs)
source is a string:
First try: Extent.fromVector(source)
Then try: Extent.fromRaster(source)
If none of the above works, an error is raised
Returns:
-
Extent–
Source code in geokit/core/extent.py
mutateRaster
¶
mutateRaster(
source: load_raster_input,
pixelWidth: numeric | None = None,
pixelHeight: numeric | None = None,
matchContext: bool = False,
warpArgs: dict | None = None,
processor: Callable | None = None,
resampleAlg: Literal[
"near", "bilinear", "cubic", "average"
] = "bilinear",
**mutateArgs,
)
Convenience function for geokit.raster.mutateRaster which automatically warps the raster to the extent's area and srs before mutating.
Note:
If this is called without any arguments except for a source, it serves to clip the raster source around the Extent, therefore performing the same function as Extent.warp(...) on an Extent which has been cast to the source's srs
Parameters:
-
(source¶Anything acceptable to geokit.raster.loadRaster()) –The source to mutate
-
(pixelHeight¶numeric, default:None) –The pixel height (y-resolution) of the output raster
-
(pixelWidth¶numeric, default:None) –The pixel width (x-resolution) of the output raster
-
(matchContext¶bool; optional, default:False) –- If True, Warp to the Extent's boundaries and srs before mutating
- pixelHeight and pixelWidth MUST be provided in this case
- If False, only warp to the Extent's boundaries, but keep its srs and resolution intact
- If True, Warp to the Extent's boundaries and srs before mutating
-
(warpArgs¶dict; optional, default:None) –Arguments to apply to the warping step * See geokit.raster.warp()
-
(processor¶Callable | None, default:None) –The function performing the mutation of the raster's data * The function will take single argument (a 2D numpy.ndarray) * The function must return a numpy.ndarray of the same size as the input * The return type must also be containable within a Float32 (int and boolean is okay) * See example in geokit.raster.mutateRaster for more info
-
(resampleAlg¶str; optional, default:'bilinear') –The resampling algorithm to use while warping * Knowing which option to use can have significant impacts! * Options are: 'near', 'bilinear', 'cubic', 'average'
-
–**kwargs¶All other keyword arguments are passed to geokit.vector.mutateVector
Returns:
-
* If 'output' is None: gdal.Dataset– -
* If 'output' is a string: None–
Source code in geokit/core/extent.py
1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 | |
mutateVector
¶
mutateVector(source, matchContext=False, **kwargs)
Convenience function for geokit.vector.mutateVector which automatically sets 'srs' and 'geom' input to the Extent's srs and geometry.
Note:
If this is called without any arguments except for a source, it serves to clip the vector source around the extent
Parameters:
-
(source¶Anything acceptable to geokit.vector.loadVector()) –The source to clip
-
(matchContext¶bool; optional, default:False) –- If True, transforms all geometries to the Extent's srs before mutating
- If False, the Extent is cast to the source's srs, and all filtering and mutating happens in that context
-
–**kwargs¶All other keyword arguments are passed to geokit.vector.mutateVector
Returns:
-
* If 'output' is None: gdal.Dataset– -
* If 'output' is a string: None–
Source code in geokit/core/extent.py
overlaps
¶
overlaps(extent, referenceSRS=EPSG4326)
Tests if the extent overlaps with another given extent.
Note:
If an optional resolution ('res') is given, the containment value is also dependent on whether or not the given extent fits within the larger extent AND is situated along the given resolution
Parameters:
-
(extent¶Extent) –The Extent object to test for containment
-
–referenceSRS¶The spatial reference frame to do the comparison in * Can be 'self'
Returns:
-
bool–
Source code in geokit/core/extent.py
pad
¶
Pad the extent in all directions.
Parameters:
-
(pad¶float) –The amount to pad in all directions * In units of the extent's srs * Can also accept a negative padding
-
(percent¶bool, default:False) –If True, the padding values are understood to be a percentage of the unpadded extent
Returns:
-
Extent–
Source code in geokit/core/extent.py
rasterMosaic
¶
rasterMosaic(
sources: list[load_raster_input],
resampleAlg: Literal[
"near", "bilinear", "cubic", "average"
] = "near",
_warpKwargs={},
_skipFiltering: bool = False,
)
Create a raster source surrounding the Extent from a collection of other rasters.
Parameters:
-
(sources¶list, or something acceptable to gk.Extent.filterSources) –The sources to add together over the invoking Extent
Returns:
-
* If 'output' is None: gdal.Dataset– -
* If 'output' is a string: None–
Source code in geokit/core/extent.py
rasterize
¶
rasterize(
source, pixelWidth, pixelHeight, strict=True, **kwargs
)
Convenience function for geokit.vector.rasterize() which automatically sets the 'srs' and 'bounds' input.
Note:
When creating an 'in memory' raster vs one which is saved to disk, a slightly different algorithm is used which can sometimes add an extra row of pixels. Be aware of this if you intend to compare value-matricies directly from rasters generated with this function.
Parameters:
-
(source¶str) –The path to the vector file to load
-
(pixelHeight¶numeric; optional) –The pixel height (y-resolution) of the output raster * Only required if this value should be changed
-
(pixelWidth¶numeric; optional) –The pixel width (x-resolution) of the output raster * Only required if this value should be changed
-
(strict¶bool, default:True) –If True, raise an error if trying to rasterize to a pixelWidth and pixelHeight which does not fit into the Extent
-
–**kwargs¶All other keyword arguments are passed on to geokit.raster.warp()
Returns:
-
* If 'output' is None: gdal.Dataset– -
* If 'output' is a string: None–
Source code in geokit/core/extent.py
shift
¶
Shift the extent in the X and/or Y dimensions.
Parameters:
-
(dx¶float, default:0) –The amount to shift in the x dimension * In units of the extent's srs
-
(dy¶float, default:0) –The amount to shift in the y dimension * In units of the extent's srs
Returns:
-
Extent–
Source code in geokit/core/extent.py
subTiles
¶
Generates tile Extents at a given zoom level which encompass the invoking Extent.
Parameters:
-
(zoom¶int) –The zoom level of the expected tile source
-
(asGeom¶bool, default:False) –If True, returns tuple of ogr.Geometries in stead of (xi,yi,zoom) tuples
Returns:
-
Generator of Geometries or (xi,yi,zoom) tuples–
Source code in geokit/core/extent.py
tileBox
¶
tileBox(zoom: int, return_index_box: bool = False)
Determine the tile Extent at a given zoom level which surround the invoked Extent.
Parameters:
-
(zoom¶int) –The zoom level of the expected tile source
-
(return_index_box¶bool, default:False) –If true, also return the index box at the specified zoom level (from self.tileIndexBox)
Returns:
-
if return_index_box is False: geokit.Extent– -
if return_index_box is True: Tuple–- Item 0: geokit.Extent
- Item 1: namedtuple(xi_start, xi_stop, yi_start, yi_stop)
Source code in geokit/core/extent.py
tileIndexBox
¶
tileIndexBox(zoom: int)
Determine the tile indexes at a given zoom level which surround the invoked Extent.
Parameters:
-
(zoom¶int) –The zoom level of the expected tile source
Returns:
-
namedtuple–- xi_start: int - The starting x index
- xi_stop: int - The ending x index
- yi_start: int - The starting y index
- yi_stop: int - The ending y index
Source code in geokit/core/extent.py
tileMosaic
¶
Create a raster source surrounding the Extent from a collection of tiles.
Parameters:
-
(source¶str) –The source to fetch tiles from * Must include indicators for: {z} -> The tile's zoom level {x} -> The tile's x-index {y} -> The tile's y-index * Ex: File on disk : "/path/to/tile/directory/{z}/{x}/{y}/filename.tif" Remote HTTP file : "/vsicurl_streaming/http://path/to/resource/{z}/{x}/{y}/filename.tif" * Find more info at https://gdal.org/user/virtual_file_systems.html
-
(zoom¶int) –The zoom level of the expected tile source
-
(pixelsPerTile¶(int, (int, int))) –The number of pixels found in each tile
-
(workingType¶dtype) –The datatype of the working matrix (should match the raster source)
-
(noData¶numeric) –The value to treat as 'no data'
-
(output¶str) –An optional path for an output raster (.tif) file
Returns:
-
* If 'output' is None: gdal.Dataset– -
* If 'output' is a string: None–
Source code in geokit/core/extent.py
tileSources
¶
Get the tiles sources which contribute to the invoking Extent.
Parameters:
-
(zoom¶int) –The zoom level of the expected tile source
-
(source¶str, default:None) –The source to fetch tiles from * Must include indicators for: {z} -> The tile's zoom level {x} -> The tile's x-index {y} -> The tile's y-index * Ex: File on disk : "/path/to/tile/directory/{z}/{x}/{y}/filename.tif" Remote HTTP file : "/vsicurl_streaming/http://path/to/resource/{z}/{x}/{y}/filename.tif" * Find more info at https://gdal.org/user/virtual_file_systems.html
Yields:
-
if source is given: str– -
if source is not given: (xi,yi,zoom)–
Source code in geokit/core/extent.py
warp
¶
warp(
source: load_raster_input,
pixelWidth,
pixelHeight,
strict=True,
**kwargs,
)
Convenience function for geokit.raster.warp() which automatically sets the 'srs' and 'bounds' input.
Note:
When creating an 'in memory' raster vs one which is saved to disk, a slightly different algorithm is used which can sometimes add an extra row of pixels. Be aware of this if you intend to compare value-matricies directly from rasters generated with this function.
Parameters:
-
(source¶str) –The path to the vector file to load
-
(pixelHeight¶numeric; optional) –The pixel height (y-resolution) of the output raster * Only required if this value should be changed
-
(pixelWidth¶numeric; optional) –The pixel width (x-resolution) of the output raster * Only required if this value should be changed
-
(strict¶bool, default:True) –If True, raise an error if trying to warp to a pixelWidth and pixelHeight which does not fit into the Extent
-
–**kwargs¶All other keyword arguments are passed on to geokit.raster.warp()
Returns:
-
* If 'output' is None: gdal.Dataset– -
* If 'output' is a string: None–