Skip to content

Commit

Permalink
fixed backward compatibility issue with region mask subsetting
Browse files Browse the repository at this point in the history
  • Loading branch information
jpswinski committed Oct 23, 2024
1 parent 3ddce82 commit fa21388
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions clients/python/sliderule/sliderule.py
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ def toregion(source, tolerance=0.0, cellsize=0.01, n_clusters=1):
"poly": [{"lat": <lat1>, "lon": <lon1> }, ...],
"region_mask": {"data": <geojson file as string>,
"raster": {"data": <geojson file as string>,
"clusters": [[{"lat": <lat1>, "lon": <lon1>}, ...], [{"lat": <lat1>, "lon": <lon1>}, ...]] }
Expand Down Expand Up @@ -1564,7 +1564,7 @@ def toregion(source, tolerance=0.0, cellsize=0.01, n_clusters=1):
"gdf": gdf,
"poly": polygon, # convex hull of polygons
"clusters": clusters, # list of polygon clusters for cmr request
"region_mask": {
"raster": {
"geojson": datafile, # geojson file
"length": len(datafile), # geojson file length
"cellsize": cellsize # units are in crs/projection
Expand Down
2 changes: 1 addition & 1 deletion clients/python/tests/test_geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_atl03(self, init):
region = sliderule.toregion(os.path.join(TESTDIR, testfile))
parms = {
"poly": region["poly"],
"region_mask": region["region_mask"],
"region_mask": region["raster"],
"srt": icesat2.SRT_LAND,
"cnf": icesat2.CNF_SURFACE_HIGH,
"ats": 10.0,
Expand Down
2 changes: 1 addition & 1 deletion clients/python/tests/test_subsetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_rasterize(self, init):
region = sliderule.toregion(os.path.join(TESTDIR, "data/grandmesa.geojson"))
parms = {
"poly": region['poly'],
"region_mask": region['region_mask'],
"region_mask": region['raster'],
"srt": icesat2.SRT_LAND,
"cnf": icesat2.CNF_SURFACE_LOW,
"ats": 20.0,
Expand Down
2 changes: 1 addition & 1 deletion clients/python/utils/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def atl06_no_sample_arcticdem():
def atl03_rasterized_subset():
parms = {
"poly": region['poly'],
"region_mask": region['region_mask'],
"region_mask": region['raster'],
"srt": icesat2.SRT_LAND,
"cnf": icesat2.CNF_SURFACE_LOW,
"ats": 20.0,
Expand Down
2 changes: 1 addition & 1 deletion clients/python/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def initialize_client(args):
region = sliderule.toregion(cfg["region"])
parms["poly"] = region['poly']
if cfg["region_mask"]:
parms["region_mask"] = region['region_mask']
parms["region_mask"] = region['raster']

# Add Ancillary Fields
if len(cfg['atl03_geo_fields']) > 0:
Expand Down
4 changes: 2 additions & 2 deletions docs/rtd/source/user_guide/SlideRule.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ There is no limit to the number of points in the polygon, but note that as the n

One of the outputs of the ``sliderule.toregion`` function is a GeoJSON object that describes the region of interest. It is available under the ``"region_mask"`` element of the returned dictionary.

* ``"region_mask"``: geojson describing region of interest, enables use of rasterized region for subsetting
* ``"raster"``: geojson describing region of interest, enables use of rasterized region for subsetting

When supplied in the parameters sent in the request, the server side software forgoes using the polygon for subsetting operations, and instead builds a raster of the GeoJSON object using the specified cellsize, and then uses that raster image as a mask to determine which points in the source datasets are included in the region of interest.

Expand All @@ -169,7 +169,7 @@ The example code below shows how this option can be enabled and used (note, the
region = sliderule.toregion('examples/grandmesa.geojson', cellsize=0.02)
parms = {
"poly": region['poly'],
"region_mask": region['region_mask']
"region_mask": region['raster']
}
5.3 Time
Expand Down
2 changes: 2 additions & 0 deletions packages/core/RequestFields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ RequestFields::RequestFields(lua_State* L, uint64_t key_space, const std::initia
#ifdef __geo__
{GeoFields::PARMS, &samplers},
#endif
// deprecated
{"raster", &regionMask},
})
{
// set key space
Expand Down

0 comments on commit fa21388

Please sign in to comment.