from_geojson(geometry, on_invalid='raise', **kwargs)#

Creates geometries from GeoJSON representations (strings).


‘from_geojson’ requires at least GEOS 3.10.1.

If a GeoJSON is a FeatureCollection, it is read as a single geometry (with type GEOMETRYCOLLECTION). This may be unpacked using the pygeos.get_parts. Properties are not read.

The GeoJSON format is defined in RFC 7946.

The following are currently unsupported:

  • Three-dimensional geometries: the third dimension is ignored.

  • Geometries having ‘null’ in the coordinates.

geometrystr, bytes or array_like

The GeoJSON string or byte object(s) to convert.

on_invalid{“raise”, “warn”, “ignore”}, default “raise”
  • raise: an exception will be raised if an input GeoJSON is invalid.

  • warn: a warning will be raised and invalid input geometries will be returned as None.

  • ignore: invalid input geometries will be returned as None without a warning.


For other keyword-only arguments, see the NumPy ufunc docs.

See also



>>> from_geojson('{"type": "Point","coordinates": [1, 2]}')
<POINT (1 2)>