segment-geospatial icon indicating copy to clipboard operation
segment-geospatial copied to clipboard

SamGeoPredictor Geo_Box

Open BjornNyberg opened this issue 2 years ago • 1 comments

Description

The geo_box parameter of the SamGeoPredictor.predict function seems to be hard coded to EPSG:4326 here. It would be useful to allow for different projections.

In addition, this also causes problem when setting geo_box to None and using the masks_to_geotiff function considering width, height, geo_transform and crs are not previously defined.

BjornNyberg avatar May 07 '23 10:05 BjornNyberg

Good suggestion. Custom projection will be supported in the next release.

giswqs avatar May 07 '23 18:05 giswqs

The feature has been implemented. See the example below. Note that the SamGeoPredictor class will be deprecated. Use the SamGeo class instead.

https://samgeo.gishub.org/examples/input_prompts/

box = [-51.2552, -22.1761, -51.2538, -22.175]
# box = samgeo.bbox_to_xy('satellite.tif', box, "epsg:4326")  # optional step
sam = SamGeo(
    model_type="vit_h",
    checkpoint=checkpoint,
    automatic=False,
    sam_kwargs=None,
)
sam.predict(point_coords, point_labels, box=box, point_crs="EPSG:4326", output='mask.tif')

giswqs avatar May 13 '23 04:05 giswqs