ellipsis 3.1.21__py3-none-any.whl → 3.1.23__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ellipsis might be problematic. Click here for more details.

ellipsis/__init__.py CHANGED
@@ -7,4 +7,4 @@ from ellipsis import path
7
7
  from ellipsis import view
8
8
  from ellipsis import util
9
9
 
10
- __version__ = '3.1.21'
10
+ __version__ = '3.1.23'
ellipsis/apiManager.py CHANGED
@@ -24,7 +24,7 @@ def filterNone(body, toString= False):
24
24
  params[k] = body[k]
25
25
  return params
26
26
 
27
- def get(url, body = None, token = None, crash = True):
27
+ def get(url, body = None, token = None, crash = True, parseJson = True):
28
28
  if body == None:
29
29
  body = {'token': token}
30
30
  else:
@@ -40,7 +40,7 @@ def get(url, body = None, token = None, crash = True):
40
40
 
41
41
  url = url + '?' + body
42
42
 
43
- r = call( method = requests.get, url = url, body = None, token = token, crash = crash )
43
+ r = call( method = requests.get, url = url, body = None, token = token, crash = crash, parseJson = parseJson )
44
44
 
45
45
 
46
46
  return r
@@ -66,7 +66,7 @@ def delete(url, body, token = None):
66
66
  return r
67
67
 
68
68
 
69
- def call(method, url, body = None, token = None, crash = True):
69
+ def call(method, url, body = None, token = None, crash = True, parseJson = True):
70
70
  body = filterNone(body)
71
71
  if type(body) != type(None) and type(body) != type({}):
