GeoJSONVectorSource#

class GeoJSONVectorSource[source]#

Bases: VectorSource

A VectorSource for reading GeoJSON files.

Attributes

extent

Envelope of union of all geoms.

__init__(uri: str, crs_transformer: CRSTransformer, vector_transformers: List[VectorTransformer] = [], ignore_crs_field: bool = False)[source]#

Constructor.

Parameters
  • uri (str) – URI of the GeoJSON file.

  • 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 [].

  • ignore_crs_field (bool) – Ignore the CRS specified in the file and assume WGS84 (EPSG:4326) coords. Only WGS84 is supported currently. If False, and the file contains a CRS, will throw an exception on read. Defaults to False.

Methods

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

Constructor.

get_dataframe([to_map_coords])

Return geometries as a GeoDataFrame.

get_geojson([to_map_coords])

Return transformed GeoJSON.

get_geoms([to_map_coords])

Returns all geometries in the transformed GeoJSON as Shapely geoms.

__init__(uri: str, crs_transformer: CRSTransformer, vector_transformers: List[VectorTransformer] = [], ignore_crs_field: bool = False)[source]#

Constructor.

Parameters
  • uri (str) – URI of the GeoJSON file.

  • 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 [].

  • ignore_crs_field (bool) – Ignore the CRS specified in the file and assume WGS84 (EPSG:4326) coords. Only WGS84 is supported currently. If False, and the file contains a CRS, will throw an exception on read. Defaults to False.

get_dataframe(to_map_coords: bool = False) geopandas.GeoDataFrame#

Return geometries as a GeoDataFrame.

Parameters

to_map_coords (bool) –

Return type

geopandas.GeoDataFrame

get_geojson(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

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

Returns

dict in GeoJSON format

Return type

dict

get_geoms(to_map_coords: bool = False) List[BaseGeometry]#

Returns all geometries in the transformed GeoJSON as Shapely geoms.

Parameters

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

Returns

List of Shapely geoms.

Return type

List[‘BaseGeometry’]

property extent: Box#

Envelope of union of all geoms.