Zum Hauptinhalt springen

In-memory reading of GML-format data with geopandas

Today I learned another way of parsing geo data formats in-memory, using geopandas.

As part of a running django web service, I wanted to request and parse a WFS respose, which comes back in GML format.

The solution to this is:


This was pointed out by sal in this stackoverflow answer. Since I could not find it in the documentation, either in fiona and not in geopandas. I want to try now to add this there.

In my path to the solution I was stuck trying to parse the string in-memory with geopandas read_file, from_features, gdal.OpenEx(). But especially the gdal.OpenEx way, which should parse definatly a string representation of any geo-data feature collection (for example GeoJSON, I did not get working properly.

  • The BytesCollection uses the VSIFileFromMemBuffer class internally, which is the gdal implementation for performant read-operation on so called.
  • To invoke the WFS service, I used oswlib.

As I learned the other day, you can do this also directly with an GET request url and read_file.