sertit.vectors.read

read(path: Union[str, cloudpathlib.cloudpath.CloudPath, pathlib.Path], crs: Optional[Any] = None, archive_regex: Optional[str] = None) geopandas.geodataframe.GeoDataFrame[source]

Read any vector: - if KML: sets correctly the drivers and open layered KML (you may need ogr2ogr to make it work !) - if archive (only zip or tar), use a regex to look for the vector inside the archive.

You can use this [site](https://regexr.com/) to build your regex.

  • if GML: manages the empty errors

>>> # Usual
>>> path = 'D:\path\to\vector.geojson'
>>> vectors.read(path, crs=WGS84)
                       Name  ...                                           geometry
0  Sentinel-1 Image Overlay  ...  POLYGON ((0.85336 42.24660, -2.32032 42.65493,...

>>> # Archive
>>> arch_path = 'D:\path\to\zip.zip'
>>> vectors.read(arch_path, archive_regex=".*map-overlay\.kml")
                       Name  ...                                           geometry
0  Sentinel-1 Image Overlay  ...  POLYGON ((0.85336 42.24660, -2.32032 42.65493,...
Parameters
  • path (Union[str, CloudPath, Path]) – Path to vector to read. In case of archive, path to the archive.

  • crs – Wanted CRS of the vector. If None, using naive or origin CRS.

  • archive_regex (str) – [Archive only] Regex for the wanted vector inside the archive

Returns

Read vector as a GeoDataFrame

Return type

gpd.GeoDataFrame