26

I'm looking at New York City's Projected Sea Level Rise dataset. This dataset states that it is:

Geodatabase of projected sea level rise based on models released by New York City Panel on Climate Change (NPCC). Data includes the 10th, 25th, 50th, 75th and 90th percentile projections for the years 2020, 2050, 2080 and 2100.

I can read this into a GeoDataFrame using:

import geopandas as gpd
# Download from https://data.cityofnewyork.us/City-Government/Projected-Sea-Level-Rise/6an6-9htp directly...
data = gpd.read_file("NYCFutureHighTideWithSLR.gdb", driver='FileGDB', layer=0)

Here I am reading the 0th (first) layer in the database.

But what does that actually mean? I'm not sure what order the percentile-year layers were provided in by the city, so I'd like to, if possible, also read the names of the various layers.

However, I am unsure how to do so, or even if layer names is a feature of this data format at all. Does anyone know how to do this in Python, preferably by using new-school tools like fiona or geopandas?

asked Sep 12, 2017 at 18:46

2 Answers 2

38

The fiona.listlayers() function returns a list of names of layers in a dataset.

import fiona
fiona.listlayers('NYCFutureHighTideWithSLR.gdb')

Any of the elements of the list can be used as a value of the layer keyword argument for gpd.read_file().

The integer index of a list element may also be used. If the layers of your dataset are ['layer_a', 'layer_b'], then gpd.read_file("NYCFutureHighTideWithSLR.gdb", driver='FileGDB', layer='layer_b') and gpd.read_file("NYCFutureHighTideWithSLR.gdb", driver='FileGDB', layer=1) are equivalent.

answered Sep 13, 2017 at 13:53
0
1

You can use pyogrio.list_layers:

import pyogrio
pyogrio.list_layers('NYCFutureHighTideWithSLR.gdb')

pyogrio replaced fiona as the default IO engine in geopandas 1.0.0.

answered Aug 13 at 19:26
1
  • 1
    Nice catch! Also include GeoPandas's .list_layers() method Commented Aug 13 at 20:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.