Raster Tool Error: error while loading shared libraries: libgeos-3.4.2.so

When I try running the raster tool:


I get the following error:

../bin/64bits/computeGridLandUse_beld4.exe: error while loading shared libraries: libgeos-3.4.2.so: cannot open shared object file: No such file or directory

This is a recurring error when I run any of the tools in the Spatial Allocator.
I am using SA-TOOLS version 4.3.2
I did a search for libgeos-3.4.2.so and found it in miniconda2 library and ~/Spatial-Allocator/src/libs/geos-3.5.0/local/lib
When I type sudo apt-cache search libgeos I get:
libgeos+±dev - Geometry engine for GIS - C++ development files
libgeos-3.5.0 - Geometry engine for Geographic Information Systems - C++ Library
libgeos-c1v5 - Geometry engine for Geographic Information Systems - C Library
libgeos-dbg - Debugging symbols for the GEOS library
libgeos-dev - Geometry engine for GIS - Development files
libgeos-doc - Documentation for the GEOS GIS geometry engine library
ruby-geos - GEOS bindings for Ruby

Is there a file in a wrong place or do I need to update/format/download data?

So I found a fix to this problem. I found that while I had configured the libraries and edited the makefile and sa_setup.csh I found that they were still looking for a directory that did not exist. The program looks in the library by going through the specified directories:


When re-configuring a library by downloading from a source, the file structure does not put the files in to the folder local so the program should look for the libraries as such:


or to change less code simply put all the files in the desired library in the folder local

Also if anyone has experience with this error any help would be much appreciated:

Error: File doe not exist: /proj/ie/proj/SA/data/sat/NLCD2006/NLCD2006_2011_20141010/nlcd_2006_landcover_2011_edition_2014_10_10.img

I believe it has something to do with running the makefile and the files in the Spatial_Allocator/src/raster folder, but I am not sure where the code actually calls for NLCD files.
/proj/ie/proj/SA/ is somthing I have already changed in the main makefile to the correct directory call out (SA_HOME =/home/pkasper/Documents/Spatial_Allocator/src)
Clearly it is calling the old directory, but I am not sure what needs to be updated. Possibly the makefile did not run properly and therefore did not update the SA_HOME variable to the new directory?

Modify this file to change the locations of nlcd and modis files:

1 Like

Thank you Dyang that does the trick.

It appears that I am now faced with the original problem again. The libraries do not appear to be linked up properly even after altering all files indicated in the documentation (Makefile and sa_setup.csh) I have run the Makefile, do I need to run the sa_setup.csh file as well? I have tried to manually set the library path:

export LD_LIBRARY_PATH="/Spatial_Allocator/src/libs"
This allows me to only link to one library at a time.

I have reconfigured all of the libraries with accordance to src/libs/README file.
My only other thought is that there is a problem with the Makefile or with OPTFLAGS
When I search for what files link to my libraries:
grep -iRl "[Library_Directory]"
I get a list of all the files in the raster folder as well as the files in the library

When I search with grep -iRl "proj/ie/proj" (old directory) nothing comes up, so I assume that I have removed past directory paths.

Has anyone found other changes that are need to get their libraries to be properly linked or any other ideas to this problem I am coming up against?

Another update:
Still getting problems with the program, but I may have found a work around the library problem. The sa_setup.csh file did not appear to be working so I linked it into the landuseTool_WRFCMAQ_BELD4.csh with the inserted script:
source ../bin/sa_setup.csh

This has cleared up initial library problems, but then I get the error:
HDF4 error.pkasper@AdamsTower2:~/Documents/Spatial_Allocator/raster_scripts$

Here is the full output code:

Using: Raster Spatial Allocator Version 4.2, 05/2014

Compute grid landuse percentage information... 

GDAL bin directory: /home/pkasper/Documents/Spatial_Allocator/src/libs/gdal-2.0.2/local/bin/
Getting modeling grid domain variables...
	Grid name: TX4KM
	Rows=183    Cols=165    Total gird cells=30195
	xmin=-216000.000000    ymin=-1392000.000000 
	xcell=4000    ycell=4000 
Grid domain projection proj4 = +proj=lcc +a=6370000.0 +b=6370000.0 +lat_1=33 +lat_2=45 +lat_0=40 +lon_0=-97
proj type = 1 
Processed NLCD image file list:  ../data/nlcd_modis_files_2006_20141010.txt
Indicator to include USGS NLCD landuse data is: YES
Indicator to include NASA MODIS IGBP landuse data is: YES

	U.S. county shapefile:  ../data/county_pophu02_48st.shp
	U.S. county shapefile FIPS item name:  CNTYID
	CAN census division shapefile:  ../data/can2006_cd_sel.shp
	CAN census division shapefile code item name:  AGUID

	U.S. county FIA tree fraction file:  ../data/beld3-fia.dat
	U.S. county NASS crop fraction file:  ../data/nass2006_beld4_ag.dat
	CAN census division crop fraction file:  ../data/can2006_beld4_ag.dat
	U.S. land cover and tree class name file:  ../data/beld4_class_names_40classes.txt
Output text file name: ../output/beld4/beld4_2006_tx4km.txt
Output NetCDF file name: ../output/beld4/beld4_2006_tx4km.nc
Reading land cover, crop and tree class name file: ../data/beld4_class_names_40classes.txt...

