5 votes
Accepted

How to extract the integer-based geometry type code from an OGR feature

After poking around a little longer, I found out that while OGR geometries don't have access to the GetGeomType method, they DO have access to the GetGeometryType method, which outputs exactly what I'...
Felipe D.'s user avatar
  • 2,509
4 votes

Python GDAL-OSGEO library: shapefile to PostGIS?

With some steer from @user2856 and others in the comments, I've managed to form a working script, with some very important information on proj.db. import os from osgeo import gdal """ ...
Theo F's user avatar
  • 1,829
4 votes
Accepted

Cannot import QgsVectorLayer from osgeo.ogr

As noted in another answer QgsVectorLayer is not and has never been part of the GDAL python bindings. I think you want gdal.VectorTranslate(). At it's simplest, your code turns into: from osgeo import ...
user2856's user avatar
  • 65.9k
4 votes

Cannot import QgsVectorLayer from osgeo.ogr

The osgeo module has never had QgsVectorLayer. That belong to qgis.core module. https://qgis.org/pyqgis/3.0/core/Vector/QgsVectorLayer.html
user30184's user avatar
  • 65.5k
2 votes
Accepted

Modify a subset of a raster based on a shapefile

You can use rasterio: from rasterio import features import rasterio, os import geopandas as gpd import numpy as np workspace = r"C:/GIS/data/dem_folder" out_file = os.path.join(workspace, &...
BERA's user avatar
  • 72.8k
1 vote

ModuleNotFoundError: No module named 'matplotlib.backends.backend_qt4agg'

For me on Windows I just changed: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas to: from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as ...
jorgealmerio's user avatar
1 vote

How to extract geometries with M-values from a feature layer in Python?

Why not make it simpler (with a list of wkt strings) my_gdf = gpd.read_file(filename=inGDBPath,layer=inLayerName) wkt =[] for this_inFeature in inLayer: this_inGeom = this_inFeature....
gene's user avatar
  • 54.9k

Only top scored, non community-wiki answers of a minimum length are eligible