{"id":13878143,"url":"https://github.com/rgeo/rgeo-proj4","last_synced_at":"2025-10-07T16:12:02.691Z","repository":{"id":27043983,"uuid":"112254838","full_name":"rgeo/rgeo-proj4","owner":"rgeo","description":"Proj4 extension for rgeo.","archived":false,"fork":false,"pushed_at":"2024-10-05T15:30:41.000Z","size":201,"stargazers_count":13,"open_issues_count":3,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-08T01:18:20.316Z","etag":null,"topics":["proj4","rgeo","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rgeo.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["BuonOmo"],"open_collective":"rgeo"}},"created_at":"2017-11-27T22:14:55.000Z","updated_at":"2024-10-05T15:30:45.000Z","dependencies_parsed_at":"2024-06-19T01:47:07.434Z","dependency_job_id":"82cc59bc-e5d5-411f-a651-872e724758f7","html_url":"https://github.com/rgeo/rgeo-proj4","commit_stats":{"total_commits":111,"total_committers":6,"mean_commits":18.5,"dds":0.3783783783783784,"last_synced_commit":"a54589227bf58ff4b48d7a31106bcfa7a037700b"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/rgeo/rgeo-proj4","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgeo%2Frgeo-proj4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgeo%2Frgeo-proj4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgeo%2Frgeo-proj4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgeo%2Frgeo-proj4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rgeo","download_url":"https://codeload.github.com/rgeo/rgeo-proj4/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgeo%2Frgeo-proj4/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259406525,"owners_count":22852598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["proj4","rgeo","ruby"],"created_at":"2024-08-06T08:01:40.972Z","updated_at":"2025-10-07T16:11:57.650Z","avatar_url":"https://github.com/rgeo.png","language":"Ruby","readme":"# `rgeo-proj4`\n\n[![Gem Version](https://badge.fury.io/rb/rgeo-proj4.svg)](http://badge.fury.io/rb/rgeo-proj4)\n[![CI](https://github.com/rgeo/rgeo-proj4/workflows/CI/badge.svg)](https://github.com/rgeo/rgeo-proj4/actions?query=workflow%3ACI+branch%3Amain+event%3Apush)\n\nThis project contains proj.4 extensions to the [rgeo gem](https://github.com/rgeo/rgeo).\n\nDocumentation about `proj.4` is available at [http://proj4.org/](http://proj4.org/).\n\n## Installation\n\n### Install PROJ\n\nInstall `proj` using your package manager:\n\n#### Homebrew\n\n```sh\nbrew install proj\n```\n\n#### Ubuntu/Debian\n\n```sh\napt-get install libproj-dev proj-bin\n```\n\nOr download binaries at https://proj.org/\n\nNote that version 3.x requires PROJ 6.2+. This should be the default on most systems, but in some cases, specific repositories will need to be added to the package manager.\n\nAdd this line to your Gemfile:\n\n```ruby\ngem \"rgeo-proj4\"\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install rgeo-proj4\n\nBy default, the gem looks for the Proj4 library in the following paths:\n\n```\n/usr/local\n/usr/local/proj\n/usr/local/proj4\n/opt/local\n/opt/proj\n/opt/proj4\n/opt\n/usr\n/Library/Frameworks/PROJ.framework/unix\n```\n\nIf Proj4 is installed in a different location, you must provide its\ninstallation prefix directory using the `--with-proj-dir` option.\n\n## Upgrading to V4\n\nSee the [Upgrading to V4](docs/Upgrading-To-V4.md) docs for information about how to upgrade from RGeo-Proj4 V3 to V4.\n\nFor a comprehensive list of changes, see the 4.0.0* release information in the [History](History.md) file.\n\n## Usage\n\nThe `rgeo-proj4` gem can be used by defining `CoordSys::Proj4` objects, as a part of an `RGeo::Geographic.projected_factory`, or as an attribute of other factories.\n\n### RGeo::CoordSys::Proj4\n\nThis is the lowest level module to transform between coordinate systems and all of the other methods ultimately rely on this object. The object is created with a [valid PROJ definition](https://proj.org/development/reference/functions.html#c.proj_create) which is used to define a coordinate reference system (CRS). Note that 2 `Proj4` objects need to be defined to transform between CRS's.\n\nIn addition to allowing transformations, this object can return information about the CRS.\n\n```ruby\nrequire 'rgeo'\nrequire 'rgeo/proj4'\n\n# define CRS's\n# can also be defined with the string \"EPSG:XXXX\" or a proj string\ngeography = RGeo::CoordSys::Proj4.create(4326)\nprojection = RGeo::CoordSys::Proj4.create(3857)\n\nx,y = RGeo::CoordSys::Proj4.transform_coords(projection, geography, -8367354.015764384, 4859054.160863457, nil)\n\np x\n# =\u003e -75.16522\np y\n# =\u003e 39.95258299\n```\n\nOther information can be shown from the `Proj4` object:\n\n```ruby\nrequire 'rgeo'\nrequire 'rgeo/proj4'\n\nprojection = RGeo::CoordSys::Proj4.create(\"EPSG:3857\")\np projection.canconical_str\n# =\u003e \"+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs\"\n\np projection.auth_name\n# =\u003e \"EPSG:3857\"\n\np projection.as_text\n# =\u003e PROJCRS[\\\"WGS 84 / Pseudo-Mercator\\\",BASEGEOGCRS[\\\"WGS 84\\\",DATUM[\\\"World Geodetic System 1984\\\",ELLIPSOID[\\\"WGS 84\\\",6378137,298.257223563,LENGTHUNIT[\\\"metre\\\",1]]],PRIMEM[\\\"Greenwich\\\",0,ANGLEUNIT[\\\"degree\\\",0.0174532925199433]],ID[\\\"EPSG\\\",4326]],CONVERSION[\\\"Popular Visualisation Pseudo-Mercator\\\",METHOD[\\\"Popular Visualisation Pseudo Mercator\\\",ID[\\\"EPSG\\\",1024]],PARAMETER[\\\"Latitude of natural origin\\\",0,ANGLEUNIT[\\\"degree\\\",0.0174532925199433],ID[\\\"EPSG\\\",8801]],PARAMETER[\\\"Longitude of natural origin\\\",0,ANGLEUNIT[\\\"degree\\\",0.0174532925199433],ID[\\\"EPSG\\\",8802]],PARAMETER[\\\"False easting\\\",0,LENGTHUNIT[\\\"metre\\\",1],ID[\\\"EPSG\\\",8806]],PARAMETER[\\\"False northing\\\",0,LENGTHUNIT[\\\"metre\\\",1],ID[\\\"EPSG\\\",8807]]],CS[Cartesian,2],AXIS[\\\"easting (X)\\\",east,ORDER[1],LENGTHUNIT[\\\"metre\\\",1]],AXIS[\\\"northing (Y)\\\",north,ORDER[2],LENGTHUNIT[\\\"metre\\\",1]],USAGE[SCOPE[\\\"unknown\\\"],AREA[\\\"World - 85\\xC2\\xB0S to 85\\xC2\\xB0N\\\"],BBOX[-85.06,-180,85.06,180]],ID[\\\"EPSG\\\",3857]]\n```\n\n### Projected Factory\n\nThe projected factory is a compound geographic factory that is useful for converting from lon/lat to the specified CRS.\n\n```ruby\nrequire 'rgeo'\nrequire 'rgeo/proj4'\n\nfactory = RGeo::Geographic.projected_factory(projection_srid: 3857)\n\np factory.projection_factory\n# =\u003e #\u003cRGeo::Geos::CAPIFactory srid=3857 bufres=1 flags=8\u003e\n\np factory.projection_factory.coord_sys\n# =\u003e #\u003cRGeo::CoordSys::Proj4 \"+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs\"\u003e\n\np factory.projection_factory.coord_sys.auth_name\n# =\u003e \"EPSG:3857\"\n\npt = factory.point(-75.16522, 39.95258299)\np pt.projection\n# =\u003e #\u003cRGeo::Geos::CAPIPointImpl \"POINT (-8367354.015764384 4859054.159411294)\"\u003e\n\np factory.unproject(pt.projection)\n# =\u003e #\u003cRGeo::Geographic::ProjectedPointImpl \"POINT (-75.16522 39.952582989999996)\"\u003e\n```\n\n### Feature::Cast\n\nThis method allows you to perform projections between more than just a lon/lat system. As long as 2 factories with valid Proj4 CRS's are defined, it can project between the CRS's.\n\n```ruby\nrequire 'rgeo'\nrequire 'rgeo/proj4'\n\n# coord_sys is unnecessary here as just an srid can be used\n# but coord_sys allows both Integer and String crs definitions.\ngeography = RGeo::Geos.factory(coord_sys: \"EPSG:4326\", srid: 4326)\nprojection = RGeo::Geos.factory(coord_sys: \"EPSG:3857\", srid: 3857)\n\np geography.coord_sys.auth_name\n# =\u003e \"EPSG:4326\"\np projection.coord_sys.auth_name\n# =\u003e \"EPSG:3857\"\n\nproj_point = projection.parse_wkt(\"POINT (-8367354.015764384 4859054.159411294)\")\n\ngeo_point = RGeo::Feature.cast(proj_point, project: true, factory: geography)\np geo_point\n# =\u003e #\u003cRGeo::Geos::CAPIPointImpl \"POINT (-75.16522 39.952582989999996)\"\u003e\n\nproj_point2 = RGeo::Feature.cast(geo_point, project: true, factory: projection)\n\np proj_point == proj_point2\n# =\u003e true\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run\nthe tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version,\nupdate the version number in `version.rb`, and then run `bundle exec rake release`, which will create\na git tag for the version, push git commits and tags, and push the `.gem` file to\n[rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/rgeo/rgeo-proj4.\nThis project is intended to be a safe, welcoming space for collaboration, and contributors are\nexpected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the\n[MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the `rgeo-proj4` project’s codebases, issue trackers, chat rooms and mailing\nlists is expected to follow the\n[code of conduct](https://github.com/rgeo/rgeo-proj4/blob/master/CODE_OF_CONDUCT.md).\n","funding_links":["https://github.com/sponsors/BuonOmo","https://opencollective.com/rgeo"],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgeo%2Frgeo-proj4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frgeo%2Frgeo-proj4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgeo%2Frgeo-proj4/lists"}