question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] add built in coordinate conversions

See original GitHub issue

Hello,

The GIS and mapping capability of Bokeh is good and growing but lacks ability to convert units between (lat,lon) pairs and Web Mercator Easting and Northing coordinate pairs.

pyproj is a simple, focused and mature coordinate conversion utility for converting between recognized standard coordinate frames.

Adding pyproj or a similar capability would allow native Bokeh code and examples to perform coordinate conversions as a normal part of GIS mapping and plotting. For example, this code and associated documentation example could be included: bokeh_tiles_example

I propose adding pyproj. How can this get considered for the next version update?

Alternative codes and methods:

  1. OpenStreetMap Mercator wiki with conversions written in multiple programming languages
  2. Web Mercator projection wiki has formulas and good explanations

References:

  1. discourse link located here.
  2. pull request with working example except for pyproj dependency.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:21 (21 by maintainers)

github_iconTop GitHub Comments

1reaction
jbednarcommented, May 15, 2020

For what it’s worth, Datashader also needed the specific projection from lon,lat to web Mercator for our examples, and to avoid having a dependency on pyproj we just added that specific function in a numpy/pandas compatible form:

import numpy as np 
def lnglat_to_meters(longitude, latitude):
    """
    Projects the given (longitude, latitude) values into Web Mercator
    coordinates (meters East of Greenwich and meters North of the Equator).

    Longitude and latitude can be provided as scalars, Pandas columns,
    or Numpy arrays, and will be returned in the same form.  Lists
    or tuples will be converted to Numpy arrays.

    Examples:
       easting, northing = lnglat_to_meters(-40.71,74)

       easting, northing = lnglat_to_meters(np.array([-74]),np.array([40.71]))

       df=pandas.DataFrame(dict(longitude=np.array([-74]),latitude=np.array([40.71])))
       df.loc[:, 'longitude'], df.loc[:, 'latitude'] = lnglat_to_meters(df.longitude,df.latitude)
    """
    if isinstance(longitude, (list, tuple)):
        longitude = np.array(longitude)
    if isinstance(latitude, (list, tuple)):
        latitude = np.array(latitude)

    origin_shift = np.pi * 6378137
    easting = longitude * origin_shift / 180.0
    northing = np.log(np.tan((90 + latitude) * np.pi / 360.0)) * origin_shift / np.pi
    return (easting, northing)
0reactions
comperemcommented, May 8, 2021

@bryevdv ,

Did the simple GIS coordinate conversion submitted by @jbednar [immediately above] (https://github.com/bokeh/bokeh/issues/10009#issuecomment-636555037) ever get added?

It looks like this task was dropped, or never initiated. If I recall correctly, this unit conversion code was the only remaining detail needed to get the mapping tile demo integrated into the Bokeh code base.

What’s the next step to completion?

This thread is already a feature request. How about putting that function in a new file in a new folder called GIS_utils or something similar?

Nobody knows how to proceed except seasoned maintainers.

Marc

Read more comments on GitHub >

github_iconTop Results From Across the Web

CoordinateConversion | ArcGIS Maps SDK for JavaScript 4.25
The CoordinateConversion widget provides a way to display user cursor position either as map coordinates or as any of several popular coordinate notations....
Read more >
How to convert coordinate system of a set of points using ArcGis
converting coordinates on ArcGisTo see more videos visit website : http://monde-geospatial.com/
Read more >
How To: Convert polygon features to point ... - Esri Support
In ArcMap, click the Search button, and search for the Add Geometry Attributes tool. Click the Add Geometry Attributes tool to open the...
Read more >
CoordinateTransformations - Intelligent Motion Lab
Many common spatial transformations, including translations, rotations, and scaling are represented by matrix / vector operations. Changes of coordinate frames ...
Read more >
Coordinate Conversions - L3HarrisGeospatial.com
This coordinate conversion functionality is built into object graphics through the XCOORD_CONVERT and YCOORD_CONVERT properties or each type of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found