lambgeo / docker-lambda

AWS Lambda friendly GDAL Docker images and AWS Lambda layer
MIT License
121 stars 17 forks source link

Geopandas and Fiona success! #51

Closed jcary741 closed 1 year ago

jcary741 commented 1 year ago

Not sure how to document this, but I managed to build a container with Geopandas and Fiona based on this project. Thanks so much!

A couple gotchas: 1) I had to add the following at the top of my handler file

import pyproj
pyproj.datadir.set_data_dir(os.path.join(os.path.dirname(__file__), 'share/proj'))

2) In order to get the final package size below 250MB, I used the following options for pip (based on https://github.com/szelenka/shrink-linalg) and trim some fluff:

RUN CFLAGS="-g0 -Wl,--strip-all -I/usr/include:/usr/local/include -L/usr/lib:/usr/local/lib" \
            pip install \
            --no-cache-dir \
            --compile \
            --global-option=build_ext \
            --global-option="-j 4" \
            --no-binary :all: \
            --target ${PACKAGE_PREFIX}/ \ fiona pandas geopandas shapely pyproj
# Remove tests, docs, and examples
RUN cd $PREFIX && rm -rf **/tests/ **/_testing/ **/doc/ **/examples/