Date   

Re: CRS is invalid : None

Denis Rykov
 

As far as I can see from your example you are getting error during the call of reproject function. Which type has heat1 object? If it is ndarray then you need to pass src_crs argument to reproject.


CRS is invalid : None

Serigne Mansour DIENE
 

Hello to all,
I'm doing a code to reproject an image to another one using gcps but I always get this error. I tried to use default_transform to get the affine transformation but I always get the same error. can I have a solution please

--
Serigne Mansour DIENE
Ingénieur Géomètre Topographe
PhD. Student Remote Sensing 
CIRAD - UCAD
Tel,: 78-104-39-07


Re: Georeference and warp a drone image based on sensor orientation and location using transform.from_gcps()

Alan Snow
 

From what Sean referenced earlier (https://rasterio.readthedocs.io/en/latest/topics/reproject.html#reprojecting-with-other-georeferencing-metadata):

Don't use "from_gcps" and instead pass in "gcps" directly into the reproject function (https://rasterio.readthedocs.io/en/latest/api/rasterio.warp.html#rasterio.warp.reproject).

This discussion may also contain helpful information: https://github.com/corteva/rioxarray/issues/339


Re: Georeference and warp a drone image based on sensor orientation and location using transform.from_gcps()

zarg
 

@Patrick Gray
Did you find a solution ? Can you share it ? 

I have the more or less the same problem. 


Thanks


Re: rasterio.features.shapes with holes in polygons

wsdaphne.wang@...
 

The image was included in the original post! Thanks.


Re: rasterio.features.shapes with holes in polygons

Fahim Hasan
 

Can you provide the data??--
Md Fahim Hasan 

Graduate Research Assistant
Geological Engineering
Missouri University of Science and Technology


Re: rasterio.features.shapes with holes in polygons

wsdaphne.wang@...
 

Hi,

I am encountering a similar problem with getting polygons with holes from a raster image. Hoping someone can help.
The image data that I am working with is a multi-page label matrix in tiff format, I am working with the first page. I have attached it for reprex. My data has no crs.

from skimage import io
import numpy as np
from rasterio import features
import shapely
import geopandas as gpd
import matplotlib.pyplot as plt

# read the first page of the multipage tiff
img = io.imread(seg_map_path, img_num=0)
img_array = np.array(img).astype('int32')

# display the label matrix; value=0 is displayed as purple; (0,0) is in the top left corner
plt.imshow(img_array)
plt.show()


# attempt to get the multipolygon for value=0
(purple region)
mask = (img_array == 0)
polygons = []
for shape, value in features.shapes(img_array, mask):
    polygons.append(shapely.geometry.shape(shape))
polygons = shapely.geometry.MultiPolygon(polygons)
# polygons = polygons.apply(make_valid)
polygons = gpd.GeoSeries(polygons)
polygons.plot()

The resulting geoseries is from the purple geometry from above, reflected across the y axis (because (0,0) is now in the lower left corner), but with no holes.

I would really appreciate any help on this.


Building rasterio from source does not inherit MrSID plugin (Windows 11)

breallis@...
 

I need to be able to read MrSID files with rasterio. According to the documentation, "The included GDAL library is fairly minimal, providing only the format drivers that ship with GDAL and are enabled by default. To get access to more formats, you must build from a source distribution (see below)."

Following the build instructions, I retrieved binaries from GIS internal. Specifically, from https://www.gisinternals.com/query.html?content=filelist&file=release-1928-x64-gdal-3-5-1-mapserver-7-6-4.zip, I downloaded
GDAL Core: gdal-305-1928-x64-core.msi
GDAL MrSID plugin:
gdal-305-1928-x64-mrsid.msi
GDAL library and header files: release-1928-x64-gdal-3-5-1-mapserver-7-6-4-libs.zip/

1) I installed GDAL core and the MrSID plugin to the default installation directory (C:\Program Files\GDAL).
2) I then unzipped the library and header files to the same installation directory, in the subfolder "release-1928-x64-gdal-3-5-1-mapserver-7-6-4-libs".
3) I created environmental variables GDAL_DATA="C:\Program Files\GDAL\gdal-data" and GDAL_DRIVER_PATH="C:\Program Files\GDAL\gdalplugins", and GDAL_VERSION=3.5.1. I also note that I have "C:\Program Files\GDAL" on the path variable itself due to a previous installation attempt
4) I opened Visual Studio 2022 Developer Command Prompt v17.3.1.
5) I created a virtual environment (Python version 3.7.9) and activate it
6) pip install numpy
7) pip install cython
8) python setup.py build_ext -I"C:\Program Files\GDAL\release-1928-x64-gdal-3-5-1-mapserver-7-6-4-libs\include" -lgdal_i -L"C:\Program Files\GDAL\release-1928-x64-gdal-3-5-1-mapserver-7-6-4-libs\lib" install
pip install --no-use-pep517 --global-option -I"C:\Program Files\GDAL\release-1928-x64-gdal-3-5-1-mapserver-7-6-4-libs\include" -lgdal_i -L"C:\Program Files\GDAL\release-1928-x64-gdal-3-5-1-mapserver-7-6-4-libs\lib" .

