I have a very large JSON file made up vector polygons, I want to use GDAL ogr2ogr to clip the JSON polygons and convert the AOI into a shapefile.

I see this can be done by ogr2ogr -f "ESRI Shapefile" <output>.shp <input>.json -clipsrc llx lly urx ury

However I do not know how to use GDAL commands... is it done via CMD or python terminal?

I have QGIS 3.0.3 installed, and GDAL downloaded as a .zip (extracted now) on my desktop.

can someone explain to process to execute this command?


You need to use the CMD to use ogr2ogr. Normally, if you have QGIS, you should already have ogr2ogr (you can assess this typing ogr2ogr in CMD terminal)

You can also use "Clip vector by extent" within QGIS Processing Toolbox if you prefer to not use command line (or are a bit afraid of it)

  • 4
    You may need to use the osgeo cmd window – Ian Turton Jul 3 '18 at 7:14
  • Yes, some GDAL directories must ne added to%PATH% before running the utility. In osgeo cmd they are set for you. – user30184 Jul 3 '18 at 9:12
  • got an error saying no driver available...... – NULL.Dude Jul 3 '18 at 11:33
  • Please add your command line and the full error message to your question. – AndreJ Mar 6 at 6:55

Create a .bat like this - change the paths to suit your install. If at all changes will be in the OSGEO root and python path.

@echo off
call "%OSGEO4W_ROOT%"\bin\o4w_env.bat
call "%OSGEO4W_ROOT%"\apps\grass\grass-7.4.0\etc\env.bat

path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-7.4.0\lib
path %PATH%;C:\OSGeo4W64\apps\Qt5\bin
path %PATH%;C:\OSGeo4W64\apps\Python37\Scripts

set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37


When you run this you can now type in ogr2ogr and get it's usage rather than unrecognised command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.