Convert Figma logo to code with AI

OSGeo logoPROJ

PROJ - Cartographic Projections and Coordinate Transformations Library

1,702
771
1,702
79

Top Related Projects

4,834

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.

1,052

Python interface to PROJ (cartographic projections and coordinate transformations library)

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL

41,217

πŸƒ JavaScript library for mobile-friendly interactive maps πŸ‡ΊπŸ‡¦

10,476

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)

The Rails application that powers OpenStreetMap

Quick Overview

PROJ is a generic coordinate transformation software library that converts coordinates between different geographic coordinate reference systems. It provides a standardized interface for defining and performing coordinate transformations, making it essential for GIS applications, cartography, and geospatial data processing.

Pros

  • Comprehensive support for a wide range of coordinate reference systems and transformations
  • Well-documented and actively maintained by the open-source community
  • High performance and efficiency, suitable for large-scale geospatial operations
  • Integrates well with other geospatial libraries and tools

Cons

  • Steep learning curve for beginners due to the complexity of coordinate systems
  • Limited built-in visualization capabilities, often requiring additional tools
  • Some advanced transformations may require external data files
  • Performance can be impacted when dealing with extremely large datasets

Code Examples

  1. Simple coordinate transformation:
#include <proj.h>
#include <stdio.h>

int main() {
    PJ_CONTEXT *C;
    PJ *P;
    PJ_COORD a, b;

    C = proj_context_create();
    P = proj_create_crs_to_crs(C, "EPSG:4326", "EPSG:3857", NULL);

    a = proj_coord(2, 49, 0, 0);
    b = proj_trans(P, PJ_FWD, a);

    printf("easting: %.3f, northing: %.3f\n", b.enu.e, b.enu.n);

    proj_destroy(P);
    proj_context_destroy(C);
    return 0;
}
  1. Creating a custom projection:
#include <proj.h>
#include <stdio.h>

int main() {
    PJ_CONTEXT *C = proj_context_create();
    PJ *P = proj_create(C, "+proj=merc +lat_ts=56.5 +ellps=GRS80");

    if (P == 0) {
        fprintf(stderr, "Error: %s\n", proj_errno_string(proj_errno(P)));
        return 1;
    }

    PJ_COORD c = proj_coord(12, 55, 0, 0);
    PJ_COORD r = proj_trans(P, PJ_FWD, c);

    printf("Result: %.2f %.2f\n", r.xy.x, r.xy.y);

    proj_destroy(P);
    proj_context_destroy(C);
    return 0;
}
  1. Geodesic calculations:
#include <proj.h>
#include <stdio.h>

int main() {
    PJ_CONTEXT *C = proj_context_create();
    PJ *P = proj_create(C, "+proj=geod +ellps=WGS84");

    PJ_COORD a = proj_coord(2, 49, 0, 0);
    PJ_COORD b = proj_coord(3, 50, 0, 0);

    double s12, azi1, azi2;
    proj_geod(P, a, b, &s12, &azi1, &azi2);

    printf("Distance: %.3f km\n", s12 / 1000);
    printf("Azimuth 1-2: %.2f degrees\n", azi1);
    printf("Azimuth 2-1: %.2f degrees\n", azi2);

    proj_destroy(P);
    proj_context_destroy(C);
    return 0;
}

Getting Started

  1. Install PROJ:

    sudo apt-get install libproj-dev proj-data
    
  2. Include PROJ in your C/C++ project:

    #include <proj.h>
    
  3. Compile with PROJ:

    gcc -o myprogram myprogram.c -lproj
    
  4. Run your program:

    ./myprogram
    

Competitor Comparisons

4,834

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.

Pros of GDAL

  • Broader functionality: GDAL supports a wide range of geospatial data formats and operations beyond just coordinate transformations
  • More extensive API: Offers bindings for multiple programming languages, including Python, Java, and C++
  • Includes raster and vector data processing capabilities

Cons of GDAL

  • Larger footprint: GDAL is a more complex library with a larger codebase and dependencies
  • Steeper learning curve: Due to its extensive functionality, it may take longer to master compared to PROJ

Code Comparison

PROJ (coordinate transformation):

PJ *P;
P = proj_create_crs_to_crs(PJ_DEFAULT_CTX, "EPSG:4326", "EPSG:3857", NULL);
proj_trans(P, PJ_FWD, coord);