The build succeeds and I am able to import rasterio and open geotiff files with it. However, I am not able to open sid files. Typing rio env in the command prompt reveals no trace of the sid format driver. In contrast, gdalinfo <filename>.sid is able to interact with sid files fine. What am I missing?


Rasterio 1.3.0

Sean Gillies
 

Hi all,

We've got a new version of rasterio! Rasterio 1.3.0 has new features, deprecations, and many bug fixes. It supports Python versions 3.8+ and GDAL versions 3.1+. Please see https://github.com/rasterio/rasterio/blob/master/CHANGES.txt for a fine grain description of changes since 1.2.10. Major changes and deprecations are listed below.

Packaging:

* Building from source now requires Cython (#2016).
* PyPI wheels include GDAL 3.5.0 and PROJ 9.0.0.

Deprecations:

The rasterio.path module has been moved to rasterio._path and all its member made private (#2423). A new version of rasterio.path temporarily provides aliases to maintain compatibility.

New features:

* A dataset's write method now accepts Numpy masked arrays and has a "masked" keyword argument. In this case, if masked is False, the masked array's filled method is called with the dataset's nodata value or else the masked array's fill value. If the masked argument is True, the dataset's write_mask method is called.
* Datasets have a new statistics method that computes the minimum, maximum, mean, and standard deviation of a raster band's data, matching the output of gdalinfo (#2441).
* The rio-warp CLI command now takes --wo (--warper-option) and --to (--transformer-option) options, allowing the use of PROJ coordinate transformation pipelines like "--to coordinate_operation=proj=pipeline" (#2438).
* Python file objects and file-like objects from, for example, fsspec are adapted for opening to get a dataset without copying file data to a MemoryFile (#2141).
* Added support for PROJ JSON based interchange for CRS (#2212).
* More efficient window intersection and union (#2164).
* New Affine, GCP, and RFC transformer classes (#2225).

Rasterio 1.3.0 is the work of 30 contributors on GitHub:

Adam J. Stewart, Alan D. Snow, Andrea Giardini, Andrew Nisbet, Arno Gobbin, Bill Morris, Caleb Robinson, David Hoese, Denis Rykov, Dr Martin Black, Even Rouault, Ewout ter Hoeven, Felix Divo, Howard Butler, Idan Miara, Joachim Ungar, João Santos, Keith Jenkins, Martijn Visser, Mike Taves, Nico Mandery, Olivier Cloux, RichardScottOZ, Ryan Grout, Samuel Kogler, Sean Gillies, Steven Pestana, Tomáš Hrnčiar, Vincent Sarago, and Yann-Sebastien Tremblay-Johnston.

Many people contributed to 1.3.0 in other ways. Thank you packagers, teachers, writers, pre-release testers, you who ask and answer questions on various internet forums. The project would not be where it is without you.

Yours,

--
Sean Gillies


Rasterio 1.3.0

Sean Gillies
 

Hi all,

Here is the GitHub release summary: https://github.com/rasterio/rasterio/releases/tag/1.3.0.

Here is the full list of changes since 1.2.10:https://github.com/rasterio/rasterio/blob/master/CHANGES.txt#L4-L162.

Thanks, everyone!

--
Sean Gillies


Rasterio 1.3b3

Sean Gillies
 

Hi all,

This is a belated announcement that rasterio 1.3b3 is on PyPI. For the first time we have a small set of Windows wheels. This same set of wheels is what we intend to provide for the final 1.3.0 release, which will come on July 5 unless any show-stopping bug or wheel issue is found before then.

--
Sean Gillies


Re: Applying Color Ramp to Single-Band Grayscale Images

Brandon Victor
 

Hello Eyat,

I just realised I didn't respond. Definitely, if it's not a once-off, a programmatic solution is the best way. Option #2 can be used with negative integers; the gotchya is that matplotlib interprets floating point numbers as scaling between 0-1, and integers as scaling between 0-256. You'll also have to set the dtype to int16 if your DEMs are stored in uint8 or int16 and you are doing a subtraction. You just have to set your range to include the negative values. Something like this (you can also replace np.int16 with np.float32 if you need):

```python
data = np.random.uniform(-256, 256, (100, 100)).astype(np.int16)
cmap_dict = {n: np.array(cmap(int((n+256)/2)))*256 for n in range(-256, 256, 2)}
with rasterio.open('scraps/mapped.tif', 'w', width=100, height=100, count=1, dtype=np.int16) as dst:
    dst.write(data, 1)
    dst.write_colormap(1, cmap_dict)
```

There are at least two reasons option #3 is not recommended:
  1. You bake the colours into the image, meaning that for downstream users, there's no practical way to recover the variable of interest from the image. That might be you, or it might be other people.
  2. You are multiplying your data storage requirements. This may or may not be relevant to you. Smaller files are easier to deal with.
Of course, the benefits of option #3 are that you have a more portable file; it could even be opened by a non-GIS image viewer. I assumed that processing utility was paramount; perhaps I shouldn't have.

Perhaps it's too untimely a response for you, but maybe it will help anyone else who stumbles on this page.


Re: rasterio ImportError: version `GLIBCXX_3.4.30' not found

alec.glen.ostrander@...
 

Installed via conda; `conda list rasterio` does show it coming from conda-forge.

The OS is Ubuntu 20.04.4 LTS running in Docker. It should be reproducible with the following commands:
```

docker run -dit --name jbase jupyter/base-notebook

docker exec jbase conda install rasterio

docker exec jbase python -c "import rasterio"

```


Re: rasterio ImportError: version `GLIBCXX_3.4.30' not found

Herzmann, Daryl E [AGRON]
 

Greetings,

How did you install rasterio ? Via conda or pip ? Does `conda list rasterio` show it coming from conda-forge? Which version of Linux is this?

daryl

________________________________________
From: main@rasterio.groups.io <main@rasterio.groups.io> on behalf of alec.glen.ostrander via groups.io <alec.glen.ostrander@...>
Sent: Thursday, May 19, 2022 3:08 PM
To: main@rasterio.groups.io
Subject: [rasterio] rasterio ImportError: version `GLIBCXX_3.4.30' not found

Hello, I'm struggling to figure out an issue with my installation of rasterio, any help is greatly appreciated!

I've had rasterio installed and working cleanly for a month, but today when I ran my code, I received the following error:

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/opt/conda/lib/python3.9/site-packages/rasterio/__init__.py", line 9, in <module>
from rasterio._base import gdal_version
ImportError: /opt/conda/lib/python3.9/site-packages/rasterio/../../.././libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /opt/conda/lib/python3.9/site-packages/rasterio/../../.././libtiledb.so.2.8)

I've tried reinstalling a few times without luck, and confirmed that GLIBCXX_3.4.30 does not exist on my machine (I have versions 3.4.1-29). But I'm a bit beyond my depth trying to figure out how to fix it.


Re: rasterio ImportError: version `GLIBCXX_3.4.30' not found

alec.glen.ostrander@...
 

Seems like it might be a bug, related to https://forum.manjaro.org/t/latest-firefox-has-possible-dependency-issue-with-missing-glibcxx-3-4-30/111179?


rasterio ImportError: version `GLIBCXX_3.4.30' not found

alec.glen.ostrander@...
 

Hello, I'm struggling to figure out an issue with my installation of rasterio, any help is greatly appreciated!

I've had rasterio installed and working cleanly for a month, but today when I ran my code, I received the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/conda/lib/python3.9/site-packages/rasterio/__init__.py", line 9, in <module>
    from rasterio._base import gdal_version
ImportError: /opt/conda/lib/python3.9/site-packages/rasterio/../../.././libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /opt/conda/lib/python3.9/site-packages/rasterio/../../.././libtiledb.so.2.8)

I've tried reinstalling a few times without luck, and confirmed that GLIBCXX_3.4.30 does not exist on my machine (I have versions 3.4.1-29). But I'm a bit beyond my depth trying to figure out how to fix it.


Rasterio 1.3b1

Sean Gillies
 

Hi all,

Rasterio 1.3b1 is on PyPI now. We're not accepting new features for 1.3.0 and are only working on major runtime and installation bugs. If you would be willing to try out this pre-release and provide feedback on GitHub, or in responses to this email, the 1.3.0 release will be better and will arrive sooner.

There's one new feature since 1.3a4: support for writing both band data and band mask when passing a Numpy MaskedArray to a dataset's write method. Perhaps more interesting is that the binary wheels on PyPI include GDAL 3.5.0rc4 and PROJ 9.0.0, the latest versions of each.

Our set of binary wheels is small right now, but we'll keep working on that, and will send updates when we've added support for more platforms.

Big thanks to everyone who contributed since 1.3a4, particularly Alan Snow, who cleaned up a lot of obsolete code that was supporting older versions of GDAL.

--
Sean Gillies


Inconsistent results between gdalWarp (with cutline) and rasterio.mask

bbuzz318@...
 

Hi,
Please see my stack exchange post:
https://gis.stackexchange.com/questions/430544/inconsistent-results-between-gdalwarp-with-cutline-and-rasterio-mask
and this post: https://github.com/rasterio/rasterio/issues/2355 which seems to have noticed this same issue.

On closer inspection, rasterio adds about an extra row of pixels (see attachment), which would seem to be incorrect.
Purple shows the vector I'm cropping to; the black is the result of the gdalWarp and the red is the extra from Rasterio.

Thanks!


Re: a_scale parameter for writing GTiff file

calba@...
 

Ok thanks, I will try it !


Re: a_scale parameter for writing GTiff file

Alan Snow
 

The scales and offsets properties on the DatasetWriter object should allow you to update the raster.
I recommend masking your data before scaling your data as the mask value is for the raw data.

Reference for how rioxarray does it:
  • Writing the scales/offsets to file: code
  • Reading with scales and offsets: code

1 - 20 of 956