using ArchGDAL
In this section, we revisit the data/point.geojson
dataset.
dataset = ArchGDAL.read("data/point.geojson")
Retrieve a layer from a dataset using ArchGDAL.getlayer
layer = ArchGDAL.getlayer(dataset, 0)
The display provides
- the name of the feature layer (
point
) - the geometries in the dataset, and their brief summary.
- the fields in the dataset, and their brief summary.
You can also programmatically retrieve them using
ArchGDAL.getname(layer)
: the name of the feature layerArchGDAL.nfeature(layer)
: the number of features in the layerfeaturedefn =
ArchGDAL.layerdefn(layer)
: the schema of the layer featuresArchGDAL.nfield(featuredefn)
: the number of fieldsArchGDAL.ngeom(featuredefn)
: the number of geometriesArchGDAL.getfielddefn(featuredefn, i)
: the definition for thei
-th fieldArchGDAL.getgeomdefn(featuredefn, i)
: the definition for thei
-th geometry
Each fielddefn
defines an attribute of a feature, and supports the following:
ArchGDAL.getname(fielddefn)
: the name of the field ("FID"
or"pointname"
)ArchGDAL.gettype(fielddefn)
: the type of the field (OFTReal
orOFTString
)
Each geomdefn
defines an attribute of a geometry, and supports the following:
ArchGDAL.getname(geomdefn)
: the name of the geometry (""
in this case)ArchGDAL.gettype(geomdefn)
: the type of the geometry (wkbPoint
)
We can examine an individual feature
ArchGDAL.getfeature(layer, 2) do feature
print(feature)
end
You can programmatically retrieve the information using
ArchGDAL.nfield(feature)
: the number of fields (2
)ArchGDAL.ngeom(feature)
: the number of geometries (1
)ArchGDAL.getfield(feature, i)
: thei
-th field (0.0
and"a"
)ArchGDAL.getgeom(feature, i)
: thei
-th geometry (the WKT displayPOINT
)
More information on geometries can be found in Geometric Operations.