Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

subset_spatial op should work with valid polygons #507

Closed
forman opened this issue Jan 12, 2018 · 4 comments
Closed

subset_spatial op should work with valid polygons #507

forman opened this issue Jan 12, 2018 · 4 comments
Assignees
Milestone

Comments

@forman
Copy link
Member

forman commented Jan 12, 2018

Expected behavior

subset_spatial should work with all valid polygons regardless of their actual spatial extent.

Actual behavior

If I invoke subset_spatial with ds:

esacci.2010.CLOUD.mon.L3C.CLD_PRODUCTS.multi-sensor.multi-platform.ATSR2-AATSR.2-0.r1

and region WKT defining the following, rather small polygon from ESA CCI Glaciers dataset:

"POLYGON ((-53.57632337894747 67.10673414497307, -53.57626614693088 67.10619646968784, -53.575575794544775 67.10620761160448, -53.57551858059012 67.10566993596773, -53.57482824280637 67.1056810746106, -53.57479964451354 67.10541223662418, -53.574109313685 67.10542337213865, -53.57408072373028 67.1051545339918, -53.572009750037914 67.10518792220135, -53.571981183714094 67.10491908360363, -53.56991022674504 67.10495244453077, -53.569881684051325 67.10468360548275, -53.56919137132743 67.10469471968085, -53.56921990637478 67.10496355887388, -53.56852958531452 67.1049746702339, -53.56855811340513 67.10524350955681, -53.5671774539219 67.10526572361778, -53.56712042901686 67.10472804437723, -53.56781074381009 67.10471693912801, -53.56778222474533 67.10444809962996, -53.568472531202524 67.10443699154277, -53.56838695520772 67.10363047339246, -53.569077238037295 67.10361936275717, -53.56904870643948 67.10335052348844, -53.56973898093374 67.10333941001542, -53.569710442380476 67.10307057087647, -53.57040070853927 67.10305945456565, -53.570372163030925 67.1027906155566, -53.571062420854446 67.1027794964081, -53.57103386839113 67.10251065752905, -53.57241436667729 67.10248841057422, -53.57238579961488 67.10221957197018, -53.57445651892933 67.10218617960403, -53.57442792962403 67.10191734142042, -53.575808390422566 67.1018950652207, -53.575779786519966 67.10162622731258, -53.57785044959804 67.10159279108024, -53.57782182345493 67.10132395359305, -53.57920224675896 67.1013016481501, -53.57917360602069 67.10103281093878, -53.58262461394139 67.10097699586724, -53.58259593567808 67.10070815936882, -53.58604688804876 67.10065227046755, -53.58607560452903 67.10092110623687, -53.5867658005646 67.10090991936381, -53.58679452538237 67.10117875497203, -53.587484728366974 67.10116756497067, -53.5874559959055 67.10089872950844, -53.588146190552095 67.10088753667073, -53.58805997440654 67.10008103063063, -53.58875014542906 67.10006983524875, -53.58877889109226 67.10033867046462, -53.589469069062815 67.10032747195446, -53.589555333151964 67.10113397707244, -53.58817493065678 67.10115637198695, -53.588203671456405 67.10142520728797, -53.58751346152288 67.10143640041765, -53.58754219537351 67.10170523584945, -53.58685197710164 67.10171642614279, -53.586880704002844 67.10198526170532, -53.58619047739239 67.10199644916216, -53.58621919734403 67.10226528485546, -53.58414849041439 67.10229882976869, -53.58417718812709 67.1025676658843, -53.58348694345156 67.10257884170274, -53.583515634213306 67.10284767794896, -53.582825381199484 67.1028588509306, -53.58288274951425 67.10339652366906, -53.58357301781828 67.10338535039598, -53.583601710661156 67.10365418659654, -53.585672534345264 67.10362064844344, -53.58570125081805 67.10388948419128, -53.58639153163644 67.10387829869555, -53.586420256449124 67.10414713428231, -53.585729967985365 67.10415831992393, -53.58575868584685 67.10442715564143, -53.58506838904291 67.10443833844619, -53.58509709995305 67.10470717429435, -53.58371648897093 67.10472953124703, -53.58368779335269 67.10446069510724, -53.582307194887086 67.10448303983686, -53.58233587521329 67.1047518762682, -53.58164556729428 67.10476304430442, -53.58167424066754 67.10503188086624, -53.580983924408926 67.10504304606525, -53.58101259082931 67.10531188275765, -53.58032226623112 67.1053230451192, -53.580350925698 67.10559188194198, -53.579660592760035 67.10560304146625, -53.57971789847896 67.10614071535736, -53.579027549554304 67.1061518721897, -53.57908484274993 67.10668954631129, -53.57839447783797 67.10670070045153, -53.57842311782737 67.10696953763514, -53.57704237063045 67.10699183725701, -53.57701374593649 67.10672299978249, -53.57632337894747 67.10673414497307, -53.57632337894747 67.10673414497307))"

