Skip to main content

Questions tagged [geocube]

Tool to convert geopandas vector data into rasterized xarray data.

Filter by
Sorted by
Tagged with
1 vote
1 answer
42 views

rio.to_raster returns ValueError: cannot convert float NaN to integer

Maybe this is more like a Pandas question but when I try to write an xarray to a raster using rio.to_raster() I get a ValueError in Python. If I don't convert the type of xarray to int16 (this is a ...
Andrei Niță's user avatar
0 votes
0 answers
13 views

Unexpected result with all_touched in geocube

I am using the geocube.api.core.make_cube function as a way to build a template array for fast data extraction in my pipeline. Basically, I will use this template array to store the row-index of a gpd....
topcat's user avatar
  • 327
0 votes
1 answer
125 views

How to rasterize point data using average value per cell (not replace or add)

I have a geopandas.GeoDataFrame containing point observations that I would like to rasterize into a grid with a certain resolution, such that, for cells that contain multiple observations, the ...
lusk's user avatar
  • 111
0 votes
0 answers
93 views

Saving my Geocube object as a raster is way too big

I am rasterizing some polygon data with make_geocube and exporting the result as a .tif file. It works, but my file sizes are orders of magnitude larger (10-20x) what I am expecting them to be after ...
Vance's user avatar
  • 1
-1 votes
1 answer
48 views

Extending raster after rasterizing geodataframe using geocube

I have created rasterized a geodataframe using geocube make_geocube. The resulting xr.Dataset now has the extent of the underlying geodataframe vector data. Say, the bounding box would be covering ...
ChipChap's user avatar
1 vote
0 answers
47 views

How to create point-centered cells grid with geocube

I want to create a tiff file starting from a numpy array which contains temperature data points in the format lat,lon,T2 My data array (the columns contain respectively cell number,temperature,lon,lat)...
Andrea's user avatar
  • 69
0 votes
1 answer
404 views

Rasterizing shapefiles using Geocube

I am trying to create a raster from a shapefile, with cells assigned a value from a specific column within the shapefile. I am using geocube below but am getting an error saying AttributeError: '...
penguin's user avatar
1 vote
1 answer
724 views

Mask NetCDF data in Python with shapefile

Precursor to this question: Masking NetCDF data with a shapefile in that has more than one variable Python. Note: Data files are in the previous question. I am trying to mask my polygon but I don't ...
Julius Bamah's user avatar
2 votes
3 answers
2k views

Creating GeoTIFF from Pandas DataFrame

I have a Pandas DataFrame that looks like this: SIF_743,latitude,longitude 0.7626782059669495,-85.90831756591797,22.40107536315918 0.3139636516571045,-85.9532470703125,22.630943298339844 0....
Rezwan's user avatar
  • 199
5 votes
3 answers
345 views

Raster Statistics of Fire Driven Forest Loss within shapefile

I have two inputs, a) shapefile, which I am reading in as a geodataframe, download here: https://we.tl/t-QxfgtLWOVN b) raster data from - GFW Fire Driven Forest Loss dataset, download here: https://...
Stuey17's user avatar
  • 199
1 vote
1 answer
225 views

How to properly use geocube geom parameter with crs other than 4326

I dont fully understand how to use the "geom" parameter in python geocube library with crs different than 4326, described here: https://corteva.github.io/geocube/stable/geocube.html#make-...
XDOLK009's user avatar
  • 183
6 votes
2 answers
3k views

Vectorizing a raster containing holes using rasterio

