We changed our privacy policy. Read more.

Questions tagged [numpy]

NumPy is a Python module, adding support for large, multi-dimensional arrays and matrices, along with a large library of high-level mathematical functions to operate on these arrays.

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

Array is visualized differently in matplotlib than QGIS

I am getting different resutls when plotting a np.array with matplotlib than when doing it in an external software - QGIS. Here is what I have: print(wiw[0].shape) (1, 8433, 9254) print(wiw[0]...
0
votes
0answers
40 views

Acquiring data point coordinates from Geotiff and converting to numpy array

I would like to use scipy.interpolate.griddata to interpolate my Sentinel-1 products (see two sample images below) taken from different orbits resulting in having the uniform datapoint coordinates. I ...
0
votes
1answer
17 views

Varying resolution (scale) when using Google Earth Engine sampleRectangle to convert to numpy array

I am trying to convert my google earth engine image to a numpy array. I have used sampleRectangle but the scale seems to be set to 1 degree, way too large, even though the native resolution of the ...
0
votes
0answers
26 views

Extracting lon lat data from .hgt file using Python

I have a .hgt file and I want to extract the lon and lat data from it. I separated the height values by using python==3.8 to work with the data in an numpy array-format. import rasterio raster1 = ...
1
vote
0answers
24 views

ArcPy: Populating array column with rank values

I am trying to get the rank values for some values in my fields. I have created an array from fields of an attribute table, sorted them in descending order, and I now want to populate the third column ...
0
votes
1answer
55 views

Reclassifying raster image in Google Colab with NumPy

In Google Earth Engine's Java API, I have the following code that works and am trying to use this in Google Colab with Python. How do you reclassify the pixels in a raster image in Python? var ...
0
votes
1answer
54 views

Get Numpy array from SHAPE@WKB token

I am trying to get a numpy array from the SHAPE@WKB token that is obtained either using FeatureClassToNumpyArray or cursors, however what I get does not make much sense. Specifically I am interested ...
3
votes
1answer
80 views

Reproject NumPy ndarray without saving as TIFF

I have NumPy ndarray with shape (1063,2116,12) (has 12 bands). The ndarray has non geographical data, but I do have its' transform affine and the crs. I want to give this geographical data to the ...
0
votes
1answer
47 views

Python array based alternative to GRASS r.cost

I am looking for a numpy array based alternative to the GRASS r.cost function. I have a friction surface raster where the value of each cell corresponds to travel time. I would like to find the cells ...
0
votes
2answers
54 views

Type error for gdal- GDAL-style transforms have been deprecated

I'm trying to export numpy ndarray that I have to TIFF using rasterio. I have the transform of the image: print(transf) >>>(583932.1992386435, 10.0, 0, 2223772.1491772938, 0, -10.0) When I ...
3
votes
1answer
333 views

Strange warning/error when working with polygons

Reading a polygon shapefile with geopandas I got a strange error. I found out it is a normally hidden warning about another error, which I saw only because I turned warnings to errors. It also appears ...
2
votes
0answers
90 views

Reclassify raster MemoryError: Unable to allocate 97.5 GiB for an array with shape (6546455295, 2) and data type int64

I have tried to reclassify my global land use dataset downloaded from here. And I tried to reclassify this tiff file using the following code. driver = gdal.GetDriverByName('GTiff') file = gdal.Open('...
0
votes
1answer
107 views

GeoPandas TypeError: geometries are not orderable (numpy: TypeError: '<' not supported between instances of 'Point' and 'Point')

I'm trying to group rows of a GeoDataFrame based on a common gid value and aggregating two columns for which the values differ but I am facing this error: TypeError ...
0
votes
1answer
65 views

ArcPy polyline shape object to numpy array

I am learning to work with the geometry objects included in ArcPy. I'm really interested in using them since I don't want to create files at all since most of the data I'm going to use is just mere ...
1
vote
1answer
97 views

Create array from EE image after reducing image collection in Google Earth Engine

I'm trying to create an array from an EE image, following the accepted answer in this post. However, instead of grabbing a specific image, I start with an EE imageCollection, then reduce it to an ...
2
votes
0answers
56 views

How can I plot a Kernel Density Estimation in a projected coordinate system in Python?

I am trying to plot a Kernel Density Estimation calculated from a geopandas GeoDataFrame in UTM. I am using sci-kit learn's KernelDensity, because other implementations don't allow for much ...
1
vote
1answer
53 views

Black and white to rgb

I have a GeoTIFF grayscale raster. When trying to paint a raster in RGB, the code does not take into account the nodata value. import sys from osgeo import gdal, gdalnumeric import sys from xml.dom ...
1
vote
2answers
32 views

Unexpected behaviour of RasterBand converted to Array and back

I have two raster images, mask and data. The first one is a single-band tif with integer values that refer to classes. The second one, data, is a 3-band (RGB) tif. In the raster containing the classes,...
2
votes
1answer
49 views

Python fastest way to load overlapping part of 2 rasters with different origin to np.array

I got a problem with gdal.wrap - it works REALLY slow. On 10m raster of Poland, matching the origin of 2 rasters takes like 30 minutes. Is there an easy and fast way to take 2 rasters (of different ...
1
vote
1answer
58 views

How do I avoid altering the data range when writing a NumPy array into a TIF file with rasterio?

I'm using a machine learning model to automatically recognize (a specific type of) vegetation in RGB imagery. The output of this model is a binary NumPy 2d array, with '1' meaning vegetation and '0' ...
0
votes
0answers
61 views

Writing raster file from masked array

I am doing some raster subtraction to get a canopy height model and I am struggling to write the output as a raster. The original datasets were .tif files in ESPG 27700 created from LiDAR. I used ...
1
vote
1answer
49 views

Numpy array from centerline object

I created a Centerline object from a shapely polygon, which is basically a multiline string which contains the starting and endpoint of the centerlines. How can I transform this multiline string into ...
0
votes
1answer
55 views

Converting GDAL dataset into numpy array

I am trying to do data augmentation on sentinel 2. Everything else is working the only problem I have is the output I am getting is only one band when the input image is with 10 band. I also tried ...
0
votes
1answer
96 views

Rotating GeoTIFF images

I have a GeoTIFF file which when imported using rasterio get flipped on the y-axis, and now I am trying to rotate this GeoTIFF file using NumPy rotate, it gives an error (Axes=(0, 1) out of range for ...
1
vote
0answers
37 views

OpenCV array is totally different from raster values of my TIFF in QGIS? [closed]

I have a a GeoTIFF that I need to binarize. OpenCV is of course the choice program for the job, but I am having major issues. Below, you will see a typical range for RGBnIR values in QGIS of my image: ...
0
votes
0answers
21 views

set CRS for numpy array that has no geographical data using rasterio and bbox data [duplicate]

I have 1 dimension numpy array that has no geographical information. The numpy array was originally satellite image that I have manipulated in order to get this 1 dimension arrray. I have the crs and ...
0
votes
2answers
357 views

Set CRS to numpy array with no geographical data using rasterio

I have 1 dimension numpy array that has no geographical information. The numpy array was originally satellite image that I have manipulated in order to get this 1 dimension array. I have the crs and ...
1
vote
1answer
51 views

Resolving trade off between smoothing via polynomial fitting and simplify-like algorithms (do not eliminate vertices)

I am struggling for a few weeks to use Python to smooth various linestrings and bumped into a conundrum. There seems to be a trade-off between using techniques that apply parametric curve fitting and ...
1
vote
0answers
11 views

Comparing two same-shape band arrays, one against a set of conditions to then change the other one

first band and second band can be assumed to be the same shape. I want to test the second band against two conditions (that it's not "invalid_data" and the value is one of the numbers in &...
0
votes
0answers
60 views

Save an 8 band raster in one TIFF rasterio

I'm trying to write an 8 band image in just one TIFF using rasterio. I actually opened an 8 band raster, normalize it for further processing and tried to re-write the normalized bands: I used with ...
0
votes
0answers
70 views

Extracting data from a .mat file with numpy and a mask

I have the output of a xBeach model run in .mat format. There are several layers that represent the sea status for each time-step. In each layer there are the coordinates and the water level of the ...
1
vote
1answer
37 views

Splitting a BigTIFF using tifffile

I am having trouble splitting a BigTIFF. I am orginally using @Ivan code from this question. I had to modify it a bit since I am using a .tif that was larger than 4GB. Pillow does not support BigTIFFs....
2
votes
1answer
292 views

Export numpy array as TIFF with rasterio fail with the folder name :No such file or directory

I experienced unexpected behaviour of rasterio and I couldn't understand yet where is my mistake. I have opened rasterio TIFF, did some manipulations on it as numpy array and then export it as TIFF ...
2
votes
1answer
200 views

Create 3D lines at a specific distance and bearing from a 2D polygon using Shapely and Geopandas

I have a shapefile of the runways(polygons) of different airports: I want to build a line that represents the 3D trajectory followed by an airplane 9 km after take off and 18 km before landing and ...
0
votes
0answers
58 views

Converting polygon to numpy array for CNN using Python

I need to create the current data set for CNN. So I want to convert the number entering a section of a certain area into a numpy array. For example, at the point where the geohash code is precision 6, ...
2
votes
0answers
31 views

Calculating inverse polynomial transforms for pixel sampling when map georeferencing

In map georeferencing, one typically chooses a set of ground control points that represent pixel locations in the map image along with their real world geographic coordinates, which are then used to ...
1
vote
1answer
164 views

Weird coordinates after converting numpy array to raster

I have the NumPy array and its bounding box coordinates. I have tried to convert it into raster using rasterio, based on this answer, and it did save it as raster, but when I use rasterio.show the ...
0
votes
0answers
417 views

Reproject a NumPy array with affine transform

I have NumPy array with one band and no CRS. I do have the shape of the image and the coordinates of the bbox, in WGS84. I would like to reproject it based on bounding box and the shape. I have ...
1
vote
0answers
50 views

Reproject numpy array based on bbox (extent)

I have a NumPy array image which is basically NDVI values. The image looks like this: I know the bbox coordinates of this image (e.g (bbox_coords_wgs84=[minx, miny, maxx, maxy])) I'm looking for ...
1
vote
0answers
216 views

Creating raster stack from xarray in Python

I am trying to create a raster stack from an xarray dataset which I obtained from multiple NetCDF files. import netCDF4 as nc import rasterio as rio import numpy as np import xarray as xr import os ...
1
vote
0answers
44 views

Speed up zonal statistics with additional calculation

I have two rasters, one is a classified image and the other the corresponding probabilities for a correct classification. Now I need to calculate zonal statistics for polygon segments in the following ...
0
votes
0answers
127 views

ArcGIS 10.5 ImportError: cannot import name multiarray with numpy

I've installed ArcGIS 10.5, and with it the numpy 1.9.3 library. However, I get the following error when I try to run any scripts with numpy: Traceback (most recent call last): File "U:\vickerss\...
0
votes
0answers
26 views

Converting GDAL Raster to a Boost Python Array (C++)

My Python project has a C++ extension that accepts detection coordinates to crop a GDAL raster, and then return the crop to the Python side. On the C++ side, I create a uint8_t buffer to hold the crop....
1
vote
1answer
318 views

How to create a raster delineating all drainage basins using pysheds python

I am going through the tutorial of "Pysheds" available in the following website https://www.hatarilabs.com/ih-en/elevation-model-conditioning-and-stream-network-delimitation-with-python-and-...
0
votes
0answers
27 views

Memory issue loading raster into numpy array

I am trying to open a historical imagery tiff dataset into a numpy array so I can do some image processing on it afterwards. However, it gives me 'unspecified error' when trying to run the (very) ...
0
votes
2answers
274 views

Export numpy array with rasterio

I have made some processing on some satellite images as numpy arrays. I want to export the data as tif images again to see the result I read ùy image with rasterio sentinel2 = rasterio.open('sentinel2....
1
vote
1answer
257 views

Write numpy ndarray as TIFF with rasterio does not work

I have ndarray with shape of (12, 773, 1231) ((12 bands)). I want to save it as array in order to reproject it. I have image with the same shape and image but reprojected so I baiscally want my ...
1
vote
2answers
194 views

Preserve coordinates when converting TIFF image to numpy ndarray

I have satellite image that I want to convert into numy array (and then to Pandas). I already know how to do that thanks to Stefan, but th eproblem is that it does not preserve the coordinate data. ...
0
votes
0answers
144 views

Looping over 5D masked Numpy array Python

I am a beginner in Python and I faced a problem in maintaining the same size of the last 2 dimensions in the 5D array that I have while looping over it to do some calculations, as they represent the ...
3
votes
1answer
250 views

Issue in calculating NDVI using Rasterio Python

I am trying to calculate NDVI using two clipped raster images of Landsat 7 (NIR & Red Bands clipped using mask file) using the following code: import rasterio as rio import numpy as np import ...

1
2 3 4 5
9