GithubHelp home page GithubHelp logo

lua-proj's Introduction

lua-proj - Binding to Proj.4

Unix Build Status Coverage Status

1. What?

Proj.4 is a library for converting coordinates between geographic projections.

2. How?

luarocks install proj

then

local proj = require"proj"
local nztm_to_wgs84 = proj:new("nztm", "wgs84 +degrees")
print(nztm_to_wgs84(1600000, 6000000))    -- prints "173     -36.144718099788"
print(nztm_to_wgs84:revert(173, -36))     -- prints "1600000    6016051.5467717"

local wgs84_to_nztm = nztm_to_wgs84:reverse()
print(wgs84_to_nztm(173, -36))            -- prints "1600000    6016051.5467717"

wgs84_to_nztm:set_output("nzmg")
print(wgs84_to_nztm(173, -36))            -- prints "2510588.5912768    6578340.6211262"

Extensions to Proj.4

Proj.4 projection definition strings are hard to remember, so lua-proj contains a list of shortcuts for projections I use frequently in proj/shortcuts.lua These are NZTM, NZMG and WGS84. This list could be extended (perhaps by pull request?)

When Proj.4 does projections in "degrees", like WGS84, despite most of the documentation saying "degrees", it actually means radians. Sometimes it's more convenient to work in degrees (particularly if you're reading a shapefile whose projection is in degrees). lua-proj recognises +degrees in the projection definition string and handles conversion from degrees to radians. The +degrees is removed before the string is passed on to Proj.4.

Proj.4 has the options +proj=latlong and +proj=longlat. Despite what you might think, these both expect coordinates to be passed in in the order longitude, latitude. Sometimes it's convenient (for example when parsing shapefiles) to work in latitude, longitude order. lua-proj recognises +order=longlat and +order=latlong and swaps the coordinates as necessary. As for +degrees the +order=... is removed before the string is passed on to Proj.4.

3. Requirements

  • Proj.4 installed on your system
  • Lua >= 5.1 or LuaJIT >= 2.0.0.
  • For building, you need the proj4 headers installed. Strictly speaking, this is only for Lua, not LuaJIT, but the rock builds the binding either way.

4. Wishlist

  • I don't know enough about windows to get Proj.4 installed before building and testing for AppVeyor.

5. Alternatives

lua-proj's People

Contributors

geoffleyland avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.