Skip to content

Commit

Permalink
Merge pull request #24 from gregory-halverson/main
Browse files Browse the repository at this point in the history
working on point extraction
  • Loading branch information
gregory-halverson authored Nov 5, 2024
2 parents dca88b2 + 1bfc631 commit 081e399
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion rasters/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,15 @@ def bbox(self) -> BBox:
def geolocation(self) -> Raster:
return self.contain(geometry=self.geometry.geolocation)

def to_point(self, point: Point):
if not self.geometry.intersects(point):
return np.nan

index = self.geometry.index_point(point)
value = self.array[index]

return value

# @profile
def to_grid(
self,
Expand Down Expand Up @@ -1086,7 +1095,7 @@ def to_geolocation(

def to_geometry(
self,
target_geometry: RasterGeometry,
target_geometry: Union[RasterGeometry, Point],
resampling: str = None,
search_radius_meters: float = None,
kd_tree: KDTree = None,
Expand Down Expand Up @@ -1117,6 +1126,8 @@ def to_geometry(
kd_tree=kd_tree,
**kwargs
)
elif isinstance(target_geometry, Point):
return self.to_point(target_geometry)
else:
raise ValueError(f"unsupported target geometry type: {type(target_geometry)}")

Expand Down

0 comments on commit 081e399

Please sign in to comment.