Skip to content

Commit

Permalink
point extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-halverson committed Nov 5, 2024
1 parent dca88b2 commit b2a35e5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rasters/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,12 @@ def bbox(self) -> BBox:
def geolocation(self) -> Raster:
return self.contain(geometry=self.geometry.geolocation)

def to_point(self, point: Point):
index = self.geometry.index_point(point)
value = self.array[index]

return value

# @profile
def to_grid(
self,
Expand Down Expand Up @@ -1086,7 +1092,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 +1123,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 b2a35e5

Please sign in to comment.