72
72
  raise ValueError(
@@ -85,10 +85,12 @@ def call(method, url, body = None, token = None, crash = True):
85
85
  if crash:
86
86
  if r.status_code != 200:
87
87
  raise ValueError(r.text)
88
- try:
89
- r = r.json()
90
- except:
91
- r = r.text
88
+
89
+ if parseJson:
90
+ try:
91
+ r = r.json()
92
+ except:
93
+ r = r.text
92
94
 
93
95
  return r
94
96
  else:
@@ -11,6 +11,7 @@ from ellipsis.path.raster.timestamp.root import trash
11
11
  from ellipsis.path.raster.timestamp.root import recover
12
12
  from ellipsis.path.raster.timestamp.root import getSampledRaster
13
13
  from ellipsis.path.raster.timestamp.root import getValuesAlongLine
14
+ from ellipsis.path.raster.timestamp.root import contour
14
15
 
15
16
  from ellipsis.path.raster.timestamp import file
16
17
  from ellipsis.path.raster.timestamp import order
@@ -17,13 +17,16 @@ import tifffile
17
17
  from PIL import Image
18
18
  import geopandas as gpd
19
19
  import datetime
20
+ import pandas as pd
20
21
  import time
21
22
  import requests
23
+ from skimage.measure import find_contours
24
+ from shapely.geometry import Point, LineString
22
25
 
23
26
  def getDownsampledRaster(pathId, timestampId, extent, width, height, epsg=3857, style = None, token = None):
24
27
  return getSampledRaster(pathId, timestampId, extent, width, height, epsg, style, token)
25
28
 
26
- def getSampledRaster(pathId, timestampId, extent, width, height, epsg=3857, style = None, token = None):
29
+ def getSampledRaster(pathId, timestampId, extent, width, height, epsg=4326, style = None, token = None):
27
30
  bounds = extent
28
31
  token = sanitize.validString('token', token, False)
29
32
  pathId = sanitize.validUuid('pathId', pathId, True)
@@ -32,9 +35,7 @@ def getSampledRaster(pathId, timestampId, extent, width, height, epsg=3857, styl
32
35
  style = sanitize.validObject('style', style, False)
33
36
  epsg = sanitize.validInt('epsg', epsg, True)
34
37
  body = {'pathId':pathId, 'timestampId':timestampId, 'extent':bounds, 'width':width, 'height':height, 'style':style, 'epsg':epsg}
35
- r = apiManager.get('/path/' + pathId + '/raster/timestamp/' + timestampId + '/rasterByExtent', body, token, crash = False)
36
- if r.status_code != 200:
37
- raise ValueError(r.message)
38
+ r = apiManager.get('/path/' + pathId + '/raster/timestamp/' + timestampId + '/rasterByExtent', body, token, crash = True, parseJson = False)
38
39
 
39
40
 
40
41
  if type(style) == type(None):
@@ -56,18 +57,88 @@ def getSampledRaster(pathId, timestampId, extent, width, height, epsg=3857, styl
56
57
  return {'raster': r, 'transform':trans, 'extent': {'xMin' : xMin, 'yMin': yMin, 'xMax': xMax, 'yMax': yMax}, 'crs':"EPSG:" + str(epsg) }
57
58
 
58
59
 
60
+ def contour(pathId, timestampId, extent, interval = None, intervals = None, epsg = 4326, bandNumber = 1, token = None):
61
+ pathId = sanitize.validUuid('pathId', pathId, True)
62
+ timestampId = sanitize.validUuid('timestampId', timestampId, True)
63
+ token = sanitize.validString('token', token, False)
64
+ epsg = sanitize.validInt('epsg', epsg, True)
65
+ extent = sanitize.validBounds('extent', extent, True)
66
+
67
+
68
+ res = getActualExtent(extent['xMin'], extent['xMax'], extent['yMin'], extent['yMax'], 'EPSG:' + str(epsg))
69
+ if res['status'] == '400':
70
+ raise ValueError('Invalid epsg and extent combination')
71
+
72
+ bounds = res['message']
73
+
74
+ xMinWeb = bounds['xMin']
75
+ yMinWeb = bounds['yMin']
76
+ xMaxWeb = bounds['xMax']
77
+ yMaxWeb = bounds['yMax']
78
+
79
+ extentWeb = {'xMin': xMinWeb, 'xMax':xMaxWeb, 'yMin':yMinWeb, 'yMax':yMaxWeb}
80
+ size = 1000
81
+ r = getSampledRaster(pathId = pathId, timestampId = timestampId, extent = extentWeb, width = size, height = size, epsg=3857, token = token)
82
+ raster = r['raster']
83
+
84
+ if bandNumber >= raster.shape[0]:
85
+ raise ValueError('BandNumber too high. Raster only has ' + str(raster.shape[0]) + 'bands.')
86
+
87
+
88
+
89
+ if type(intervals) == type(None):
90
+ minVal = np.min(raster[bandNumber-1, raster[-1,:,:] == 1])
91
+ maxVal = np.max(raster[bandNumber-1, raster[-1,:,:] == 1])
92
+
93
+
94
+ cont = minVal + interval
95
+
96
+ conts = []
97
+ while cont < maxVal:
98
+ conts = conts + [cont]
99
+ cont = cont + interval
100
+ else:
101
+ conts = intervals
102
+
103
+
104
+ Lx = (xMaxWeb - xMinWeb)/size
105
+ Ly = (yMaxWeb - yMinWeb)/size
106
+
107
+ sh_total = []
108
+ for cont in conts:
109
+
110
+ lines = find_contours(raster[bandNumber-1,:,:], mask=raster[-1,:,:] == 1, level = cont)
111
+
112
+ newLines = []
113
+ line = lines[0]
114
+ for line in lines:
115
+ newLine = LineString([ Point( xMinWeb + x[0] * Lx , yMinWeb + x[1] * Ly ) for x in line])
116
+ newLines = newLines + [newLine]
117
+
118
+ sh = gpd.GeoDataFrame({'geometry': newLines, 'label': (np.repeat(cont, len(newLines)))} )
119
+
120
+ sh_total = sh_total + [sh]
121
+
122
+ sh = pd.concat(sh_total)
123
+ sh.crs = 'EPSG:3857'
124
+ sh = sh.to_crs('EPSG:' + str(epsg))
125
+
126
+ return sh
127
+
128
+
59
129
  def getValuesAlongLine(pathId, timestampId, line, token = None, epsg = 4326):
60
130
  pathId = sanitize.validUuid('pathId', pathId, True)
61
131
  timestampId = sanitize.validUuid('timestampId', timestampId, True)
62
132
  token = sanitize.validString('token', token, False)
63
133
  line = sanitize.validShapely('line', line, True)
134
+ epsg = sanitize.validInt('epsg', epsg, True)
64
135
 
65
136
  if line.type != 'LineString':
66
137
  raise ValueError('line must be a shapely lineString')
67
138
 
68
139
  temp = gpd.GeoDataFrame({'geometry':[line]})
69
140
  temp.crs = 'EPSG:' + str(epsg)
70
- temp = temp.to_crs('EPSG:4326')
141
+ temp = temp.to_crs('EPSG:3857')
71
142
  line = temp['geometry'].values[0]
72
143
  line = list(line.coords)
73
144
 
@@ -79,20 +150,32 @@ def getValuesAlongLine(pathId, timestampId, line, token = None, epsg = 4326):
79
150
  xMax = max(x_of_line)
80
151
  yMin = min(y_of_line)
81
152
  yMax = max(y_of_line)
82
-
153
+
154
+ d = (xMax - xMin) * 0.1
155
+ xMax = xMax + d
156
+ xMin = xMin -d
157
+ d = (yMax - yMin) * 0.1
158
+ yMax = yMax + d
159
+ yMin = yMin -d
160
+
161
+
162
+
83
163
  #now we retrieve the needed raster we use epsg = 4326 but we can use other coordinates as well
84
164
  extent = {'xMin': xMin, 'xMax':xMax, 'yMin':yMin, 'yMax':yMax}
85
165
 
86
166
  size = 1000
87
- r = getSampledRaster(pathId = pathId, timestampId = timestampId, extent = extent, width = size, height = size, epsg=4326)
167
+ r = getSampledRaster(pathId = pathId, timestampId = timestampId, extent = extent, width = size, height = size, epsg=3857, token = token)
88
168
  raster = r['raster']
89
169
 
90
170
  memfile = MemoryFile()
91
171
  dataset = memfile.open( driver='GTiff', dtype='float32', height=size, width=size, count = raster.shape[0], crs= r['crs'], transform=r['transform'])
92
172
  dataset.write(raster)
93
173
 
174
+
175
+
94
176
  values = list(dataset.sample(line))
95
177
 
178
+ memfile.close()
96
179
  return values
97
180
 
98
181
 
@@ -1 +1 @@
1
- from ellipsis.path.usage.root import getActiveUsers, getUsage, getAggregatedUsage
1
+ from ellipsis.path.usage.root import getActiveUsers, getUsage, getAggregatedUsage, getUserUsage
@@ -1,5 +1,7 @@
1
1
  from ellipsis import apiManager, sanitize
2
2
  from ellipsis.util.root import recurse
3
+ from ellipsis.util.root import dateToString
4
+
3
5
 
4
6
 
5
7
  def getActiveUsers(pathId, token, listAll = True, pageStart = None):
@@ -36,3 +38,11 @@ def getAggregatedUsage(pathId, loggedIn, token):
36
38
 
37
39
 
38
40
  return apiManager.get('/path/' + pathId + '/usage/processingUnits', {'loggedIn': loggedIn}, token)
41
+
42
+
43
+ def getUserUsage(userId, date, token):
44
+ token = sanitize.validString('token', token, True)
45
+ userId = sanitize.validUuid('userId', userId, True)
46
+ date = sanitize.validDate('date', date, True)
47
+
48
+ return apiManager.get('/path/usage/user/' + userId + '/processingUnits', {'date':date}, token)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ellipsis
3
- Version: 3.1.21
3
+ Version: 3.1.23
4
4
  Summary: Package to interact with the Ellipsis API
5
5
  Home-page: https://github.com/ellipsis-drive-internal/python-package
6
6
  Author: Daniel van der Maas
@@ -1,5 +1,5 @@
1
- ellipsis/__init__.py,sha256=tjFP254ZzDDr2at_-Ydnm6TF9cnvMIkGV-Knv28J2so,233
2
- ellipsis/apiManager.py,sha256=c2BkdLQb2czsx4FOj4WjnYRqmbEV2LKGuhpcBrbdhdw,4904
1
+ ellipsis/__init__.py,sha256=-KUrZ0PSjYlB_d1bJ47n4O7kEFzdm05nv3icVZGcDGM,233
2
+ ellipsis/apiManager.py,sha256=W0kT0KxgQE7gUEp5PhNVphJDSQxk8atP8uKj41msg9Y,5014
3
3
  ellipsis/sanitize.py,sha256=T5FawJRZ2eqGv0itiMkZ1fuJpahsSyhBMFty9cG-wwA,10194
4
4
  ellipsis/account/__init__.py,sha256=K40DMBaUDSxt3rO2WZv63Wmpfy49ocqBxvWqyIYHR24,92
5
5
  ellipsis/account/root.py,sha256=29IGUJavfXC9wLC_Fxzy1cdCbnP4QPmbYlE-H6VP088,1285
@@ -21,15 +21,15 @@ ellipsis/path/raster/__init__.py,sha256=xWEsdpQxsqnwSdRqmZujS3pEUAmemHmUCtMKCaWL
21
21
  ellipsis/path/raster/root.py,sha256=-y0SEukHEYUDvyJyDI1x7gtcDm-Wum_Ze7ekSYJr6O4,1749
22
22
  ellipsis/path/raster/style/__init__.py,sha256=mxlqVtSd2dsKai3DAVQjtNsh2KnTrZVyF8loRwUNT7E,61
23
23
  ellipsis/path/raster/style/root.py,sha256=D01E-z2F1OrbLJgUF48cttH6chM0K94Vk2dhwENg8OY,1547
24
- ellipsis/path/raster/timestamp/__init__.py,sha256=x7uCEnVHmNFS686Iaw8bD0zv6lfQpEdYx6RZpcnQ5-4,859
25
- ellipsis/path/raster/timestamp/root.py,sha256=Qh0sPqV1FXuMzIjEsBoXADZJXWOBIz1j5_We6ljnfl4,15715
24
+ ellipsis/path/raster/timestamp/__init__.py,sha256=_2rt8Kcpu-Zj7FwyzmvAbbxoENv-R5dNbjRbJdnjpz4,915
25
+ ellipsis/path/raster/timestamp/root.py,sha256=961ZuHDV6nJElLrPICtnXCWlQRGTCoxTTvBNHuzPCHA,18317
26
26
  ellipsis/path/raster/timestamp/util.py,sha256=eupFFSBp5CaTDIRg6DYnZnfWY61h81JZ7c15NdJ-j5E,2580
27
27
  ellipsis/path/raster/timestamp/file/__init__.py,sha256=Ln9_dQ4-PMwb5VP--Qh09IV5zmr-47RShpe0-f_NVh4,97
28
28
  ellipsis/path/raster/timestamp/file/root.py,sha256=T-vcD5o257-8t2M1l-c7WUxpq4ZmSApWFLqFhIL5Kb0,3920
29
29
  ellipsis/path/raster/timestamp/order/__init__.py,sha256=4YEK4XW9TM-HsjoFlFeyGMtI3OKX2VCXfb4NsTsugBo,74
30
30
  ellipsis/path/raster/timestamp/order/root.py,sha256=zWcfI_q9KlfevzyvwWY8ni27KCvOyAiaJvohVfasjXg,1176
31
- ellipsis/path/usage/__init__.py,sha256=TfHolUnnQFh7VuE9eG3-DGEc5ctyj4PzPxDNVgoU5tg,82
32
- ellipsis/path/usage/root.py,sha256=6RkKxEFrbKckeTqXtAfc7W3O784YH3dtxzospEVkxiE,1215
31
+ ellipsis/path/usage/__init__.py,sha256=2BHmLV9soOYDhyQFH2B86bBjmWXGsfuX4KneEBDo6O4,96
32
+ ellipsis/path/usage/root.py,sha256=NAZCDHXHcN6kodU3EpbNwlWM3It60ewsGXt4LJ_enG0,1566
33
33
  ellipsis/path/vector/__init__.py,sha256=hIbJlp1kO_k2AhaFagUfd_We7taOBdD3K9n6lheWpYI,228
34
34
  ellipsis/path/vector/root.py,sha256=dGW6md_Hxu8y0IZ2sX8FJuH8aEy-qPY5IpsyMKKhtgo,984
35
35
  ellipsis/path/vector/featureProperty/__init__.py,sha256=-S6G0Sq66m8HVTg4bCp33fsUzYq-2hPueg5BotSpk2Q,81
@@ -54,8 +54,8 @@ ellipsis/util/__init__.py,sha256=A3BEF6O5qTRU90yoaZDI-xF8R1WAFuh1fdxwWKd1Uvw,628
54
54
  ellipsis/util/root.py,sha256=c3_gKqSqADzR8CypFsmxBOn1MCcbYwCUiqedQq8AAXI,19604
55
55
  ellipsis/view/__init__.py,sha256=91KyJzbSvwSP9hvJQyo1LLM48b5NixLz6G40I9h6sdY,67
56
56
  ellipsis/view/root.py,sha256=6actiBwIsM0f7sJhQl_U4j-C6Dhe0z5XGGtxIOIKdY8,1726
57
- ellipsis-3.1.21.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
58
- ellipsis-3.1.21.dist-info/METADATA,sha256=BYGD9x1rGzB6U8vjp5aqvol8Rfz9G7wK2cTzoWBOH2g,1798
59
- ellipsis-3.1.21.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
60
- ellipsis-3.1.21.dist-info/top_level.txt,sha256=eG8gfaVDyprKdb-dsGSh_lFMSa3DiZCsJFqze239RjA,9
61
- ellipsis-3.1.21.dist-info/RECORD,,
57
+ ellipsis-3.1.23.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
58
+ ellipsis-3.1.23.dist-info/METADATA,sha256=GXMDl4g-84NPRs6M4S3w1vnUXkJMxtkPmkeAO6KcZbc,1798
59
+ ellipsis-3.1.23.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
60
+ ellipsis-3.1.23.dist-info/top_level.txt,sha256=eG8gfaVDyprKdb-dsGSh_lFMSa3DiZCsJFqze239RjA,9
61
+ ellipsis-3.1.23.dist-info/RECORD,,