0

Problem 1: Whenever I generate raster from a point using “geocube” I am noticing a shift in raster i.e., pixel center is not in line with the input point.

enter image description here

enter image description here enter image description here

Buffer snippet used is as follows

enter image description here

enter image description here

Note: If I gave like (xarray.Dataset, optional) , parameter to the make_geocube code is working fine. But I don`t want to use any like/template raster. Problem 2: while converting many point files to raster geocube is taking very long time to save raster into disk (when compared with rasterio, features.rasterize) while using geocube I can convert 10 vector files to rasters (saving on disk) takes around 40+ seconds, while using rasterio it is taking around 25+ seconds. How to make this thing faster.

sat06
  • 1
  • 2

1 Answers1

1

On GIS SE, you should ask one question at a time, so I will answer problem 1.

Without a template raster, geocube determines the area of the raster by the bounding box of the input geometries and resamples the geometries to the raster. That is why it looks how it currently looks

If you want the raster cells to be centered on each point, I recommend doing a square buffer using geopandas so each point turns into a grid cell. Creating square buffers around points using shapely?

import geopandas
import pandas
from geocube.api.core import make_geocube

pdf = pandas.read_csv("nz_points1.csv") gdf = geopandas.GeoDataFrame( pdf, geometry=geopandas.points_from_xy( x=pdf.Longitude, y=pdf.Latitude, crs="EPSG:4326", ).buffer(0.005, cap_style=3), ) out_grid = make_geocube(gdf, resolution=(-0.01, 0.01), measurements=["Temp"])

snowman2
  • 7,321
  • 12
  • 29
  • 54