Created
February 24, 2022 10:39
-
-
Save tastatham/1e7ada20d39edfa75ff8fbabb4aa259e to your computer and use it in GitHub Desktop.
dask_geopandas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import geopandas | |
import dask_geopandas | |
path = "https://geodata.ucdavis.edu/gadm/gadm4.0/gpkg/gadm40_USA.gpkg" | |
gdf = geopandas.read_file(path, layer="ADM_1") | |
gdf.head() | |
# Filter and rename cols | |
gdf = gdf[["NAME_1", "geometry"]].rename(columns={"NAME_1": "State"}) | |
gdf.info() | |
gdf.plot() | |
# We can quickly filter out non-US mainland areas by the `cx` method, which filters by a set of bounds | |
us_main = gdf.cx[-150:-50, 20:50] | |
us_main.plot(facecolor="none", linewidth=0.5, edgecolor="red") | |
d_gdf = dask_geopandas.from_geopandas(us_main, npartitions=4) | |
d_gdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment