Skip to content

Commit 5f21004

Browse files
committed
geocode prototype: attempt via resample_spatial
cloudinsar/s1-workflows#20
1 parent 219642f commit 5f21004

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

openeogeotrellis/geopysparkdatacube.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,24 @@ def resample_spatial(
14011401
if projection is not None and CRS.from_user_input(projection).equals(CRS.from_user_input(current_crs_proj4)):
14021402
projection = None
14031403

1404+
if method == "geocode":
1405+
if projection is None:
1406+
raise ProcessParameterInvalidException(
1407+
parameter="projection", process="resample_spatial",
1408+
reason="geocode method requires a projection to be set."
1409+
)
1410+
scala_crs = get_jvm().geopyspark.geotrellis.TileLayer.getCRS(projection).get()
1411+
extent = max_level.layer_metadata.layout_definition.extent
1412+
extent_in_target_projection = GeopysparkDataCube._reproject_extent(
1413+
cube_crs, projection, extent.xmin, extent.ymin, extent.xmax, extent.ymax
1414+
)
1415+
scala_target_extent = get_jvm().geotrellis.vector.Extent(float(extent_in_target_projection.xmin), float(extent_in_target_projection.ymin),
1416+
float(extent_in_target_projection.xmax), float(extent_in_target_projection.ymax))
1417+
return self._apply_to_levels_geotrellis_rdd(lambda rdd,
1418+
level: get_jvm().org.openeo.geotrellis.geocoding.GeoCodingProcess().geocode(
1419+
rdd, scala_target_extent, scala_crs
1420+
))
1421+
14041422
#IF projection is defined, we need to warp
14051423
if projection is not None and resolution==0.0:
14061424
reprojected = self.apply_to_levels(lambda layer: gps.TiledRasterLayer(

0 commit comments

Comments
 (0)