title: How can I fix ValueError: Input shapes do not overlap raster in python?
body: <p>I want to:</p>
  <ol>
  <li>Create a masked version of the input raster where pixels falling within one of the fields are set to <code>1</code> and pixels outside the fields are set to <code>0</code> then</li>
  <li>Reproject the input raster to the provided CRS</li>
  </ol>
  <p>Cde:</p>
  <pre><code>import fiona
  import rasterio
  import rasterio.mask
  import pycrs
  
  
  def masked_raster(input_file, raster_file):
      # Create a masked version of the input raster where pixels falling within one of the fields are set to `1` and pixels outside the fields are set to `0`
      
     
      data = rasterio.open(raster_file)
      
  
      #creating the a bounding box with Shapely
      ## WGS84 coordinates
      minx, miny = 24.60, 60.00
      maxx, maxy = 25.22, 60.35
      bbox = box(minx, miny, maxx, maxy)
  
      #inserting the bounding box into GeoDataFrame
      geo = geopandas.GeoDataFrame({'geometry': bbox}, index=[0], crs=from_epsg(4326))
  
      #Re-project into the same coordinate system as the raster data
      geo = geo.to_crs(crs=data.crs.data)
  
      #get the coordinates of the geometry in a proper format of rasterio
      def getFeatures(gdf):
        &quot;&quot;&quot;Function to parse features from GeoDataFrame in such a manner that rasterio wants them&quot;&quot;&quot;
        import json
        return [json.loads(gdf.to_json())['features'][0]['geometry']]
  
      #Getting the geometry coordinates by using the function
      coordinates = getFeatures(geo)
      # mask to clip the raster with the polygon using the coords variable
      out_img, out_transform = mask(data, shapes=coordinates, crop=True)
  
      out_img = rasterio.open(raster_file).read()
      return out_img
  
  def reproject_raster(raster_file, dst_crs):
      # Reproject the input raster to the provided CRS
      
      src = rasterio.open(raster_file)
      
      # Parse EPSG code
      epsg_code = int(data.crs.data['init'][5:])
  
      #copy metadata
      out_meta = raster_file.meta.copy()
      #update the metadata with new dimensions, transform (affine) and CRS 
      out_meta.update({&quot;driver&quot;: &quot;GTiff&quot;, &quot;height&quot;: out_img.shape[1], &quot;width&quot;: out_img.shape[2], &quot;transform&quot;: out_transform, &quot;crs&quot;: pycrs.parser.from_epsg_code(epsg_code).to_proj4()})
  
      #save the clipped raster to disk
      with rasterio.open(out_tif, &quot;w&quot;, **out_meta) as dst:
        dst.write(out_img)
  
  
      dst = src
      
      return dst
  
  # Run this to validate your function works correctly
  
  assert masked_raster('crops.geojson', 'crops.tif')[0].sum() == 1144636.0, &quot;Sorry wrong answer&quot;
  assert str(reproject_raster('crops.tif', 'EPSG:4326').crs) == 'EPSG:4326', &quot;Sorry wrong answer&quot;
  print(&quot;Congratulations, all is working just fine !!!&quot;)
  </code></pre>
  <p>Error:
  <a href="https://i.stack.imgur.com/xIgV3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xIgV3.png" alt="enter image description here" /></a></p>
  <p><a href="https://github.com/spchaane/help_line.git" rel="nofollow noreferrer">Git Repo Link</a></p>