Python:如何检查形状是否与栅格重叠?

时间:2019-06-20 10:07:44

标签: python gis rasterio

我正在与<query xmlns="http://marklogic.com/appservices/search"> <and-query> <collection-query> <uri>live</uri> </collection-query> <value-query type="string"> <element name="id" ns="" /> <text>${'content'}</text> </value-query> </and-query> </query> 一起工作,并尝试const withContext = (Context, propName) => (Component) => (props) => ( <Context.Consumer> {(value) => (React.createElement(Component, { ...props, [propName]: value }))} </Context.Consumer> ); const withThemeContext = withContext(ThemeContext, 'theme'); // MyComponent will have this.props.theme const MyComponent = withThemeContext(MyPureComponent); 如果rasterio成像五个形状。碰巧相同的形状不会与栅格重叠。例如我有一个循环

mask

例如某形状,当geotiff时出现以下错误:

import rasterio
from rasterio.mask import mask
import geopandas as gpd    

def getFeatures(gdf):
    """Function to parse features from GeoDataFrame in such a manner that rasterio wants them"""
    import json
    return [json.loads(gdf.to_json())['features'][0]['geometry']]

poly_df = gpd.read_file('myShape.shp')
data    =  rasterio.open('myFile.tiff') ## geotiff
for i in poly_df.index:
    geo = gpd.GeoDataFrame({'geometry': poly_df['geometry'][i]}, index=[0])
    coords = getFeatures(geo)
    out_img, out_transform = mask(data, coords, crop=True)

在制作蒙版之前,如何检查形状i = 14是否与栅格ValueError: Input shapes do not overlap raster. 重叠?

0 个答案:

没有答案