Skip to content

Instantly share code, notes, and snippets.

@grinsted
Created June 21, 2023 10:21
Show Gist options
  • Save grinsted/623b6c44b26ba0f02a93aa0e54cdf285 to your computer and use it in GitHub Desktop.
Save grinsted/623b6c44b26ba0f02a93aa0e54cdf285 to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point, Polygon
zwally = np.loadtxt('grndrainagesystems_ekholm.txt',skiprows=7)
regions = np.unique(zwally[:,0])
for region in regions:
z = zwally[np.abs(zwally[:,0]-region)<0.001,1:]
#p = gpd.GeoSeries(map(Point, zip(z[:,1], z[:,0])),crs = 'EPSG:4326')
p = gpd.GeoSeries([Polygon(np.fliplr(z))],crs = 'EPSG:4326')
p = p.to_crs('epsg:3413')
p.to_file("zwallybasins.gpkg", layer=f'{region:.1f}', driver="GPKG")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment