Create a transparent layer with Stamen in Folium

53 Views Asked by At

I'm trying to create a map using Folium in Python, and I would need to do the following: I have a geojson that contains the outline of Spain (or of a country or a municipality in Spain), and I want that when creating the map, the Stamen layer that is not inside the geojson (or the country's outline) appears blurred, transparent, or with a white layer, while what is inside my polygon is perfectly visible with the Stamen layer. How could I achieve this?

1

There are 1 best solutions below

0
rioV8 On

You have to transform your geojson to the inverse.

Create a really big rectangle encompassing the whole world consisting of 2 shapes that combined have a hole that is your starting contour.

In the starting contour find the most top and bottom geo points.

Create shape 1:

  • start at north pole
  • go to top geo point
  • add points of contour going clockwise until you reach bottom geo point
  • go to south pole
  • go west to the date marker line (180 east)
  • close the shape

Create shape 2:

  • start at south pole
  • go to bottom geo point
  • add points of contour going clockwise until you reach top geo point
  • go to north pole
  • go east to the date marker line (180 west)
  • close the shape

Use this new geojson to color these regions white on the map.