line 1: MODIS and NLCD Land Cover Classes:

line 43: Pasture and Crop Classes:

line 87: Tree Classes:
	Total lines read: 281    Landcover classes: 40   Crop classes: 42    Tree classes: 194   MaxNameLength: 50

Reading FIA tree fraction file: ../data/beld3-fia.dat...
	Total lines read: 70819    Counties in the file: 3125

Reading NASS crop fraction file: ../data/nass2006_beld4_ag.dat...
	Total lines read: 6128    Counties for 81 crops: 3063    Counties for 82 crops: 3063

Reading CAN crop fraction file: ../data/can2006_beld4_ag.dat...
	Total lines read: 379    Census divisions for CAN crops: 378

line 1: USGS NLCD Landuse Files:
line 3: /home/pkasper/Documents/Spatial_Allocator/data/NLCD2006/NLCD2006_2011_20141010/nlcd_2006_landcover_2011_edition_2014_10_10.img

line 4: USGS NLCD Urban Imperviousness Files:
line 5: /home/pkasper/Documents/Spatial_Allocator/data/NLCD2006/NLCD_2006_Impervious_L48_20190405/NLCD_2006_Impervious_L48_20190405.img

line 6: USGS NLCD Tree Canopy Files:
line 7: /home/pkasper/Documents/Spatial_Allocator/data/NLCD2006/Cartographic/nlcd2011_usfs_conus_canopy_cartographic.img

line 8: MODIS Landcover Tiled Files:
line 9: /home/pkasper/Documents/Spatial_Allocator/data/MCD12Q1/MCD12Q1.A2015001.h08v04.006.2018146022544.hdf
line 10: /home/pkasper/Documents/Spatial_Allocator/data/MCD12Q1/MCD12Q1.A2015001.h08v05.006.2018146022554.hdf
line 11: /home/pkasper/Documents/Spatial_Allocator/data/MCD12Q1/MCD12Q1.A2015001.h09v04.006.2018146022634.hdf
line 12: /home/pkasper/Documents/Spatial_Allocator/data/MCD12Q1/MCD12Q1.A2015001.h09v05.006.2018146022644.hdf
line 13: /home/pkasper/Documents/Spatial_Allocator/data/MCD12Q1/MCD12Q1.A2016001.h08v04.006.2018149124825.hdf
line 14: /home/pkasper/Documents/Spatial_Allocator/data/MCD12Q1/MCD12Q1.A2016001.h08v05.006.2018149124823.hdf
line 15: /home/pkasper/Documents/Spatial_Allocator/data/MCD12Q1/MCD12Q1.A2016001.h09v04.006.2018149124910.hdf
line 16: /home/pkasper/Documents/Spatial_Allocator/data/MCD12Q1/MCD12Q1.A2016001.h09v05.006.2018149124914.hdf
line 17: /home/pkasper/Documents/Spatial_Allocator/data/MCD12Q1/MCD12Q1.A2017001.h08v04.006.2018257170505.hdf
line 18: /home/pkasper/Documents/Spatial_Allocator/data/MCD12Q1/MCD12Q1.A2017001.h08v05.006.2018257170516.hdf
line 19: /home/pkasper/Documents/Spatial_Allocator/data/MCD12Q1/MCD12Q1.A2017001.h09v04.006.2018257170607.hdf
line 20: /home/pkasper/Documents/Spatial_Allocator/data/MCD12Q1/MCD12Q1.A2017001.h09v05.006.2018257170618.hdf

	Obtaining image information from /home/pkasper/Documents/Spatial_Allocator/data/NLCD2006/NLCD2006_2011_20141010/nlcd_2006_landcover_2011_edition_2014_10_10.img...
	Driver: HFA/Erdas Imagine Images (.img)ta/MCD12Q1/MCD12Q1.A2015001.h08v04.006.2018146022544.hdf
	Number of the global attributes: 6

HDF4 error.pkasper@AdamsTower2:~/Documents/Spatial_Allocator/raster_scripts$

This raster tool is not working with MODIS 2017 yet, we will enhance it in the new release. You can try to use 2012 MODIS data.

I think I am confused about the difference between MODIS 2017 and MODIS 2012. I am using MODIS land cover tiles -> MCD12Q1 Is this not the MODIS 2012 file needed?


I’ve gotten past the generic HDF4 Error with some help from CMAS

Here is what I was directed to do:
Use h4dump (ncdump for h4 file in Spatial Allocator alias) to check the variable name in your file.

  • The old MODIS file variable is: Land_Cover_Type_1

  • The new MODIS file variable is: LC_Type1

If you have new MODIS variable, you need to do this:
In geo_functions.cpp and in string getHDF4VarAttrInfo function:

attStr = string ( attBuff );
//attStr.erase (count);

In computeGridLandUse.cpp
//MODIS tile land cover class variable: may change depending on NASA MODIS LC products

//string modisVarName = string ( "Land_Cover_Type_1" );
string modisVarName = string ( "LC_Type1" );`

Repeat what was done on computeGridLandUse.cpp to computeGridLandUse)beld4.cpp
Somehow, the new MODIS file “long_name” attribute count is set to 100, not real char counts like before.

Run the make file in the src/raster directory

make clean
make install