I get IndexError: index 1 is out of bounds for axis 0 with size 0:

Cate Desktop, version 1.0.1-dev.1

set_workspace_resource() call raised exception: "index 1 is out of bounds for axis 0 with size 0"

An error (code 20) occurred in Cate Core:

Traceback (most recent call last):
  File "D:\Projects\cate\cate\util\web\jsonrpchandler.py", line 192, in send_service_method_result
    result = future.result()
  File "D:\Miniconda3\envs\cate-env\lib\concurrent\futures\_base.py", line 398, in result
    return self.__get_result()
  File "D:\Miniconda3\envs\cate-env\lib\concurrent\futures\_base.py", line 357, in __get_result
    raise self._exception
  File "D:\Miniconda3\envs\cate-env\lib\concurrent\futures\thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\Projects\cate\cate\util\web\jsonrpchandler.py", line 269, in call_service_method
    result = method(*method_params, monitor=monitor)
  File "D:\Projects\cate\cate\webapi\websocket.py", line 284, in set_workspace_resource
    monitor=monitor)
  File "D:\Projects\cate\cate\core\wsmanag.py", line 323, in set_workspace_resource
    workspace.execute_workflow(res_name=res_name, monitor=monitor)
  File "D:\Projects\cate\cate\core\workspace.py", line 600, in execute_workflow
    self.workflow.invoke_steps(steps, context=self._new_context(), monitor=monitor)
  File "D:\Projects\cate\cate\core\workflow.py", line 632, in invoke_steps
    step.invoke(context=context, monitor=monitor.child(work=1))
  File "D:\Projects\cate\cate\core\workflow.py", line 318, in invoke
    self._invoke_impl(_new_context(context, step=self), monitor=monitor)
  File "D:\Projects\cate\cate\core\workflow.py", line 980, in _invoke_impl
    return_value = self._op(monitor=monitor, **input_values)
  File "D:\Projects\cate\cate\core\op.py", line 215, in __call__
    return_value = self._wrapped_op(**input_values)
  File "D:\Projects\cate\cate\ops\subset.py", line 57, in subset_spatial
    return adjust_spatial_attrs(subset_spatial_impl(ds, region, mask))
  File "D:\Projects\cate\cate\core\op.py", line 215, in __call__
    return_value = self._wrapped_op(**input_values)
  File "D:\Projects\cate\cate\ops\normalize.py", line 78, in adjust_spatial_attrs
    return adjust_spatial_attrs_impl(ds)
  File "D:\Projects\cate\cate\util\opimpl.py", line 176, in adjust_spatial_attrs_impl
    geoattrs = _get_spatial_props(ds, dim)
  File "D:\Projects\cate\cate\util\opimpl.py", line 285, in _get_spatial_props
    dim_res = abs(ds[dim].values[1] - ds[dim].values[0])
IndexError: index 1 is out of bounds for axis 0 with size 0

Specifications

Cate 1.0.1.dev1

@JanisGailis
Copy link
Member

@forman Should we select all pixels 'touched' by such a polygon, or treat it as a 'point' coordinate and select nearest of each dimension?

@JanisGailis
Copy link
Member

.. Or let the user choose

@forman
Copy link
Member Author

forman commented Mar 12, 2018

@JanisGailis I'd select any cell whose area is inside or intersects polygon.

@forman
Copy link
Member Author

forman commented Mar 12, 2018

Currently, only the cells completely inside the region are selected. The operation also fails if only a single cell is selected that way. But single cell selection should of course be valid and produce a "normal" dataset subset (see also #555).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants