Tag Archives: lq

How to Use spatial in MAC

1. To https://distfiles.macports.org/MacPorts/ download package management tools

MacPorts-2.3.1-10.9-Mavericks.pkg

2. Install macPort and check whether the installation is successful

lqdeMacBook-Pro:~ lq$ port
MacPorts 2.3.1
Entering interactive mode... ("help" for help, "quit" to quit)
[Users/lq] > port
lqdeMacBook-Pro:~ lq$ port selfupdate
--->  Updating MacPorts base sources using rsync
Error: can't create directory "/opt/local/var/macports/sources/rsync.macports.org/release/tarballs/tmp": permission denied
Please run `port -v selfupdate' for details.
Error: /opt/local/bin/port: port selfupdate failed: can't create directory "/opt/local/var/macports/sources/rsync.macports.org/release/tarballs/tmp": permission denied
lqdeMacBook-Pro:~ lq$ sudo port selfupdate
Password:
Sorry, try again.
Password:
--->  Updating MacPorts base sources using rsync
MacPorts base version 2.3.1 installed,
MacPorts base version 2.3.1 downloaded.
--->  Updating the ports tree
--->  MacPorts base is already the latest version

The ports tree has been updated. To upgrade your installed ports, you should run
  port upgrade outdated

3. Check if the package exists

You can go to the following website to check whether the package exists or not
https://www.macports.org/ports.php

4. Install the spatialite

lqdeMacBook-Pro:~ lq$ port intall spatialite
Error: Unrecognized action "port intall"
lqdeMacBook-Pro:~ lq$ port install spatialite
Error: Insufficient privileges to write to MacPorts install prefix.
lqdeMacBook-Pro:~ lq$ sudo port install spatialite  ———Note: You need to add sudo to get system privileges.
Warning: The Xcode Command Line Tools don't appear to be installed; most ports will likely fail to build.
Warning: Install them by running `xcode-select --install'.
--->  Computing dependencies for spatialite
--->  Dependencies to be installed: geos libxml2 libiconv xz gettext expat ncurses zlib proj sqlite3 libedit
--->  Fetching archive for geos
--->  Attempting to fetch geos-3.4.2_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/geos
--->  Attempting to fetch geos-3.4.2_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/geos
--->  Installing geos @3.4.2_0
--->  Activating geos @3.4.2_0
--->  Cleaning geos
--->  Fetching archive for libiconv
--->  Attempting to fetch libiconv-1.14_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/libiconv
--->  Attempting to fetch libiconv-1.14_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/libiconv
--->  Installing libiconv @1.14_0
--->  Activating libiconv @1.14_0
--->  Cleaning libiconv
--->  Fetching archive for expat
--->  Attempting to fetch expat-2.1.0_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/expat
--->  Attempting to fetch expat-2.1.0_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/expat
--->  Installing expat @2.1.0_0
--->  Activating expat @2.1.0_0
--->  Cleaning expat
--->  Fetching archive for ncurses
--->  Attempting to fetch ncurses-5.9_2.darwin_13.x86_64.tbz2 from http://packages.macports.org/ncurses
--->  Attempting to fetch ncurses-5.9_2.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/ncurses
--->  Installing ncurses @5.9_2
--->  Activating ncurses @5.9_2
--->  Cleaning ncurses
--->  Fetching archive for gettext
--->  Attempting to fetch gettext-0.19.1_1.darwin_13.x86_64.tbz2 from http://packages.macports.org/gettext
--->  Attempting to fetch gettext-0.19.1_1.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/gettext
--->  Installing gettext @0.19.1_1
--->  Activating gettext @0.19.1_1
--->  Cleaning gettext
--->  Fetching archive for xz
--->  Attempting to fetch xz-5.0.5_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/xz
--->  Attempting to fetch xz-5.0.5_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/xz
--->  Installing xz @5.0.5_0
--->  Activating xz @5.0.5_0
--->  Cleaning xz
--->  Fetching archive for zlib
--->  Attempting to fetch zlib-1.2.8_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/zlib
--->  Attempting to fetch zlib-1.2.8_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/zlib
--->  Installing zlib @1.2.8_0
--->  Activating zlib @1.2.8_0
--->  Cleaning zlib
--->  Fetching archive for libxml2
--->  Attempting to fetch libxml2-2.9.1_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/libxml2
--->  Attempting to fetch libxml2-2.9.1_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/libxml2
--->  Installing libxml2 @2.9.1_0
--->  Activating libxml2 @2.9.1_0
--->  Cleaning libxml2
--->  Fetching archive for proj
--->  Attempting to fetch proj-4.8.0_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/proj
--->  Attempting to fetch proj-4.8.0_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/proj
--->  Installing proj @4.8.0_0
--->  Activating proj @4.8.0_0
--->  Cleaning proj
--->  Fetching archive for libedit
--->  Attempting to fetch libedit-20121213-3.0_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/libedit
--->  Attempting to fetch libedit-20121213-3.0_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/libedit
--->  Installing libedit @20121213-3.0_0
--->  Activating libedit @20121213-3.0_0
--->  Cleaning libedit
--->  Fetching archive for sqlite3
--->  Attempting to fetch sqlite3-3.8.4.3_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/sqlite3
--->  Attempting to fetch sqlite3-3.8.4.3_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/sqlite3
--->  Installing sqlite3 @3.8.4.3_0
--->  Activating sqlite3 @3.8.4.3_0
--->  Cleaning sqlite3
--->  Fetching archive for spatialite
--->  Attempting to fetch spatialite-4.1.1_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/spatialite
--->  Attempting to fetch spatialite-4.1.1_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/spatialite
--->  Installing spatialite @4.1.1_0
--->  Activating spatialite @4.1.1_0
--->  Cleaning spatialite
--->  Updating database of binaries
--->  Scanning binaries for linking errors               
--->  No broken files found.

5. Test whether the installation is successful

lqdeMacBook-Pro:~ lq$ sqlite3
SQLite version 3.8.4.3 2014-04-03 16:53:12
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> select load_extension('libspatialite')
   ...> ;
Error: dlopen(libspatialite.dylib, 10): image not found
sqlite> select load_extension('libspatialite-5');
Error: dlopen(libspatialite-5.dylib, 10): image not found
sqlite> select load_extension('libspatialite.5');
Error: dlopen(libspatialite.5.dylib, 10): image not found
sqlite> select load_extension('/opt/local/lib/libspatialite.5’); // Note: This is the compile path automatically generated by the system after downloading, it must be full path or it may not be read successfully.

sqlite> select geomfromtext('POINT ( 23 56 )', 4326)
   ...> ;
sqlite>select astext(geomfromtext('POINT ( 23 56 )', 4326));
POINT(23 56)
sqlite>