geowatch.tasks.poly_from_point.predict module¶
Primary entrypoint to convert polygons to points.
CommandLine
python -m geowatch.tasks.poly_from_point.predict --help
CommandLine
xdoctest -m geowatch.tasks.poly_from_point.predict __doc__:0
Example
>>> from geowatch.tasks.poly_from_point.predict import * # NOQA
>>> import geowatch
>>> from geowatch.geoannots import geomodels
>>> import ubelt as ub
>>> dpath = ub.Path.appdir('geowatch/poly_from_point/doc').ensuredir()
>>> region_model, site_models = geomodels.RegionModel.random(with_sites=True)
>>> region_models = [region_model]
>>> point_model = site_models.to_point_model()
>>> print(f'Number of region models: {len(region_models)}')
>>> print(f'Number of site models: {len(site_models)}')
>>> # It is also easy to convert these models to geopandas
>>> region_model = region_models[0]
>>> gdf = region_model.pandas()
>>> print(gdf)
>>> filepath_to_points = dpath / 'points.geojson'
>>> filepath_to_points.write_text(point_model.dumps())
>>> filepath_to_region = dpath / 'region.geojson'
>>> filepath_to_region.write_text(region_model.dumps())
>>> filepath_output = dpath / 'output_region.geojson'
>>> gpd.read_file(filepath_to_points) # check
>>> kwargs = dict(
>>> filepath_to_points=filepath_to_points,
>>> filepath_to_region=filepath_to_region,
>>> filepath_output=filepath_output,
>>> )
>>> cmdline = 0
>>> PolyFromPointCLI.main(cmdline=cmdline, **kwargs)
# To Viz import xdev viz_fpath = dpath / ‘viz.png’ ub.cmd(f’geowatch draw_region {filepath_output} –fpath {viz_fpath}’, verbose=3) xdev.startfile(viz_fpath)
- class geowatch.tasks.poly_from_point.predict.PolyFromPointCLI(*args, **kwargs)[source]¶
Bases:
DataConfig
Convert points to polygons based on trimaping or SAM (trimap seems to work better, SAM could be improved).
Example
DVC_DATA_DPATH=$(geowatch_dvc –tags=’phase3_data’ –hardware=hdd) DVC_EXPT_DPATH=$(geowatch_dvc –tags=’phase3_expt’ –hardware=auto) echo “$DVC_DATA_DPATH” echo “$DVC_EXPT_DPATH”
DVC_DATA_DPATH=$(geowatch_dvc –tags=’phase3_data’ –hardware=ssd) python -m geowatch.tasks.poly_from_point.predict
–method ‘ellipse’ –filepath_output KR_R001-genpoints.geojson –region_id KR_R001 –size_prior “20x20@10mGSD” –ignore_buffer “10@10mGSD” –filepath_to_images None –filepath_to_points “$DVC_DATA_DPATH/submodules/annotations/supplemental_data/point_based_annotations.geojson” –filepath_to_region “$DVC_DATA_DPATH/annotations/drop8/region_models/KR_R001.geojson”
geowatch draw_region KR_R001-genpoints.geojson –fpath KR_R001-genpoints.png
Valid options: []
- Parameters:
*args – positional arguments for this data config
**kwargs – keyword arguments for this data config
- default = {'filepath_output': <Value('output_region.geojson')>, 'filepath_to_images': <Value(None)>, 'filepath_to_points': <Value(None)>, 'filepath_to_region': <Value(None)>, 'filepath_to_sam': <Value(None)>, 'ignore_buffer': <Value(None)>, 'method': <Value('ellipse')>, 'region_id': <Value(None)>, 'size_prior': <Value('20.06063 x 20.0141229 @ 10mGSD')>, 'threshold': <Value(0.45)>, 'time_prior': <Value('1 year')>}¶
- geowatch.tasks.poly_from_point.predict.convert_polygons_to_region_model(utm_polygons, main_region_header, points_gdf_utm, points_gdf_crs84, config)[source]¶
Given polygons in a CRS, convert them to CRS84 polygon-based RegionModels.
- geowatch.tasks.poly_from_point.predict.get_vidspace_info(video_obj)[source]¶
Extract information about the videospace of a kwcoco video object