Linked Questions

7 votes
1 answer
20k views

How do I use ogr2ogr with python GDAL? [duplicate]

I've just installed GDAL, but I don't know how to import/use ogr2ogr. I've tried: from osgeo import gdal from osgeo import ogr and searched both for ogr2ogr, but it wasn't there.
bozdoz's user avatar
  • 345
10 votes
4 answers
6k views

How to make crs transformation of a QgsVectorLayer?

I need to transform QgsVectorLayers in python from one crs into another crs. By googling I found the following solution (https://qgis.readthedocs.org/en/latest/docs/pyqgis_developer_cookbook/05_crs....
gallay's user avatar
  • 351
4 votes
1 answer
6k views

Merge all features in polygon shapefile with gdal

How do I apply using this same concept, but simply merging all features into one? ogr2ogr output.shp input.shp -dialect sqlite -sql "SELECT ST_Union(geometry), dissolve_field FROM input GROUP BY ...
Steven Lutz's user avatar
4 votes
2 answers
11k views

Python library for KML to GeoJSON?

I am writing a Python script to reproject a KML file to WGS 84 and then to convert it to a GeoJSON. I am aware of and use the GDAL command line tool ogr2ogr (which was the answer to this question in ...
dave's user avatar
  • 107
2 votes
1 answer
2k views

Sentinel-2 cloud mask with fmask

I'm trying to run fmask on a Sentinel-2 granule. I downloaded the 3.2 version of Windows stand alone software for Sentinel 2 from https://github.com/prs021/fmask When I try to run fmask by calling the ...
unnic's user avatar
  • 360
3 votes
1 answer
1k views

Issue to convert from PostgreSQL input to GPKG using Python GDAL API function gdal.VectorTranslate

When I run the following code, it fails with message The error is ERROR 1: SELECT from table mytable failed, no such table/featureclass. from osgeo import gdal gdal.UseExceptions() gdal....
ThomasG77's user avatar
  • 30.1k
1 vote
3 answers
2k views

Cropping a Shapefile into a Rectangular Box with Python pyshp

Using 'pyshp' I am hoping to reduce the set of US highway shapefiles to only those in Puerto Rico. The idea is very easy since I only need those pieces which fit into the window. >> import ...
john mangual's user avatar
2 votes
2 answers
1k views

Plotting Storm Prediction Center (SPC) Shapefile using Python?

I am trying to make a plot of the SPC's thunderstorm outlook using Python. I have downloaded the shapefile from this website http://www.spc.noaa.gov/products/outlook/day1otlk.html. Then I use this ...
wolfpack's user avatar
2 votes
1 answer
1k views

Unable to open datasource with ogr2ogr.main() [closed]

I try to make ogr2ogr work in Python the way suggested by Elevine's answer elsewhere, but I'm facing bugs. Most notable error is that while I try to reproject shapefiles, I get the following error: ...
Pavel V.'s user avatar
  • 1,517
3 votes
2 answers
882 views

Using ogr2ogr in Python scripts

I have been trying to figure out how to execute ogr2ogr to convert files in Python script. I got it to work in Jupyter notebook within ArcGIS Pro and in the terminal but not in Python scripts. Here's ...
Muppidi Sahaja Reddy's user avatar
2 votes
1 answer
1k views

GML file converted to ESRI shapefile with ogr2ogr missing spatial reference information

I am trying to convert Sentinel-2 cloud masks from GML format to ESRI shapefiles. I have managed to use ogr2ogr in a python script as described in the answer to Using ogr2ogr to convert GML to ...
liamvharris's user avatar
2 votes
0 answers
454 views

Using ogr2ogr in python?

I found this helpful post that got me started using ogr2ogr in python: Using ogr2ogr to convert GML to shapefile in Python? as well as this one: Converting ArcGIS Server JSON to GeoJSON? I am trying ...
kflaw's user avatar
  • 1,396
2 votes
1 answer
91 views

KML driver failed to create

I want to convert spatial data from postgres to some basic formats (shp, geopackage, csv, xlsx, gml... ) using python gdal functionality. I read the answer to this question: Using ogr2ogr to convert ...
DrJacoby's user avatar
  • 781