3

I need to get simplified boundaries of all countries with some buffer around them (20 km). I am using QGIS, I converted my country polygons vector layer from 4326 to 3857, set buffer, used simplify and the result looks OK.

EPSG:3857

Then, when I try to convert the layer with the new polygons to 4326 I get some malformed polygons for Russia, Fiji, Antarctica, and Tuvalu - I think it's because they appear on both east and west sides of the map in the 4326 projection. Then, when I try to use the "split vector layer" function, it says incorrect geometry.

EPSG:4326

Is there any way, how to do it "correctly"? I am new to QGIS, I need this for my other project.

5
  • 1
    I think it's because the buffer has extended the polygons outside of the projection's extent. Why are you converting from 4326 to 3857, then doing the buffer and then coverting back to 4326? Couldn't you just buffer the 4326 data which would solve your problem. Also I would then create a boundary box polygon of the 4326 projection's extent and cut the buffered bits that are outside of that extent using the difference tool.
    – Trashmonk
    Commented Jan 11, 2021 at 22:58
  • 1
    4326 has units in degrees, so buffering-distance would be difficult. However, 3857 is not ideal, either.
    – Babel
    Commented Jan 11, 2021 at 23:02
  • Of Course, forgot about that. He could still difference the 3857 buffered layer with a boundary box which would fix the problem and then convert back to 4326. I see your point about 3857 not being ideal, but it might be accurate enough for what he needs.
    – Trashmonk
    Commented Jan 11, 2021 at 23:10
  • I already tried clipping the layer to prevent layer's extension beyond the bounds, but the result was the same. And as babel said, I need some projection, where I could define buffer in km, do you recommend any other than EPSG:3857? Commented Jan 12, 2021 at 7:19
  • 1
    @TomášČerný I would use Mollweide epsg.io/54009 it will give you more realistic results Commented Jan 12, 2021 at 8:21

1 Answer 1

1

EDIT 2 05/02/2023 : Corrected code so it works properly

EDIT 1 05/02/2023 : I just realized my data is completely broken (all geometry were swapped) after the .clip (e.g. Argentina has the geometry of the USA for instance). I will try to find why.

I had the same problem using the admin0 shapefile from the Worldbank "WB_countries_Admin0". Although in my case I am not using QGIS but geopandas.

I found that the total boundaries were [-180., -59.47275156, 180., 83.63410065] and guessed that the problem came from the -180,180 couple.

I am clueless on how to do it with QGIS, but here is how I fixed it using python/geopandas.

import geopandas as gdp

wb_world_original = gpd.read_file("path/to/WB_countries_Admin0.geojson")
wb_world_corrected = wb_world_original.copy()
wb_world_corrected["geometry"] = wb_world["geometry"].clip((-180, -59.48, 179.9999999, 83.64))

Here are the results I obtain, plotted with matplotlib.

resulting maps

1
  • GeoJSON is not EPSG:4326, GeoJSON is long/lat and EPSG:4326 is lat/long
    – nmtoken
    Commented May 23, 2023 at 14:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.