0

I need a polygon that covers land and oceans. I found each polygon separately and used the function dissolve but the result did not make sense ( i have a big rectangle as shown below).

Here is the code

# world polygon
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))

#ocean polygons
ocean=import_shapes_list(path_to_data,shapes_folder,crs='EPSG:4326')

# plotted both polygons (land ans Sea) on Tableau and there are fine
Land = gpd.GeoDataFrame(world.geometry,columns=['geometry'])
Sea = gpd.GeoDataFrame(ocean.geometry,columns=['geometry'])

Combined=pd.concat([Land, Sea])

## dissolve geometry
Combined['world']='World'
Combined=Combined.dissolve(by=['world']).reset_index()[['world','geometry']]

Is there a way to get a polygon that covers the whole earth including oceans? Thank you

enter image description here

bravopapa
  • 309
  • 1
  • 10

1 Answers1

0

This answer worked for me:

from shapely.geometry import Polygon, LineString, Point
w_oceans = gpd.GeoSeries(
    [       
        Polygon([(-180, -90), (-180, 90), (180, 90), (180, -90), (-180, -90)]),
        
    ],)

w_oceans.to_file(path_to_output+'earth.geojson', driver="GeoJSON")

enter image description here

bravopapa
  • 309
  • 1
  • 10