Commit b8887bc1 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

moved GeoArray to a new separate library called 'geoarray', added convenience module;

- added new module 'convenience'

convenience:
- added new submodule 'object_oriented': added function alias_property from GeoArray

geo.projection:
- EPSG2Proj4(): catched case EPSG_code=None
- EPSG2WKT(): catched case EPSG_code=None
- WKT2EPSG(): catched case wkt=''

io.raster.GeoArray:
- moved GeoArray, NoDataMask, CloudMask, BadDataMask, MultiGeoArray to a new separate library called 'geoarray' and added DeprecationWarnings instead

- updated some import statements

- updated __version__
parent eef1b430
......@@ -15,7 +15,7 @@ __all__=[#'compatibility',
'similarity',
'GeoArray']
__version__ = '20170330_01'
__version__ = '20170405_01'
__author__='Daniel Scheffler'
# Validate GDAL version
......
# -*- coding: utf-8 -*-
__author__ = "Daniel Scheffler"
from . import object_oriented
__all__=['object_oriented']
\ No newline at end of file
# -*- coding: utf-8 -*-
__author__='Daniel Scheffler'
def alias_property(key):
return property(
lambda self: getattr(self, key),
lambda self, val: setattr(self, key, val),
lambda self: delattr(self, key))
\ No newline at end of file
......@@ -95,15 +95,21 @@ def isProjectedOrGeographic(prj):
def EPSG2Proj4(EPSG_code):
srs = osr.SpatialReference()
srs.ImportFromEPSG(EPSG_code)
return srs.ExportToProj4()
# type: (int) -> str
if EPSG_code is not None:
srs = osr.SpatialReference()
srs.ImportFromEPSG(EPSG_code)
return srs.ExportToProj4()
else:
return ''
def EPSG2WKT(EPSG_code):
srs = osr.SpatialReference()
srs.ImportFromEPSG(EPSG_code)
return srs.ExportToWkt()
# type: (int) -> str
if EPSG_code is not None:
srs = osr.SpatialReference()
srs.ImportFromEPSG(EPSG_code)
return srs.ExportToWkt()
def WKT2EPSG(wkt, epsg=os.environ['GDAL_DATA'].replace('/gdal', '/proj/epsg')):
......@@ -119,6 +125,8 @@ def WKT2EPSG(wkt, epsg=os.environ['GDAL_DATA'].replace('/gdal', '/proj/epsg')):
if not isinstance(wkt,str):
raise TypeError("'wkt' must be a string. Received %s." %type(wkt))
code = None #default
if not wkt:
return None
p_in = osr.SpatialReference()
s = p_in.ImportFromWkt(wkt)
if s == 5: # invalid WKT
......
......@@ -35,7 +35,7 @@ def raster2polygon(array_or_GeoArray, gt=None, prj=None, DN2extract=1, exact=Tru
:param q: quiet mode (default: False)
:return:
"""
from ... import GeoArray
from geoarray import GeoArray
geoArr = array_or_GeoArray if isinstance(array_or_GeoArray, GeoArray) else GeoArray(array_or_GeoArray, gt, prj)
src_ds = get_GDAL_ds_inmem(geoArr.mask_nodata.astype(np.uint8), geoArr.gt, geoArr.prj)
......
......@@ -136,7 +136,7 @@ def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=N
print('calc_trafo_args')
for i in [src_crs, dst_crs, cols, rows, left, bottom, right, top, out_res]:
print(i, '\n')
from ...io.raster.GeoArray import GeoArray
from geoarray import GeoArray
left, right, bottom, top = GeoArray(ndarray, in_gt, in_prj).box.boundsMap
dst_transform, out_cols, out_rows = rio_calc_transform(
......@@ -212,7 +212,7 @@ def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=N
def warp_GeoArray(geoArr, **kwargs):
ndarray = geoArr[:]
from ... import GeoArray
from geoarray import GeoArray
return GeoArray(*warp_ndarray(ndarray, geoArr.geotransform, geoArr.projection, **kwargs)) # FIXME this does not copy GeoArray attributes
......
This diff is collapsed.
# -*- coding: utf-8 -*-
__author__ = "Daniel Scheffler"
from . import GeoArray
__all__=['GeoArray']
\ No newline at end of file
__author__ = "Daniel Scheffler"
\ No newline at end of file
......@@ -27,7 +27,7 @@ def find_noDataVal(pathIm_or_GeoArray,bandIdx=0,sz=3):
:param bandIdx:
:param sz: window size in which corner pixels are analysed
"""
from .. import GeoArray
from geoarray import GeoArray
geoArr = pathIm_or_GeoArray if isinstance(pathIm_or_GeoArray, GeoArray) else GeoArray(pathIm_or_GeoArray)
get_mean_std = lambda corner_subset: {'mean':np.mean(corner_subset), 'std':np.std(corner_subset)}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment