When I use the GetGeomType() with GDAL/OGR it returns an integer. I want to know what geometry type each integer represents.
driver = ogr.GetDriverByName("FileGDB")
gdb = r"C:\Users\******\Documents\ArcGIS\Default.gdb"
ds = driver.Open(gdb, 0)
input_lyr_name = "Birmingham_Burglaries_2016"
lyr = ds.GetLayerByName(input_lyr_name)
# access the schema info
lyr_def = lyr.GetLayerDefn()
print lyr_def.GetGeomType()
Output: 1
I already know an alternative way to get the geometry type as below, but I am interested to match integers to the correct geometry type. Is there a list somewhere?
first_feat = lyr.GetFeature(1)
print first_feat.geometry().GetGeometryName()
Output: POINT
But this won't work on an empty dataset.
Answer
You will find the output variants of WKB types supported by GDAL here:
From §8.2.8 (page 66):
enum WKBGeometryType {
wkbPoint = 1,
wkbLineString = 2,
wkbPolygon = 3,
wkbTriangle = 17
wkbMultiPoint = 4,
wkbMultiLineString = 5,
wkbMultiPolygon = 6,
wkbGeometryCollection = 7,
wkbPolyhedralSurface = 15,
wkbTIN = 16
wkbPointZ = 1001,
wkbLineStringZ = 1002,
wkbPolygonZ = 1003,
wkbTrianglez = 1017
wkbMultiPointZ = 1004,
wkbMultiLineStringZ = 1005,
wkbMultiPolygonZ = 1006,
wkbGeometryCollectionZ = 1007,
wkbPolyhedralSurfaceZ = 1015,
wkbTINZ = 1016
wkbPointM = 2001,
wkbLineStringM = 2002,
wkbPolygonM = 2003,
wkbTriangleM = 2017
wkbMultiPointM = 2004,
wkbMultiLineStringM = 2005,
wkbMultiPolygonM = 2006,
wkbGeometryCollectionM = 2007,
wkbPolyhedralSurfaceM = 2015,
wkbTINM = 2016
wkbPointZM = 3001,
wkbLineStringZM = 3002,
wkbPolygonZM = 3003,
wkbTriangleZM = 3017
wkbMultiPointZM = 3004,
wkbMultiLineStringZM = 3005,
wkbMultiPolygonZM = 3006,
wkbGeometryCollectionZM = 3007,
wkbPolyhedralSurfaceZM = 3015,
wkbTinZM = 3016,
}
No comments:
Post a Comment