GeoJSONVectorSource#

class GeoJSONVectorSource[source]#

Bases: VectorSource

A VectorSource for reading GeoJSON files.

Attributes

bbox

Bounding box applied to the source data.

extent

Envelope of union of all geoms.

__init__(uris: str | list[str], crs_transformer: CRSTransformer, vector_transformers: list['VectorTransformer'] = [], bbox: rastervision.core.box.Box | None = None)[source]#

Constructor.

Parameters:
  • uris (str | list[str]) – URI(s) of the GeoJSON file(s).

  • crs_transformer (CRSTransformer) – A CRSTransformer to convert between map and pixel coords. Normally this is obtained from a RasterSource.

  • vector_transformers (list['VectorTransformer']) – VectorTransformers for transforming geometries. Defaults to [].

  • bbox (rastervision.core.box.Box | None) – User-specified crop of the extent. If None, the full extent available in the source file is used.

Methods

__init__(uris, crs_transformer[, ...])

Constructor.

get_dataframe([window, to_map_coords])

Return geometries as a GeoDataFrame.

get_geojson([window, to_map_coords])

Return transformed GeoJSON.

get_geoms([window, to_map_coords])

Returns all geometries in the transformed GeoJSON as Shapely geoms.

__init__(uris: str | list[str], crs_transformer: CRSTransformer, vector_transformers: list['VectorTransformer'] = [], bbox: rastervision.core.box.Box | None = None)[source]#

Constructor.

Parameters:
  • uris (str | list[str]) – URI(s) of the GeoJSON file(s).

  • crs_transformer (CRSTransformer) – A CRSTransformer to convert between map and pixel coords. Normally this is obtained from a RasterSource.

  • vector_transformers (list['VectorTransformer']) – VectorTransformers for transforming geometries. Defaults to [].

  • bbox (rastervision.core.box.Box | None) – User-specified crop of the extent. If None, the full extent available in the source file is used.

get_dataframe(window: rastervision.core.box.Box | None = None, to_map_coords: bool = False) GeoDataFrame#

Return geometries as a GeoDataFrame.

Parameters:
  • window (Box | None) – If specified, return only the features that intersect with this window; otherwise, return all features. Defaults to None.

  • to_map_coords (bool) – If true, will return GeoJSON in map coordinates.

Return type:

GeoDataFrame

get_geojson(window: rastervision.core.box.Box | None = None, to_map_coords: bool = False) dict#

Return transformed GeoJSON.

This makes the following transformations to the raw geojson:

  • converts to pixels coords (by default)

  • removes empty features

  • splits apart multi-geoms and geom collections into single geometries

  • buffers lines and points into Polygons

Additionally, the transformations specified by all the VectorTransformers in vector_transformers are also applied.

Parameters:
  • window (Box | None) – If specified, return only the features that intersect with this window; otherwise, return all features. Defaults to None.

  • to_map_coords (bool) – If true, will return GeoJSON in map coordinates.

Returns:

dict in GeoJSON format

Return type:

dict

get_geoms(window: rastervision.core.box.Box | None = None, to_map_coords: bool = False) list['BaseGeometry']#

Returns all geometries in the transformed GeoJSON as Shapely geoms.

Parameters:
Returns:

List of Shapely geoms.

Return type:

list[‘BaseGeometry’]

property bbox: Box#

Bounding box applied to the source data.

property extent: Box#

Envelope of union of all geoms.