raster

Create a raster from points (gpd.geodataframe object) in Python 3.6

Create a raster from points (gpd.geodataframe object) in Python 3.6 Question: I want to create a raster file (.tif) from a points file using a geopandas.geodataframe.GeoDataFrame object. My dataframe has two columns: [geometry] and [Value]. The goal is to make a 10m resolution raster in [geometry] point with the [Value] value. My dataset is: geometry …

Total answers: 2

Update raster values using Python

Update raster values using Python Question: I’m trying to read in a raster file. It’s a 32-bit float raster, with either values 1 or no data. I want to update the values of 1 to 10, and write it out again (probably as a UNIT8 data type?). Here is my attempt: import rioxarray import numpy …

Total answers: 1

How can I solve this "IndexError: index 774 is out of bounds for axis 0 with size 724"?

How can I solve this "IndexError: index 774 is out of bounds for axis 0 with size 724"? Question: Code: import geopandas as gpd import rasterio as rio capital_cities = gpd.read_file(r’C:UsersuserDesktopSHPBangladesh_shapefile_Feature.shp’) capital_cities[‘Temp’]=0 for index, row in capital_cities.iterrows() : city= row[‘DISTNAME’] longitude=row[‘geometry’].x latitude=row[‘geometry’].y temp_raster = rio.open(r’C:UsersuserDesktopOutput rasterc2019GDP_Clip.tif’) temp_data = temp_raster.read(1) rowIndex, colIndex = temp_raster.index(longitude, latitude) print(city …

Total answers: 1

Setting Discrete Colors in Matplotlib Imshow

Setting Discrete Colors in Matplotlib Imshow Question: I have seen numerous resources for establishing unique cmap color codes, such as: i) Merge colormaps in matplotlib ii) Python: Invalid RGBA argument 0.0 color points according to class iii) Defining a discrete colormap for imshow in matplotlib None of these quite answer my question. I have 900 …

Total answers: 1

How to automatically add a field directly in a .vrt?

How to automatically add a field directly in a .vrt? Question: I have a VRT file for which I would like to automatically add a color table. I vould like to add (in python) a field ColorTablea the correct location in the file. To be clear: I have the following lines: <VRTDataset rasterXSize=”40320″ rasterYSize=”14560″> <SRS>GEOGCS[“WGS …

Total answers: 2