rasterio mask aborts kernel. Potential issue with format for geojson feature?

by bw4sz   Last Updated May 15, 2018 19:22 PM

I have a pandas dataframe where each row is a bounding box. i'd like to crop my raster by each feature.

       xmin       xmax        ymin        ymax  \
1  398296.6  398301.46  3280997.15  3280998.96   

1  NEON_D03_OSBS_DP1_398000_3280000_classified_po...  

I first created a function to create a geojson polygon from each row.

def data2geojson(df):
    features = []
    insert_features = lambda X: features.append(
    df.apply(insert_features, axis=1)
    return geojson.FeatureCollection(features)

such that the output of each row looks like

{"geometry": {"coordinates": [[398534.16, 3280995.59], [398539.84, 3280995.59], [398539.84, 3280998.99], [398534.16, 3280998.99]], "properties": {"name": "NEON_D03_OSBS_DP1_398000_3280000_classified_point_cloud_laz_silva_10"}, "type": "Polygon"}, "properties": {}, "type": "Feature"}

The idea would be then to iterate through features to create the crops


This yields no error message, but just kills the python kernel.

My initial thought is that my format of the geojson is incorrect? I was following rasterio masking with GeoJSON from file issue

System info

3.6.5 | packaged by conda-forge | (default, Mar 30 2018, 00:00:55) 
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)]

Tags : geojson rasterio

Related Questions

Masking a list of geojson features Rasterio

Updated May 12, 2017 15:22 PM

Crop a raster using rasterio and geopandas

Updated July 11, 2017 00:22 AM

rasterio: ImportError: No module named tools.mask

Updated July 26, 2018 10:22 AM

rasterio masking with GeoJSON from file issue

Updated May 01, 2017 03:22 AM