1

I'm making a map on Pyhton and someone recommended that I reporject it to lon=30 for better visuals. But when I do that a random line over Greenland appears. I can't seem to get rid of it.

import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import seaborn as sns
import geopandas as gpd
import os
import zipfile
import pyproj

# Define A1 paper size in inches
a1_width_inches = 33.1
a1_height_inches = 23.4

# Specify the shapefile URL and filename
shapefile_url = "https://naturalearth.s3.amazonaws.com/110m_cultural/ne_110m_admin_0_countries.zip"
shapefile_zip = "ne_110m_admin_0_countries.zip"
shapefile_name = "ne_110m_admin_0_countries.shp"

# Download the shapefile if it doesn't exist
if not os.path.exists(shapefile_name):
    # Download the zip file
    !wget {shapefile_url} -O {shapefile_zip}

    # Extract the shapefile
    with zipfile.ZipFile(shapefile_zip, 'r') as zip_ref:
        zip_ref.extractall()

    print(f"Shapefile downloaded and extracted to: {shapefile_name}")

# Load the world map data directly from the downloaded file
world = gpd.read_file(shapefile_name)

# Define the Winkel Tripel projection
winkel_tripel_crs = "+proj=wintri +lon_0=30 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"

# Reproject the GeoDataFrame
world = world.to_crs(winkel_tripel_crs)
2
  • You need to command to download os.system(f"wget {shapefile_url} -O {shapefile_zip}") Commented May 18 at 12:07
  • gis.stackexchange.com/questions/429384/… Commented May 31 at 16:23

1 Answer 1

0

I think this may be a problem with whatever display software you're using for the file. When I load "ne_110m_admin_0_countries.shp" using https://mapshaper.org/ it works just fine, and I can not find any lines over Greenland.

Sign up to request clarification or add additional context in comments.

2 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
Thank you for your suggestion! I don't think the problem is the shapefile. That is definitely working correctly (I have used it on QGIS in the past). The problem is with the reporjection to Winkel Tripel and the lon_0=30. But I want to have that for aesthetics, I just don't know how to fix the line over Greenland. This is what AI suggested, but I still can't seem to remove the line over Greenland. 1. Use geopandas with shapely’s buffer(0) trick to clean geometry 2. Clip the coordinates or filter very small geometries

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.