I got a GML file from Ordnance Survey's Topography layer. The file has 5 layers in total (image from loading to QGIS):

enter image description here

I would like to load the file to python and I saw that GeoPandas has GML support so I am doing this:

db = gpd.read_file('pth/to/5221132-NS7010', driver='GML')

But this seems to load only the Cartographic text layer (the db contains 1039 points):

len(db) # 1039

Is there a way to specify the specific layer (by layer id) that I want loaded? Or even load everything and the choose the one I am interested in?

  • 1
    You can pass layer= keyword to read_file. Jun 18 '21 at 18:35
  • 1
    Yes indeed! Can you please make this an answer so that I can accept it?
    – GStav
    Jun 18 '21 at 19:36

GeoPandas allows the layer keyword in read_file.

db = gpd.read_file('pth/to/5221132-NS7010', driver='GML', layer="my_layer_name")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.