GDAL (coordinate transformation):

OGRSpatialReference srcSRS, dstSRS;
srcSRS.importFromEPSG(4326);
dstSRS.importFromEPSG(3857);
OGRCoordinateTransformation *poCT = OGRCreateCoordinateTransformation(&srcSRS, &dstSRS);
poCT->Transform(1, &x, &y);

Both libraries offer coordinate transformation capabilities, but GDAL provides a more comprehensive set of geospatial tools and supports a wider range of data formats. PROJ is more focused on coordinate systems and transformations, making it lighter and potentially easier to use for specific tasks.

1,052

Python interface to PROJ (cartographic projections and coordinate transformations library)

Pros of pyproj

  • Python-specific implementation, offering seamless integration with Python ecosystems
  • User-friendly API designed for Python developers
  • Extensive documentation and examples tailored for Python users

Cons of pyproj

  • Limited to Python environment, lacking cross-language support
  • May have slightly slower performance compared to PROJ's C implementation
  • Dependent on PROJ library updates, potentially lagging behind new features

Code Comparison

PROJ (C):

PJ *P;
LP lp = { DEG_TO_RAD * longitude, DEG_TO_RAD * latitude };
XY xy;

if (!(P = proj_create(PJ_DEFAULT_CTX, "+proj=merc +ellps=clrk66 +lat_ts=33")))
    exit(1);
xy = proj_trans(P, PJ_FWD, lp);

pyproj (Python):

from pyproj import Proj

p = Proj(proj='merc', ellps='clrk66', lat_ts=33)
x, y = p(longitude, latitude)

Both PROJ and pyproj offer powerful projection capabilities, with PROJ providing a lower-level C implementation and broader language support, while pyproj focuses on Python-specific usage with a more intuitive API for Python developers.

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL

Pros of mapbox-gl-js

  • Offers a complete, interactive mapping solution with built-in rendering and user interaction capabilities
  • Provides extensive customization options for map styles and features
  • Supports both vector and raster tile formats

Cons of mapbox-gl-js

  • Larger file size and potentially higher resource usage due to its comprehensive feature set
  • May have a steeper learning curve for developers new to web mapping

Code Comparison

PROJ (coordinate transformation):

PJ *P;
P = proj_create_crs_to_crs(PJ_DEFAULT_CTX, "EPSG:4326", "EPSG:3857", NULL);
proj_trans(P, PJ_FWD, coord);

mapbox-gl-js (map initialization):

mapboxgl.accessToken = 'your-access-token';
const map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v11',
    center: [-74.5, 40],
    zoom: 9
});

Summary

PROJ focuses on coordinate transformations and geodetic computations, making it ideal for specialized geospatial applications. mapbox-gl-js, on the other hand, provides a complete web mapping solution with interactive features and customizable styles, suitable for creating user-friendly map interfaces. While PROJ is more lightweight and specialized, mapbox-gl-js offers a more comprehensive set of features for web-based mapping applications.

41,217

πŸƒ JavaScript library for mobile-friendly interactive maps πŸ‡ΊπŸ‡¦

Pros of Leaflet

  • User-friendly API for creating interactive maps in web browsers
  • Lightweight and mobile-friendly, with a small codebase
  • Extensive plugin ecosystem for additional functionality

Cons of Leaflet

  • Limited to web-based mapping applications
  • Less suitable for complex geospatial operations and transformations

Code Comparison

Leaflet (JavaScript):

var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
L.marker([51.5, -0.09]).addTo(map).bindPopup('A sample marker.');

PROJ (C):

PJ *P;
XY p;
LP lp;
P = proj_create(PJ_DEFAULT_CTX, "+proj=utm +zone=32 +datum=WGS84");
lp.lam = DEG_TO_RAD * 12.0;
lp.phi = DEG_TO_RAD * 55.0;
p = proj_trans(P, PJ_FWD, lp);

Summary

Leaflet is ideal for creating interactive web maps with a simple API, while PROJ is better suited for complex geospatial operations and coordinate transformations. Leaflet's strength lies in its ease of use and web focus, whereas PROJ offers more powerful tools for geodetic calculations and projections across various platforms.

10,476

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)

Pros of QGIS

  • Comprehensive GIS software with a user-friendly GUI
  • Extensive plugin ecosystem for additional functionality
  • Supports a wide range of geospatial data formats and operations

