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.

How to Add Data Layers on Custom Projections

See original GitHub issue

https://github.com/jupyter-widgets/ipyleaflet/pull/598 added the ability to display maps with custom projections, which is highly useful for the polar regions!

It’s a bit unclear currently what is supported for adding data layers onto maps with custom projections. According to the Proj4Leaflet readme it seems straightforward to support GeoJSON and Image Overlays, but as far as I can tell this isn’t yet supported (ipyleaflet 0.13.0).

Here is a full gist (https://gist.github.com/scottyhq/39b39917e851a2fc691fa6e6d9716794) with a few self-contained examples for adding a coastline layer or simple bounding box for the south pole (projections.EPSG3031)

Default projection Screenshot 2020-06-09 10 28 35

SPS projection Screenshot 2020-06-09 10 28 24 And for the north polar projection (projections.EPSG3413) here is an example from @betolink with screenshot showing offset polygons

from ipyleaflet import Map, GeoJSON, projections
import json
import os
import requests

if not os.path.exists('europe_110.geo.json'):
    url = 'https://github.com/jupyter-widgets/ipyleaflet/raw/master/examples/europe_110.geo.json'
    r = requests.get(url)
    with open('europe_110.geo.json', 'w') as f:
        f.write(r.content.decode("utf-8"))

with open('europe_110.geo.json', 'r') as f:
    data = json.load(f)

m = Map(center=(60, 0), zoom=2,  crs=projections.EPSG3413)
geo_json = GeoJSON(data=data, style = {'color': 'green', 'opacity':1, 'weight':1.9, 'dashArray':'9', 'fillOpacity':0.1})
m.add_layer(geo_json)

m
Screenshot 2020-06-09 10 38 11

cc @davidbrochart @asteiker

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
davidbrochartcommented, Jul 1, 2020

FYI xarray-leaflet just got initial support for custom projections, see this example.

1reaction
scottyhqcommented, Jun 11, 2020

Thanks so much for looking into this and providing a workaround @betolink !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting A Map Projection for Single and Multiple Layers in ...
STEP 1: Download and examine the (meta)data · STEP 2: Add the data to the map window in Pro · STEP 3: Change...
Read more >
Define a new coordinate system—ArcGIS Pro | Documentation
On the Map Properties dialog box, on the Coordinate Systems tab, highlight the Current XY button. · Click the Add Coordinate System button...
Read more >
How To: Create a custom projection file in ArcMap to align ...
Procedure · Open ArcMap with a new empty map, and add data the CAD file is supposed to line up with. · Add...
Read more >
Custom Projections | Drupal.org
Navigate to Structure → OpenLayers → Layers and click Add above the list as before with the projections. Enter the settings of the...
Read more >
10. Working with Projections - QGIS Documentation
Add nadgrids ( +nadgrids=nameofthefile.gsb ) to the Proj definition in the Parameters field of the Custom Coordinate Reference System Definition ...
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