Skip to main content
added 22 characters in body
Source Link
Pieter
  • 4.6k
  • 1
  • 11
  • 26

For larger files, Geofileopsgeofileops uses multiprocessing with multiple parallel processes under the hood, and when multiprocessing is used. In that case, typically you need to use the if __name__ == "__main__": construct needs to be used to avoid this kind of issues (source).

Something like this:

import geofileops as gfo
import geopandas as gpd
import shapely.geometry
import numpy as np

if __name__ == "__main__":
    np.random.seed(42)

    r = np.random.rand
    p = 4

    polygons = [
        shapely.geometry.Polygon([[r(), r()], [r(), r()], [r(), r()], [r(), r()]])
        for _ in range(10**p)
    ]
    df = gpd.GeoSeries(polygons)

    df.to_file(f"example_{p}.gpkg")
    gfo.makevalid(input_path=f"example_{p}.gpkg", output_path=f"madevalid_{p}.gpkg")

Geofileops uses multiprocessing under the hood, and when multiprocessing is used, typically you need to use the if __name__ == "__main__": construct to avoid this kind of issues (source).

Something like this:

import geofileops as gfo
import geopandas as gpd
import shapely.geometry
import numpy as np

if __name__ == "__main__":
    np.random.seed(42)

    r = np.random.rand
    p = 4

    polygons = [
        shapely.geometry.Polygon([[r(), r()], [r(), r()], [r(), r()], [r(), r()]])
        for _ in range(10**p)
    ]
    df = gpd.GeoSeries(polygons)

    df.to_file(f"example_{p}.gpkg")
    gfo.makevalid(input_path=f"example_{p}.gpkg", output_path=f"madevalid_{p}.gpkg")

For larger files, geofileops uses multiprocessing with multiple parallel processes under the hood. In that case, the if __name__ == "__main__": construct needs to be used to avoid this kind of issues (source).

Something like this:

import geofileops as gfo
import geopandas as gpd
import shapely.geometry
import numpy as np

if __name__ == "__main__":
    np.random.seed(42)

    r = np.random.rand
    p = 4

    polygons = [
        shapely.geometry.Polygon([[r(), r()], [r(), r()], [r(), r()], [r(), r()]])
        for _ in range(10**p)
    ]
    df = gpd.GeoSeries(polygons)

    df.to_file(f"example_{p}.gpkg")
    gfo.makevalid(input_path=f"example_{p}.gpkg", output_path=f"madevalid_{p}.gpkg")
added 10 characters in body
Source Link
Pieter
  • 4.6k
  • 1
  • 11
  • 26

Geofileops uses multiprocessing under the hood, and when multiprocessing is used, typically you need to use the if __name__ == "__main__": construct to avoid this kind of issues (source).

Something like this:

import geofileops as gfo
import geopandas as gpd
import shapely.geometry
import numpy as np

if __name__ == "__main__":
    np.random.seed(42)

    r = np.random.rand
    p = 4

    polygons = [
        shapely.geometry.Polygon([[r(), r()], [r(), r()], [r(), r()], [r(), r()]])
        for _ in range(10**p)
    ]
    df = gpd.GeoSeries(polygons)

    df.to_file(f"example_{p}.gpkg")
    gfo.makevalid(input_path=f"example_{p}.gpkg", output_path=f"madevalid_{p}.gpkg")

Geofileops uses multiprocessing under the hood, and when multiprocessing is used, you need to use the if __name__ == "__main__": construct to avoid this kind of issues (source).

Something like this:

import geofileops as gfo
import geopandas as gpd
import shapely.geometry
import numpy as np

if __name__ == "__main__":
    np.random.seed(42)

    r = np.random.rand
    p = 4

    polygons = [
        shapely.geometry.Polygon([[r(), r()], [r(), r()], [r(), r()], [r(), r()]])
        for _ in range(10**p)
    ]
    df = gpd.GeoSeries(polygons)

    df.to_file(f"example_{p}.gpkg")
    gfo.makevalid(input_path=f"example_{p}.gpkg", output_path=f"madevalid_{p}.gpkg")

Geofileops uses multiprocessing under the hood, and when multiprocessing is used, typically you need to use the if __name__ == "__main__": construct to avoid this kind of issues (source).

Something like this:

import geofileops as gfo
import geopandas as gpd
import shapely.geometry
import numpy as np

if __name__ == "__main__":
    np.random.seed(42)

    r = np.random.rand
    p = 4

    polygons = [
        shapely.geometry.Polygon([[r(), r()], [r(), r()], [r(), r()], [r(), r()]])
        for _ in range(10**p)
    ]
    df = gpd.GeoSeries(polygons)

    df.to_file(f"example_{p}.gpkg")
    gfo.makevalid(input_path=f"example_{p}.gpkg", output_path=f"madevalid_{p}.gpkg")
Source Link
Pieter
  • 4.6k
  • 1
  • 11
  • 26

Geofileops uses multiprocessing under the hood, and when multiprocessing is used, you need to use the if __name__ == "__main__": construct to avoid this kind of issues (source).

Something like this:

import geofileops as gfo
import geopandas as gpd
import shapely.geometry
import numpy as np

if __name__ == "__main__":
    np.random.seed(42)

    r = np.random.rand
    p = 4

    polygons = [
        shapely.geometry.Polygon([[r(), r()], [r(), r()], [r(), r()], [r(), r()]])
        for _ in range(10**p)
    ]
    df = gpd.GeoSeries(polygons)

    df.to_file(f"example_{p}.gpkg")
    gfo.makevalid(input_path=f"example_{p}.gpkg", output_path=f"madevalid_{p}.gpkg")