Last active
April 27, 2020 14:03
-
-
Save Brideau/b96aa05d719fb764d38bb9d75b48aa9d to your computer and use it in GitHub Desktop.
Install GDAL with Java bindings on macOS High Sierra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resolvers += "Boundless" at "http://repo.boundlessgeo.com/main/" | |
libraryDependencies += "org.gdal" % "gdal" % "2.2.1" | |
// These let you enter input in the terminal if running via SBT | |
fork in run := true | |
connectInput in run := true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export DYLD_LIBRARY_PATH=/usr/local/opt/gdal2/lib:$DYLD_LIBRARY_PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install osgeo/osgeo4mac/gdal2 --with-java --with-libkml --with-mdb --with-mysql --with-opencl --with-postgresql --with-swig-java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.whackdata | |
import org.gdal.ogr._ | |
object Main extends App { | |
val fileName = "./src/main/resources/Canada3573.gpkg" | |
// Register all of the OGR drivers that are part of your GDAL installation. | |
ogr.RegisterAll() | |
// Open your file | |
val dataSource = ogr.OpenShared(fileName) | |
// Get the first layer (there is only one in the sample file). | |
// You can also use dataSource.GetLayerByName() if your layers are named. | |
val layer = dataSource.GetLayer(0) | |
// Load the Spatial Reference and auto-identify | |
val srs = layer.GetSpatialRef() | |
srs.AutoIdentifyEPSG | |
val authCode = srs.GetAuthorityCode(null) | |
println("EPSG: " + authCode) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.whackdata | |
import org.gdal.ogr._ | |
import scala.concurrent.Future | |
import scala.io.StdIn | |
import scala.util.{Failure, Success} | |
import scala.concurrent.ExecutionContext.Implicits.global | |
object MainNonBlocking extends App { | |
val fileName = "./src/main/resources/hex62p5.geojson" | |
// Register all of the OGR drivers that are part of your GDAL installation. | |
ogr.RegisterAll() | |
def getAuthCode(fileName: String): Future[String] = Future { | |
val dataSource = ogr.OpenShared(fileName) | |
// Get the first layer (there is only one in the sample file). | |
// You can also use dataSource.GetLayerByName() if your layers are named. | |
val layer = dataSource.GetLayer(0) | |
// Load the Spatial Reference and auto-identify | |
val srs = layer.GetSpatialRef() | |
srs.AutoIdentifyEPSG | |
srs.GetAuthorityCode(null) | |
} | |
getAuthCode(fileName).onComplete{ | |
case Success(authCode) => println("EPSG: " + authCode) | |
case Failure(ex) => println("Lookup Failed: " + ex.getMessage) | |
} | |
println(s"Running in background. Press Return to stop.") | |
StdIn.readLine() | |
} |
Tried with-swig-java option.
Error: invalid option: --with-swig-java
FYI it seems like you cannot do this via homebrew anymore as there are no such options available (e.g. with-swig-java).
So far I haven't found a way other than building from source.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try with "with-swig-java" option