Questions tagged [geocube]

Tool to convert geopandas vector data into rasterized xarray data.

Filter by
Sorted by
Tagged with
0 votes
1 answer
63 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
203 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
661 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....
Rick's user avatar
  • 129
5 votes
3 answers
263 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
116 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
3 votes
2 answers
1k 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
181 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
450 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... ...
Reut's user avatar
  • 1,960
0 votes
0 answers
41 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
406 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
569 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
709 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
606 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
705 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
152 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
4 votes
2 answers
3k views

How to create a GeoPandas GeoDataFrame from rasterio features?

I try to create a GeoDataFrame of paches of 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 a ...
Pierrick Rambaud's user avatar
1 vote
1 answer
640 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
  • 27
0 votes
1 answer
224 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
  • 27
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
  • 250
3 votes
1 answer
5k 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
0 votes
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
  • 499
1 vote
1 answer
2k 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
  • 676
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
8k 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
3 votes
2 answers
7k 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
  • 211
21 votes
3 answers
27k 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