Tag Archives: GDAL

Python import GDAL failed: DLL load failed. The specified module cannot be found.

Recently, after installing some libraries such as pyqt and labelme in CONDA environment, I planned to run a geotif to JPG program, but an error was reported at the beginning of running, showing that there was a problem with the sentence Import importlib. Machine in imp.py, and the last line
return_ Load (SPEC) importerror: DLL load failed: the specified module could not be found although import does not prompt syntax errors, it will report errors when running. It is speculated that there is a problem with the import of GDAL library. Because the GDAL installed before is available, it can not be used now. It took a long time to make trouble. Finally, it is directly reinstalled to solve the problem, which has nothing to do with the version
CONDA enters the environment,
PIP uninstall GDAL
then find the previous GDAL installation package. My GDAL is gdal-3.2.1-cp37-cp37m-win_ Amd64.whl, install this installation package directly
PIP install gdal-3.2.1-cp37-cp37m-win_ Amd64.whl
after successful installation, enter Python for import, and the problem is solved

GDAL Error: ERROR 1: PROJ [How to Solve]

Using GDAL, an error occurs suddenly:

ERROR 1: PROJ: createGeodeticReferenceFrame: Cannot find proj.db
ERROR 1: PROJ: proj_as_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_create_from_wkt: Cannot find proj.db
ERROR 1: PROJ: createGeodeticReferenceFrame: Cannot find proj.db
ERROR 1: PROJ: pj_obj_create: Cannot find proj.db
ERROR 1: PROJ: proj_as_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_create_from_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_create_from_wkt: Cannot find proj.db
ERROR 1: PROJ: pj_obj_create: Cannot find proj.db
ERROR 1: PROJ: proj_as_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_as_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_create_from_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db

Solution:

Add these codes below at the header of your codes.

import os
os.environ['PROJ_LIB'] = r'D:\Anaconda3\envs\tf14\Library\share\proj'

Visual domain analysis of Python GDAL

gdal_viewshed

gdal_viewshed -md 10000 -ox 12509311 -oy 4769484 -a_nodata 0 srtm_59_05_3857.tif viewshed.tif

gdal. ViewshedGenerate

from osgeo import gdal

ds = gdal.Open('srtm_59_05_3857.tif')
band = ds.GetRasterBand(1)
gdal.ViewshedGenerate(srcBand=band, driverName='GTiff', targetRasterName='viewshed.tif', creationOptions=None, observerX=12509311, observerY=4769484, observerHeight=2, targetHeight=0, visibleVal=255, invisibleVal=0, outOfRangeVal=0, noDataVal=0, dfCurvCoeff=0.85714, mode=2, maxDistance=10000)

effect