5

I start using GDAL 3.0.0 using conda build. I successfully installed GDAL on my laptop (Windows 10) and I am trying to ingest MapInfo tab file into Elasticsearch index. I understood that I have to create mapping first before ingesting it into Elasticsearch.

ogr2ogr -progress -lco MAPPING="D:\mymappings\map.text" -f "ElasticSearch" http://localhost:9700 "D:\MIProTab.tab"

But when I try to execute the above command then it is giving me the following error:

C:\Users\ABCD>ogr2ogr -progress -lco MAPPING="D:\mymappings\map.text" -f "ElasticSearch" http://localhost:9700 "D:\MIProTab.tab"
ERROR 1: PROJ: pj_obj_create: Cannot find proj.db
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: proj_create_from_database: 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: proj_as_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_as_wkt: Cannot find proj.db
0...10...20...30...40...50...60...70...80...90...100 - done.

C:\Users\ABCD>

I checked other's solution where it is mentioned to have gdal.dll to be present on the same directory where ogr2ogr is present. Also, I have set the environment variable "PROJ_LIB" but all went in vain. What is wrong here?

  • 1
    GDAL needs to find the file "proj.db" that contains all the definitions for the coordinate systems. I do not know where conda is placing in the zip file from gisinternals.com it seems to be in …\bin\proj6\share. – user30184 Jun 26 '19 at 11:07
  • this location is not present there. I also downloaded the GDAL core from gisinternals.com and try to run the same above command. But it doesn't work out. – Praveen Kumar Jun 26 '19 at 12:30
  • Do you get the same error about missing proj.db? – user30184 Jun 26 '19 at 12:50
  • How did you install GDAL the first time? – Marcelo Villa-Piñeros Jun 26 '19 at 15:30
  • I installed anaconda/minconda python and then i use "conda" installer. – Praveen Kumar Jun 28 '19 at 6:42
4

I set the PROJ_LIB environment variable to point to the PROJ.4 data directory (where proj.db lives) and this problem has been solved,hope that is useful to you.

| improve this answer | |
  • Sorry. but it didn't solve my problem. – Praveen Kumar Jul 1 '19 at 5:34
  • Yes this solved my problem. Of course you have to restart the software (including shells such as cmd boxes) to load this new environment setting into the ogr2ogr environment. – anneb Sep 14 '19 at 14:14
3

Check your environment_variable:

setx GDAL_DATA "C:\Program Files\GDAL\gdal-data"
setx GDAL_DRIVER_PATH "C:\Program Files\GDAL\gdalplugins"
setx PROJ_LIB "C:\Program Files\GDAL\projlib"
setx PYTHONPATH "C:\Program Files\GDAL\"
| improve this answer | |
  • suggest using 'set', instead of the permanent 'setx' – Theo F Dec 17 '19 at 13:30
  • 1
    Thanks this helped. For @TheoF in windows 10 you need to use setx if you want it to be a permanent change: superuser.com/questions/916649/… – HeikkiVesanto Jan 3 at 11:38
  • @HeikkiVesanto yes, like I said. I suggest not using setx for testing. – Theo F Jan 3 at 16:06
0

To use GDAL and/or PROJ from conda, you need to activate the environment, which sets the necessary environment variables (including GDAL_DATA and PROJ_LIB).

If you have conda on your path, it's simply conda activate base (or other environment).


If you don't have conda on your path, you can activate this a bit differently. For example, to activate the "base" Anaconda3 environment for Windows:

call %LOCALAPPDATA%\Continuum\anaconda3\Scripts\activate.bat base

Or for Linux:

. $HOME/anaconda3/bin/activate base
| improve this answer | |
0

This is fairly straightforward once you know how to prepare the command environment - that was the bit I couldn't figure out. You can do as above or if you have already installed QGIS then this should work:

ogr2ogr is the tool but in order to use it some parameters qgis takes care of must be known (like where the projection information is) by the stand alone utility:

  1. If ogr2ogr was installed with QGIS (like mine was) then start a cmd session in C:\Program Files\QGIS 3.4\bin
  2. Run o4w_env.bat - this sets all the environment variables required to use ogr at the cmd
  3. Execute your export command. In my case it was
    ogr2ogr.exe -f SQLite -dsco SPATIALITE=yes "C:\temp\osm_lines" PG:"dbname=thedbasename user=theuser password=thepwd" public.planet_osm_line
    

This link was helpful for the ogr2ogr cmd syntax.

https://trac.osgeo.org/postgis/wiki/SpatiaLite

| improve this answer | |

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.