Skip to content

Commit

Permalink
swap order of imports to avoid python crash; osgeo needs to be after …
Browse files Browse the repository at this point in the history
…shapely
  • Loading branch information
nicolepaul committed May 18, 2021
1 parent aae5359 commit 26088db
Show file tree
Hide file tree
Showing 7 changed files with 406,593 additions and 38,557 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Avoid large files
data/worldpop/*.tif

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The dependencies are as follows:

* numpy
* pandas
* fiona
* geopandas
* rasterio
* shapely^
Expand All @@ -25,7 +26,7 @@ The dependencies are as follows:
*^There is currently a known issue where importing from shapely returned an AssertionError when loading the GEOS library. This can be resolved by installing shapely before fiona, rasterio, and GDAL. See [this link](https://sgillies.net/2019/06/23/fix-for-geos-dll-bug-shapely-1-7a2.html) for more details. If that doesn't work, try using the command ``pip install shapely --no-binary shapely``*


*^^GDAL requires installation prior to ``pip`` installation. This can be done using ``brew``. Windows users might consider installing GDAL using [OSGeo4W](https://trac.osgeo.org/osgeo4w/). macOS users might consider using the [KyngChaos installer](https://www.kyngchaos.com/software/frameworks/)*
*^^GDAL requires installation prior to ``pip`` installation. This can be done using ``brew``. Windows users might consider installing GDAL using [OSGeo4W](https://trac.osgeo.org/osgeo4w/). macOS users might consider using the [KyngChaos installer](https://www.kyngchaos.com/software/frameworks/). Additionally, if the ``pip`` installation fails, be sure to check that the versions between ``brew`` and ``pip`` correspond to one another.*

## Getting started

Expand Down
13 changes: 11 additions & 2 deletions _config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
import rasterio.transform
import rasterio.mask
from rasterio import Affine
from osgeo import gdal, gdalconst

# Shapefiles - working with vector data
import shapely.geometry
from shapely.ops import cascaded_union
import geopandas as gpd

# GDAL
from osgeo import gdal, gdalconst

# Numeric
import pandas as pd
import numpy as np
Expand All @@ -53,13 +55,19 @@
# data
res = 0.01

# Desired coordinate reference system
# Desired coordinate reference system corresponding to input files
desired_crs = "EPSG:4326"
# Desired coordinate reference system for calculating areas (you may need to
# look up which flat projection would work well for your region); however it's
# not particularly important to the calculation and therefore OK to be a bit
# inaccurate
area_crs = "EPSG:3035" # Suitable for EU

# Input shapefile parameters - field_name needs to exist in both the input
# shapefile and the input exposure CSV file. Directly replace field_name
# with the field of interest
adm_level = 3
# adm_level = 1
field_name = f"ID_{adm_level}"

# Threshold for checking that sampled asset counts match original input
Expand Down Expand Up @@ -98,6 +106,7 @@

# File locations - inputs
name = "Portugal"
# name = "Austria"
shp_file = f"Adm{adm_level}_{name}.shp"

# Directory locations - outputs
Expand Down
Loading

0 comments on commit 26088db

Please sign in to comment.