Cons of QGIS

  • Larger codebase and more complex architecture
  • Steeper learning curve for developers
  • Higher resource requirements for installation and usage

Code Comparison

PROJ (coordinate transformation):

PJ *P;
XY xy;
LP lp;

P = proj_create(PJ_DEFAULT_CTX, "+proj=merc +ellps=clrs66");
xy = proj_trans(P, PJ_FWD, lp);

QGIS (similar functionality):

from qgis.core import QgsCoordinateReferenceSystem, QgsCoordinateTransform, QgsProject

sourceCrs = QgsCoordinateReferenceSystem("EPSG:4326")
destCrs = QgsCoordinateReferenceSystem("EPSG:3857")
transform = QgsCoordinateTransform(sourceCrs, destCrs, QgsProject.instance())
point = transform.transform(lon, lat)

PROJ focuses on coordinate transformations and geodetic computations, while QGIS is a full-featured GIS application that incorporates PROJ functionality alongside many other geospatial tools and visualizations.

The Rails application that powers OpenStreetMap

Pros of openstreetmap-website

  • More active community with frequent updates and contributions
  • Broader scope, focusing on the entire OpenStreetMap ecosystem
  • User-friendly web interface for map editing and data management

Cons of openstreetmap-website

  • More complex codebase due to its broader functionality
  • Steeper learning curve for new contributors
  • Higher resource requirements for deployment and maintenance

Code Comparison

PROJ (C):

PJ *P;
XY lp;
LP xy;
P = proj_create(PJ_DEFAULT_CTX, "+proj=merc +ellps=clrk66 +lat_ts=33");
xy = proj_trans(P, PJ_FWD, lp);

openstreetmap-website (Ruby):

def index
  @map = Map.find(params[:id])
  @nodes = @map.nodes.includes(:tags)
  @ways = @map.ways.includes(:tags)
  @relations = @map.relations.includes(:tags)
end

The code snippets demonstrate the different focus areas of the projects. PROJ deals with coordinate transformations and projections, while openstreetmap-website handles web-based map rendering and data management.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

PROJ

Travis Status Docker build Status Coveralls Status Gitter Mailing List Contributor Covenant DOI

PROJ is a generic coordinate transformation software, that transforms coordinates from one coordinate reference system (CRS) to another. This includes cartographic projections as well as geodetic transformations.

For more information on the PROJ project please see the web page at:

https://proj.org/

The PROJ mailing list can be found at:

https://lists.osgeo.org/mailman/listinfo/proj/

See the NEWS.md file for changes between versions.

The following command line utilities are included in the PROJ package:

  • proj: for cartographic projection of geodetic coordinates.
  • cs2cs: for transformation from one CRS to another CRS.
  • geod: for geodesic (great circle) computations.
  • cct: for generic Coordinate Conversions and Transformations.
  • gie: the Geospatial Integrity Investigation Environment.
  • projinfo: for geodetic object and coordinate operation queries.
  • projsync: for synchronizing PROJ datum and transformation support data.

More information on the utilities can be found on the PROJ website.

Installation

Consult the Installation page of the official documentation. For builds on the master branch, install.rst might be more up-to-date.

Distribution files and format

Sources are distributed in one or more files. The principle elements of the system are stored in a compressed tar file named proj-x.y.z.tar.gz where "x" will indicate the major release number, "y" indicates the minor release number, and "z" indicates the patch number of the release.

In addition to the PROJ software package, distributions of datum conversion grid files and PROJ parameter files are also available. The grid package is distributed under the name proj-data-x.y.zip, where "x" is the major release version and "y" is the minor release version numbers. The resource packages can be downloaded from the PROJ website.

More info on the contents of the proj-data package can be found at the PROJ-data GitHub repository.

The resource file packages should be extracted to PROJ_LIB where PROJ will find them after installation. The default location of PROJ_LIB on UNIX-based systems is /usr/local/share/proj but it may be changed to a different directory. On Windows you have to define PROJ_LIB yourself.

As an alternative to installing the data package on the local system, the resource files can be retrieved on-the-fly from the PROJ CDN. A network-enabled PROJ build, will automatically fetch resource files that are not present locally from the CDN.

Citing PROJ in publications

See CITATION