PROJ for Android
v9.9.0AndroidPROJ 9.9.0 for React Native apps on Android, precompiled for arm64-v8a devices and the x86_64 emulator as @crossbind/port-proj-android.
npm install @crossbind/port-proj-android@betaInstall
The whole flow, including Expo, is in the React Native playbook.
Usage
The examples the WebAssembly page runs, as Android compiles them: the same headers and the same calls. They are checked on the WebAssembly build.
Transform a coordinate between two CRSs
The most used part of PROJ: proj_create_crs_to_crs picks the operation between two coordinate reference systems, proj_normalize_for_visualization puts longitude first, and proj_trans runs it forward or back.
UTM zone 35N 666370.51 4541552.49 28.978400 41.008200 Popular Visualisation Pseudo-Mercator 3225860.73 5013551.24
Write a CRS as WKT, a .prj, PROJJSON or a PROJ string
proj_create reads a CRS from an EPSG code or any definition; proj_as_wkt writes WKT2 or the ESRI WKT a shapefile's .prj holds, proj_as_projjson writes PROJJSON, and proj_as_proj_string the short PROJ string, which drops names and the area of use.
EPSG:32635 WGS 84 / UTM zone 35N +proj=utm +zone=35 +datum=WGS84 +units=m +no_defs +type=crs PROJCRS["WGS 84 / UTM zone 35N", PROJCS["WGS_1984_UTM_Zone_35N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",27.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] ProjectedCRS Transverse Mercator 0 27 0.9996 500000 0
Read where a CRS applies and the order of its axes
proj_get_area_of_use gives the region EPSG defines a CRS for, as a bounding box in degrees and a description. proj_crs_get_coordinate_system and proj_cs_get_axis_info give the axis order, which is latitude first for EPSG:4326 and northing first for Poland's grid.
EPSG:4326: Lat north (degree), Lon east (degree) | World. -180 -90 180 90 EPSG:2180: x north (metre), y east (metre) | Poland - onshore and offshore. 14.14 49 24.15 55.93 EPSG:2056: E east (metre), N north (metre) | Liechtenstein; Switzerland. 5.95 45.81 10.5 47.81
Measure distances, headings and areas on the ellipsoid
geod_inverse gives the shortest route between two points on the WGS 84 ellipsoid and its headings, geod_direct where a heading and a distance lead, and geod_polygonarea the area of a polygon. This is GeographicLib's algorithm, part of PROJ; it needs no CRS and no proj.db.
8080.310 km, leaving on 309.12°, arriving on 230.50° halfway at 54.1948, -22.5976 1145170.4 km², perimeter 4868.1 km
Find the EPSG code of a .prj, and the UTM zone of a point
A shapefile's .prj names no EPSG code. proj_identify matches it against the registry, with a confidence that drops when names are missing, as in a PROJ string. proj_get_crs_info_list_from_database lists the CRSs whose area of use contains a point.
EPSG:32635 WGS 84 / UTM zone 35N, confidence 100 EPSG:32635 WGS 84 / UTM zone 35N, confidence 70 Istanbul: EPSG:32635 WGS 84 / UTM zone 35N Sydney: EPSG:32756 WGS 84 / UTM zone 56S
What is different on Android
- The React Native plugin compiles your headers with the library inside Gradle's native build, so
npm run androidbuilds everything. - Named imports from
./native/<header>.hwork as on the web:await initNative()once, then call the classes. - There is no
m.FSand no/memfs: files live in the app's own storage, and your C++ takes their paths. - No Worker and no COOP or COEP:
runtime: 'mt'uses pthreads directly.
Other platforms
- PROJ overview: the apps, every platform's setup and the packages.
- PROJ for WebAssembly: browsers, Node.js and edge runtimes.
- PROJ for iOS: React Native apps on iOS.
- PROJ for WASI: command-line programs under wasmtime.
Facts on this page come from the port manifests in the repository and from what npm served on beta when the site was built. See the Libraries guide for the full consumer flow.