segment-geospatial
segment-geospatial copied to clipboard
SamGeoPredictor Geo_Box
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.
Good suggestion. Custom projection will be supported in the next release.
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')