I want to vectorize raster that contains holes (nodata) in the areas with valid data. My current version uses rasterio.features.shapes: shape_list = list(shapes(raster.values, mask=raster.values !=...
Sebastian H's user avatar
1 vote
1 answer
352 views

How to use geocube with option -at (all_touched=TRUE)

In the code below, I'm trying to rasterize "roads" and "cube" to 128x128 pixels with a 10m spatial resolution for each pixel. First, I want to rasterize roads separately to make ...
Oskar's user avatar
  • 11
0 votes
1 answer
708 views

Rasterize GeoPandas with GeoCube into bbox extent

I have GeoPandas dataframe which has one column with code. id geometry code 0 1 MULTIPOLYGION (((-52.65767 -13.75468, -52.65767... ...
ReutKeller's user avatar
  • 2,149
0 votes
0 answers
42 views

Summing rasters in python with different shapes [duplicate]

I have a polygons shapefile with many individual overlapping polygons, each containing a unique value in the "Value" column. I want to iterate over each polygon in this shapefile (feature in ...
LostinSpatialAnalysis's user avatar
0 votes
1 answer
567 views

Trying to process rasters in python and received CPLE_OutOfMemoryError error

I have a script that does some geoprocessing, that makes sense in a test run, but when I actually try to use it with my actual dataset, appears to totally overload my computer with memory needs, and I ...
LostinSpatialAnalysis's user avatar
2 votes
3 answers
897 views

Rasterize and sum polygons in Python

I have the following shapefile of NYC with all 5 Boroughs as separate polygons, called Boroughs.shp. Data Source (NYC OpenData): https://data.cityofnewyork.us/City-Government/Borough-Boundaries/tqmj-...
LostinSpatialAnalysis's user avatar
1 vote
1 answer
1k views

How to rasterize each polygon in shapefile using geocube [python]?

I am trying to take shapefile Boroughs3.shp and rasterize each polygon (row) as its own raster layer, where each new raster would each contain a separate and isolated rasterized polygon. For context, ...
LostinSpatialAnalysis's user avatar
3 votes
1 answer
1k views

Using geocube in Python to rasterize each polygon in shapefile

I have a shapefile of polygons that I brought into Python in Jupyter Notebook via GeoPandas as a geodataframe. There are hundreds of polygons in this shapefile, and I want to create an individual ...
LostinSpatialAnalysis's user avatar
0 votes
1 answer
1k views

Point file to Raster conversion using "geocube"

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. Buffer snippet used is as follows Note: If ...
sat06's user avatar
  • 1
0 votes
0 answers
187 views

CRSerror in geocube make_geocube

I get the error below when i run the example by snowman2 here Rasterizing polygon grid in Python (geopandas & rasterio) CRSError: CRS is invalid: <Geographic 2D CRS: EPSG:4326> Name: WGS 84 ...
Ikey's user avatar
  • 1
7 votes
3 answers
4k views

Creating GeoPandas GeoDataFrame from rasterio features

I try to create a GeoDataFrame of paches of the same values in a binary raster using rasterio and GeoPandas. data_file is a binary TIFF raster with 0 where there is no deforestation and 1 if there is ...
Pierrick Rambaud's user avatar
1 vote
1 answer
825 views

rioxarray and vector data (including geocube)

I currently got some problem with rioxarray and geocube. I hope, this is the right place to ask. I am using a vector file for the German state of Brandenburg, so it has a massive hole in it. The file ...
tetje's user avatar
  • 99
0 votes
1 answer
253 views

Extraction affine transformation while using rasterio.features.rasterize

I am currently using rasterio.features.rasterize to rasterize my shapefile. But currently I am always using an Rasterfile to a) rasterize and b) save on disk. The get the information of the ...
tetje's user avatar
  • 99
0 votes
0 answers
2k views

Geopandas geodataframe copy with where clause causes geometry issues

Question up front: What is likely happening here, where when I take copy of the dataframe with a where clause present that there is an apparent break in the geometry, as implied by the linestring ...
anakaine's user avatar
  • 290
3 votes
1 answer
7k views

Convert GeoDataframe to Raster [closed]

I want to convert a GeoPandas GeoDataframe to raster (.tif). I have multiple attributes in my GeoDataframe and want to create a raster using a single field from the attribute table. The underlying ...
DrSnuggles's user avatar
1 vote
2 answers
2k views

Extract population count from GeoTIFF based on mask layer

I downloaded Population Count data from Gridded Population of the World (GPW), v4 as a *.GeoTIFF file. In a next step, I would like to extract the population count of a given area based on a mask ...
Stücke's user avatar
  • 529
1 vote
1 answer
3k views

Shapely Polygon to numpy boolean mask [closed]

How can I convert my Shapely polygon to a numpy pixel array representing a boolean mask, with True for where the polygon is?
Saffron Huang's user avatar
2 votes
1 answer
2k views

Rasterising multiple shapefiles into a single raster

I'm not even sure you can do this, but I want to convert multiple shapefiles into a single single-band raster. I'm pretty sure its going to be easier to first create a multi-band raster and then use ...
Nebulous29's user avatar
2 votes
1 answer
1k views

What data structure to use for raster data when using rasterio?

I want to write a method in Python that reads a raster (GTiff) using rasterio and returns its contents. Then, some processing is done. Finally, I want to write the data to a new GeoTiff. As far as I ...
Jan Pisl's user avatar
  • 726
0 votes
1 answer
1k views

Rasterising shapefile in Python? [closed]

I am trying to rasterize a shapefile with Python using ogr, but if you know to do with other libraries as fiona, I am interested in too. I use the shapefile in the following website: https://www....
AnthonyB's user avatar
6 votes
1 answer
10k views

Rasterizing polygon grid in Python (geopandas & rasterio)

I am trying to rasterize a custom polygon grid with one or more columns. Preferably I'd like to create multi-band rasters from multiple GeoDataFrame columns (in polygon grid), but I have got stuck ...
reima's user avatar
  • 638
4 votes
2 answers
8k views

How to convert vector format (geopackage, shapefile) to raster format (geotiff) using rasterio without template raster

I'm looking to create a raster given just a geopackage (or shapefile, or other vector format). I don't have a template raster, and all I wish to do is burn the shapes into a raster using rasterio. ...
Kirk's user avatar
  • 221
22 votes
3 answers
32k views

Rasterize a shapefile with Geopandas or fiona - python

I need to rasterize a really simple shapefile a bit like this http://tinyurl.com/odfbanu. Which is just a shapefile containing counties in the US. I have seen this previous answer: GDAL RasterizeLayer ...
User18981898198119's user avatar