geovalidate.PointSampler¶
-
class geovalidate.PointSampler(n_samples=
100, quasi_random=None, random_state=None)[source]¶ Sample points uniformly at random inside a Shapely geometry.
Mimics the sklearn model-selection estimator API: hyperparameters are set in
__init__andsample()acts as the primary callable.- Parameters:¶
Examples
>>> from shapely.geometry import box >>> from geovalidate import PointSampler >>> pts = PointSampler(n_samples=200, random_state=0).sample(box(0, 0, 1, 1)) >>> len(pts) 200-
__init__(n_samples=
100, quasi_random=None, random_state=None)[source]¶
Methods
__init__([n_samples, quasi_random, random_state])Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
sample(geometry[, n_samples])Sample n_samples points uniformly inside geometry.
set_params(**params)Set the parameters of this estimator.
- get_metadata_routing()[source]¶
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:¶
routing – A
MetadataRequestencapsulating routing information.- Return type:¶
MetadataRequest
-
sample(geometry, n_samples=
None)[source]¶ Sample n_samples points uniformly inside geometry.
- Parameters:¶
- geometry : shapely.Geometry | geopandas.GeoSeries | geopandas.GeoDataFrame¶
Region to sample from. A GeoSeries / GeoDataFrame is dissolved into a single union before sampling. CRS is inferred automatically.
- n_samples : int, optional¶
Overrides
self.n_samplesfor this call.
- Returns:¶
Single-column
geometryGeoDataFrame of sampled Points.- Return type:¶