In the basic ogr2ogr command the data source and layer are given as
ogr2ogr -f "GPKG" osm_bldgs_exp4.gpkg us-latest.osm.pbf multipolygons
That would convert everything from the layer "multipolygons".
When the command includes -sql the layer is defined in the SQL statement:
select * from multipolygons where ...
That overrides the layer ...
You can greatly simplify the operation using gdal.VectorTranslate
from osgeo import gdal
# Open the raster tif and extract crs
t = "path/to/raster.tif"
tif = gdal.Open(t)
crs1 = tif.GetProjectionRef()
tif = None
# Input shp path
s = "path/to/shapefile.shp"
# Set name of the new shapefile
sUTM = "shapefile_UTM.shp"
The GMLAS driver can not be installed. You need to install a GDAL distribution that has it built in.
The conda-forge gdal distribution includes the GMLAS driver. There may be other distributions that include it, but I only use conda.
If you don't have conda installed, I suggest miniconda.
conda create -c conda-forge -n gdal_with_gmlas gdal python and any ...
OpenJUMP Plus has a special tool for that purpose.
It works well if the source data is topologically good and really have shared vertices. OpenJUMP has also tools for improving topology like "Adjust polygon boundaries" that removes small gaps and overlaps and adds vertices to make the boundaries match.
Tools "Find coverage gaps" and &...