reproject-bbox

    0.3.0 • Public • Published

    reproject-bbox

    Reproject a Bounding Box

    install

    npm install reproject-bbox

    basic usage

    import reprojectBoundingBox from "reproject-bbox";
    
    const bbox = reprojectBoundingBox({
      bbox: [ -122.51, 40.97, -122.34, 41.11 ],
      
      // spatial reference system of input bounding box
      from: 4326,
      
      // convert bounding box to this spatial reference system
      to: 3857
    });
    
    // bbox is [-13637750.817083945, 5007917.677222896, -13618826.503649088, 5028580.202823918]

    advanced usage

    proj4-fully-loaded dependency

    This library depends on proj4-fully-loaded. If proj4-fully-loaded isn't found (perhaps because you used null-loader, then reproject-bbox will attempt to look for a valid proj4 at window.proj4.

    pluggable

    If you don't need any dependencies and would prefer to pass in a reprojection function, you can do so:

    import reprojectBoundingBox from "reproject-bbox/pluggable.js";
    
    const bbox = reprojectBoundingBox({
      bbox: [ -122.51, 40.97, -122.34, 41.11 ],
      reproject: proj4("EPSG:4326", "EPSG:3857").forward,
    });
    
    // bbox is [-13637750.817083945, 5007917.677222896, -13618826.503649088, 5028580.202823918]

    Install

    npm i reproject-bbox

    DownloadsWeekly Downloads

    365

    Version

    0.3.0

    License

    CC0-1.0

    Unpacked Size

    413 kB

    Total Files

    6

    Last publish

    Collaborators

    • danieljdufour