Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
18 views

How to create a GeoDataFrame points grid from a numpy.mgrid?

I'm trying to create a GeoDataFrame points grid from a numpy.mgrid. I already have created the numpy.mgrid with coordinates of future points. >>>arr = np.mgrid[-1827342.1753285176:-1827523....
0
votes
2answers
21 views

If field 1 > field 2 update field 3 in loop

I am trying to update the table above. What I want to do is if the values in the PMP fields are less than the Max fields update the check fields with PASS, if not FAIL. I started doing this trying ...
1
vote
1answer
35 views

NumPy array to Raster file (GeoTIFF)

I converted a raster file (one band grey scale) to an numpy array and set a range to it. I Did like that: import gdal import numpy ds = gdal.Open('H:/GDAL_docs/a.tif') myarray = numpy.array(ds....
2
votes
1answer
23 views

Get data from a raster using two coordinate arrays with Python

I'm trying to find a function in Python, that given two arrays with geographic coordinates, returns a list or array of raster values in those positions. that is to say: import numpy as np """geog ...
0
votes
1answer
42 views

Loading all rasters in a directory and naming the variables iteratively

Hi I'm working with prism data and I already have clipped (masked) rasters (*.bil files) of a specific area for each day of a year. I'd like to open all these rasters with rasterio, convert them into ...
1
vote
1answer
40 views

Comparing pixel values at a given point in two rasters

I have two raster images, one for land use and one for NDVI, i would like to calculate LAI based on land use. So i need to compare the pixel value in the NDVI raster and Land use raster then select ...
1
vote
0answers
29 views

Numpy import error in OSGeo4W Shell

I and my colleagues are running into a very frustrating Python import error while using the OSGeo4W Shell. Any time we attempt to use gdal_calc in a Python script, we get the following error message: ...
1
vote
1answer
58 views

Using rasterio and matplotlib how can I create a window for an NDVI image to fit into?

I am using Rasterio, Numpy, and Matplotlib. I created a window with the dimensions of 800x600 and plotted the band 5 for a Landsat 8 image, that worked just fine. I also have the nir image so then I ...
0
votes
1answer
79 views

Using Rasterio, Matplotlib, and Numpy trying to calculate and plot NDVI of a raster image getting error: IndexError: list index out of range?

First I create two variables and store my raster images in them and I use MatPlotLib to plot a subset of the original "nirband" raster image. That works fine. I am getting an IndexError: list index ...
1
vote
0answers
25 views

Using Null Values in Raster To NumPy?

I am trying a convert a raster dataset [a simple 4 x 4] into a numpy array using RasterToNumPyArray. Here is my sample raster dataset: RasterToNumPyArray however, returns zero for Null values: ...
3
votes
0answers
45 views

QGIS 3 - Save processing output to memory and turn into numpy array?

I'm currently developing a python plugin for QGIS 3. In short, the code conducts among others a viewshed algorithm, turns the output in a numpy array and calculates some spatial metrics the user can ...
0
votes
1answer
45 views

How to convert masks generated by rasterio to channel last mask

The problem is about using rasterio to generate mask from GeoJSON file which contains geographic coordinates. The function that I used is from: from rasterio.tools.mask import mask with rasterio....
1
vote
0answers
212 views

Writing numpy array to rasterio raster file generates empty file

I'm using Rasterio to read GeoTIFF from Sentinel 2 and calculating NDVI, but when I try to save as a new TIF file, the file turns to transparent and empty file. What am I missing? That's the code: ...
0
votes
0answers
66 views

numpy array coordinates to polyline in shapefile Python

I am calculating the shortest path in a numpy array which was converted from a raster (.tif). I have a list representing a path like [(1,3),(2,3)(3,3)]. How can I transform this into a polyline in ...
1
vote
1answer
93 views

Write array to CSV inside arc script tool (works in pycharm, doesn't work in arc)

I have an arcpy script in which I am writing an array to a CSV (for later use in the script to make a routeing layer). I've tried a couple iterations, and all work like a charm in PyCharm (can't ...
2
votes
0answers
111 views

Networkx shortest paths for two point layers

I have a task to know the best way from houses to subway station. There are three types of data on a picture below: orange dots are the entrances to subway stations violet dots are centerspoints of ...
1
vote
0answers
55 views

Point displacement between map (Cesium 3D) and raster (numpy array)

It is better to show than tell: On this image, the layer below the colorful shape is a trivial heat map in raster format. The colorful shape is the product of the skimage.graph.MCP_Geometric method. ...
1
vote
1answer
139 views

Writing a raster file from multi-dimension array using Python

I've been attempting to create a raster file that has multiple bands (10 or more) from a numpy array with multiple dimension(i.e. 10 or more). The script I'm currently using exports the TIFF file I ...
3
votes
1answer
120 views

Determine size of GeoTIFF header

Is there a way to find the size (in bytes) of the header information in a GeoTIFF file using Python? I am not trying to read the header (I know I can use gdalinfo for this) but rather to figure out ...
2
votes
1answer
285 views

Efficiently read large tif raster to a numpy array with GDAL?

I have been using the Python GDAL API to read tif raster files as NumPy arrays. Previously, I simply read the raster into an array directly with GDAL: ds = gdal.Open('example.tif') fullarray = np....
1
vote
1answer
149 views

Numpy array to raster with ArcPy [closed]

I have a Python script to download data in netCFD format. I have managed to extract the information I need in a masked array. This looks like: print(my_array.shape()) >> (700, 299, 217) As a ...
0
votes
0answers
201 views

Opening numpy array to rasterio?

I have numpy array that I know bbox for and can transform like this: import rasterio.plot from rasterio.transform import from_bounds t = from_bounds(minx, miny, maxx, maxy, sorted_np[3,:,:,7].shape[...
0
votes
0answers
23 views

Google Earth Engine Output - Returns Unexpected Values with np.sum()

I am exporting a CHIRPS precipitation raster from Google Earth Engine. This is part of a larger collection of data that I'll be exporting, but I'm just inspecting one image at the moment. I've ...
1
vote
2answers
318 views

NumPy memory error on large rasters

I have multiple large rasters. Their 5 percentile and 95 percentile are needed to be calculated. After loading the rasters to the ArcMap, I am using the following codes - import numpy import arcpy ...
3
votes
1answer
50 views

Raster representation in arcpy/numpy

I have a .tif raster file which contains integer values at 1, 2, 3, 4 and 5. Importing this file into ArcMap also shows a number of cells with Nodata value where the above classes are not present. I ...
1
vote
2answers
192 views

How to create a TIFF file using GDAL from a numpy array and specifying NoData value

I have some tiff files I obtained from splitting a bigger tiff file using gdal translate. The border tiff files have some nodata values, which I can see in numpy as number 15. I want to manipulate ...
0
votes
0answers
868 views

GDAL 2.3.1 is installed but the llinux terminal is using GDAL 2.2.2

I asked this question before realising this site existed: https://stackoverflow.com/questions/51476826/gdal-2-3-1-is-installed-but-the-llinux-terminal-is-using-gdal-2-2-2 I've installed GDAL 2.3.1 ...
0
votes
1answer
86 views

NumPyArrayToTable() RuntimeError: The value type is incompatible with the field type. [id]

# Create a dataframe from sorted JSON dictionary containing desired data df = pd.DataFrame(data, columns=['lat', 'lon', 'id']) # coerce dtype 'O' object values to np array native float64 type df['id']...
3
votes
1answer
428 views

Use Google Earth Engine to read MODIS NDVI into python

I'm trying to adapt this example for my needs: https://mygeoblog.com/2017/10/06/from-gee-to-numpy-to-geotiff/ The difference is that I'm using the MODIS NDVI image collection. # define the image img ...
2
votes
1answer
546 views

How to split multiband image into image tiles using Rasterio?

I have been using this answer on GIS SE to split 3-band (RGB) imagery into 256x256 3-band image tiles: import os, gdal in_path = '/path/to/indata/' input_filename = 'dtm_5.tif' out_path = '/path/to/...
2
votes
1answer
169 views

ArcGIS region group open source equivalent in numpy/python?

I am trying to get a unique ID for contiguous raster objects with the same value, like what the Region Group tool from ArcGIS does. However I need an open source solution using python/numpy/gdal/...
2
votes
0answers
264 views

LiDAR point cloud to numpy array to raster?

I'm looking for a way to create a height raster (raster of z values - i.e. not just ground poinits). I can accomplish this with gdal by creating a point vector layer from the numpy array then using ...
2
votes
1answer
146 views

NumPyArrayToTable() (SystemError: error return without exception set)

My goal for this script is to extract some information from an Overpass API query and ultimately join it with the table of another feature class I have created. So far I have completed the following ...
2
votes
1answer
136 views

Arcpy “MemoryError”; Get Classification Breaks on a TIF Raster; Jenks Breaks; Python

I have a large .tif raster with integer values. I wish to generate Jenks classification breaks using code and then use those breaks to reclassify my .tif file. I came across a block of code that I ...
1
vote
0answers
101 views

Hotspot Analysis QGIS Error: An error has occurred while executing Python code: ValueError: Illegal field requested in GetField()

I am doing a hotspot analysis for chicken spatial distribution in QGIS using Ubuntu. I have already installed the repositories used for hotspot analysis. However, an error occurred after I chose a ...
0
votes
0answers
29 views

Create polygon mask out of SAR Geom range azimuth coordinates

I have a SAR image, say s_img1, and a subset of min/max list of vertices as [(min_azimuth, min_range), (min_azimuth, max_range), (max_azimuth, min_range), (max_azimuth, max_range)] i.e they are a part ...
6
votes
1answer
821 views

numpy array to GTiff using rasterio without source raster

I have a numpy array that represents rasterized data from a LiDAR point cloud. For example: import numpy as np import rasterio arr = np.random.randint(5, size = (100, 100)) I know information about ...
0
votes
0answers
109 views

numpy array to gdal.Band

I have a numpy array that I want to convert to polygons using the gdal.Polygonize function, as outlined using this Polygonize a Raster Band approach. Unlike the example listed, however, my data is ...
2
votes
1answer
976 views

ValueError: arange: cannot compute length

I'm using a script on python "format_snow_param.py". This script takes geotiff data for snow band parameterization and converts it to the needed text format for the VIC model Usage: python ...
0
votes
0answers
3k views

ImportError: cannot import name multiarray with numpy and ArcPy?

I've installed ArcGIS 10.4.1, and with it the numpy 1.9.2 library. However, I get the following error when I try to run any scripts with numpy: >>> import numpy Runtime error Traceback (...
1
vote
0answers
102 views

Create raster map from numpy array [closed]

I want to create a raster map from a Numpy array from arcgis. I am using arcpy.NumPyArrayToRaster() function to convert. But it is throwing following error. Traceback (most recent call last): File "...
1
vote
0answers
53 views

Getting MemoryError making hexagonal lattice over polygon in ArcPy? [closed]

I am creating a hexagonal lattice that I will then use to create Thiessen Polygons. We are required to make a lattice first. I can't figure out how to get rid of the MemoryError that looks like this: ...
3
votes
0answers
121 views

Python&ArcGIS: Combining several raster layers into netCDF

EDIT: So the mod asked me to narrow down my question (waiting for answers to tell me to give more info, but here we go). How can i change my piece of python code to do the following steps: #...
0
votes
0answers
53 views

Calling Grass Raster Functions from Python and Using NumPy Array as the Input?

I have been trawling the internet for a solution, but so far no luck. It seems inefficient that when calling the Grass function r.viewshed from within python, that I have to import the raster tif ...
0
votes
2answers
100 views

Reclassify a raster in order to polygonize python

I have a GTiff raster with values from 0 to 255 and I want to reclassify 2 values ( 1 and 2) to 1, and the rest set them to NaN, in order to polygonize later and obtain polygons only for the desired ...
1
vote
0answers
33 views

Unexpected results when reclassifying raster using GDAL/numpy

I am trying to reclassify a continuous raster(Int32) using GDAL Python/NumPy, by giving values greater than a number (in this case 60 minutes) 0, and less than/equal to the number 1. It's working for ...
0
votes
1answer
49 views

A error from RastertoNumpyArray: <except str() failed>

I need to do some calculation between two Raster, and I first find the arcpy.plus_3d etc., but I find that if I can use Numpy to do this calculation, it would be more simple. I get stuck in the first ...
1
vote
1answer
55 views

How can I export a Numpy array made from MODIS data for use in ArcMap?

I have an array made from MODIS Terra Daily snow data that I would like to export for use in ArcMap. How would I output the 'probablility_of_snow array' array near the bottom of this post to an image ...
3
votes
1answer
908 views

Unique Values from Multiple Fields using Arcpy and Numpy

I am using Python 2.7 and am trying to generate a list of unique values from all values within two fields (cropsum and cropsum2). I am not trying to find unique row combinations. I've tried using both ...
3
votes
2answers
373 views

Reclassify raster in QGIS with GDAL raster calc

I'm trying to reclassify some categorical raster data in QGIS using GDAL raster calculator. My input Geotiff has four values, [26, 27, 31, 32] which I want reclassified to [1.25, 2.5, 3.75, 5] ...