I have a array of values in Julia that I would like to export as a geotiff. Right now I am using osgeo in python to make them seperately, which is a pain. Does anyone have an example of how to do this? I can’t find one, but feel like there probably is a Julia package that can do this.
Thanks for the response. That was my first impulse, but I was having trouble importing the packages. I use:
from osgeo import gdal
from osgeo import osr
import numpy as np
import os, sys
In Julia, when I try:
julia> osg = pyimport("osgeo")
ERROR: PyError (PyImport_ImportModule
The Python package osgeo could not be found by pyimport. Usually this means
that you did not install osgeo in the Python version being used by PyCall.
PyCall is currently configured to use the Python version at:
/usr/bin/python3
and you should use whatever mechanism you usually use (apt-get, pip, conda,
etcetera) to install the Python package containing the osgeo module.
One alternative is to re-configure PyCall to use a different Python
version on your system: set ENV["PYTHON"] to the path/name of the python
executable you want to use, run Pkg.build("PyCall"), and re-launch Julia.
Another alternative is to configure PyCall to use a Julia-specific Python
distribution via the Conda.jl package (which installs a private Anaconda
Python distribution), which has the advantage that packages can be installed
and kept up-to-date via Julia. As explained in the PyCall documentation,
set ENV["PYTHON"]="", run Pkg.build("PyCall"), and re-launch Julia. Then,
To install the osgeo module, you can use `pyimport_conda("osgeo", PKG)`,
where PKG is the Anaconda package the contains the module osgeo,
or alternatively you can use the Conda package directly (via
`using Conda` followed by `Conda.add` etcetera).
) <class 'ImportError'>
ImportError("/home/efurtak/julia-1.4.2/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /lib64/libgdal.so.20)")
File "/usr/lib64/python3.7/site-packages/osgeo/__init__.py", line 21, in <module>
_gdal = swig_import_helper()
File "/usr/lib64/python3.7/site-packages/osgeo/__init__.py", line 17, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
File "/usr/lib64/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib64/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
That is the right python installation, and when I use python3 from the terminal there are no issues importing osgeo (I am using fedora, maybe that is the issue). Also, numpy imports with pycall fine for some reason.
I am not sure if I am doing this correctly, but I get:
[ Info: Running `conda install -y OSGeo` in root environment
/bin/sh: module: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `module'
/bin/sh: switchml: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `switchml'
/bin/sh: scl: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `scl'
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- osgeo
Current channels:
- https://repo.anaconda.com/pkgs/main/linux-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/linux-64
- https://repo.anaconda.com/pkgs/r/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
You can do it with GMT. What kind of images do you want to plot?
A toy example.
using GMT
G = gmt("grdmath -R0/30/0/30 -I0.1 X Y MUL"); # A dummy grid
I = grdimage(G, img_out=true); # Convert it to a dummy image
I.proj4 = "+proj=latlong +datum=WGS84"; # Assign it a fake CRS
gmtwrite("lixo.tif", I, driver=:GTiff)
GMT [WARNING]: gmtapi_change_imagelayout: reordering function for case TRPa -> BRP not yet written. Doing nothing.
That seems to be the solution I am looking for, but I still can’t get your package working on Fedora! We tried, here: How to make a wind rose in Julia - #23 by joa-quim I have another machine running pop_os, so maybe I will give it a shot with that a little later.
Ah, yes. Maybe you could try to build GMT from source. We have instructions for that in GMT home page. And a new version (6.1) should probably be released this week.