Questions tagged [bash]

The Bourne-again shell (Bash) is a Bourne shell (sh) implementation with numerous additions. Bash is the default shell in many Linux distributions and on macOS. It is available on most modern operating systems, and has been ported to Windows.

Filter by
Sorted by
Tagged with
0
votes
1answer
18 views

Extract Layer with Wildcard (*) or by Index

In the Geopackage below (in.gpkg) I would like to extract the first layer (i.e. pinios_eudem2_basins) and write it to a new Geopackage (out.gpkg). However I would like to do this not by name, but with ...
0
votes
0answers
43 views

Error: free(): invalid pointer displayed when executing ogr2ogr on ubuntu 20.04

Hello I'm getting an error when executing ogr2ogr tool when running bash file: free(): invalid pointer save_maps_to_db.sh: line 5: 301101 Aborted (core dumped) ogr2ogr -f "$format" PG:"...
1
vote
1answer
44 views

Using a bat file to run r.report on large number TIFFs

I need to process a large number of TIFFs or ASC that are also large in size, I was wondering if theres a way to run a bash script to call on r.report from GRASS to get the stats for my rasters and ...
1
vote
0answers
22 views

ogr2ogr clip one GeoJSON with another

I'm trying to clip the NYC streets layer using a NYC borough polygon layer. This works: ogr2ogr -clpsrc manhattan-borough.geojson manhattan-streets.geojson nycStreetCenterline-simplified.geojson -...
6
votes
3answers
172 views

How can I rename a shapefile from terminal

Shapefile comes with a bunch of friends (often referred to as sidecar files) that all need to have the same basename. While software like QGIS deals with that very well I sometimes have the need to ...
4
votes
2answers
68 views

Merging GRASS GIS calls in Linux bash terminal/scripts

I normally use bash scripts (ie. #!/bin/bash) to include different Linux-based tools (eg. awk, sed, cut), software (eg. GMT, GDAL, SAGA), and even languages (eg. #!/usr/bin/env python). However, so ...
0
votes
0answers
52 views

Mapserver - msLoadMap(): Regular expression error. MS_DEFAULT_MAPFILE_PATTERN validation failed

I am trying to use MapServer to load tiles overtop of my Google map. When hitting the endpoint, I am getting the error: msLoadMap(): Regular expression error. MS_DEFAULT_MAPFILE_PATTERN validation ...
0
votes
0answers
25 views

Combining copy with sellonlatbox using CDO

I've got 30 years of meteorological data in 6 hour files, stored (on a Linux server) in directories by year, then by month. Each file contains hourly data (so 6 entries) for a large lat lon grid (~...
0
votes
1answer
64 views

"no such field as `OGR_GEOMETRY'" when changing Multipolygon to Polygon with altering geometry in shapefile

The attempt is to change from multipolygon to polygon (shapefile) using: ogrinfo tmpem122.shp -sql "alter table tmpem122 alter column OGR_GEOMETRY type geometry(polygon, 4326) using st_geometryn(...
2
votes
1answer
79 views

Custom datum transformation in bash or Python

I need to transform a shapefile from Deir ez Zor / Levant Stereographic (EPSG:22780) to UTM 36N using 7-parameters Helmet transformation on Ubuntu bash script or Python script. In ArcGIS, I can ...
0
votes
0answers
22 views

Bash running in custom plugin importing

Suppose I have a custom QGIS Plugin built by Processing driver and have bash script with dependencies. How to do such that when Plugin is importing bash can run?
0
votes
0answers
46 views

Transforming a GRASS formula into a code usable in R

I would like to transform the formula at the botton into a formula for R , as R runs better and fastly with files I have, but I am new with it- For me it is enough even a "literary" ...
2
votes
0answers
46 views

PROJ: proj_create: Error -7: unknown unit conversion id

I am attempting to use a bash script to reproject wrf output using the following: ${gdal} -of GTiff -a_srs '+proj=longlat +datum=WGS84 +ellps=WGS84 +lat_1=30 +lat_2=60 +lat_0=42.1200065612793 +lon_0=-...
1
vote
1answer
933 views

How to write docker-compose.yml after enabling postgis_raster for PostGIS Docker Image

I'm using the docker image of https://github.com/postgis/docker-postgis and it works fine with the commands below which is also defined in README file. docker run --name some-postgis -e ...
2
votes
1answer
100 views

Converting a single shapefile with multiple features into independent GeoJSON files using ogr2ogr

Let's say there's a single shapefile that contains multiple features. Most of which are polygons. How can one convert those features into separate independent GeoJSON files? Can this be done with ...
2
votes
0answers
48 views

How to aggregate multiple NC files into gridded data

I would like to convert daily total NO2 column data into an aggregate form similar to the monthly mean tropospheric NO2 columns on said website in order to later extract statistics using shapefile(s), ...
2
votes
1answer
120 views

Convex hull that follows irregular points distribution

Based on an irregular distribution of points (longitude,latitude), I obtained the convex hull below (I use saga_cmd with polygon convexity in 1). Would you have a way to create a convex hull that ...
1
vote
0answers
38 views

How to call GDALGetRasterHistogram( ) from R?

I need to calculate a histogram (pixel-count by each unique value, actually) for more than 256 values , the default number of buckets in gdalinfo. I understand that GDALGetRasterHistogram can deal ...
2
votes
1answer
311 views

Recursively find all GeoTIFF in current and subfolders and clip using GDAL

I have thousand of GeoTIFF file in subfolders, and I would like to crop all of them using shapefile and save in a Crop folder. My working directory is: /Data/2000/image_20000101.tif /Data/2000/...
4
votes
1answer
564 views

Adding file info using ogrinfo -sql UPDATE expression

I try to add the filename with the tool ogrinfo in a bunch of shape files for later merging reasons under Debian 8 and gdal 2.4.0. I stuck by expressing a valid statement for UPDATE part. For the ...
1
vote
0answers
92 views

GDAL or rasterio to find minimum extent of multple files in command line

I have two files, GeoTIFFs (.tif) in this case which need to be cropped to each other's minimum overlap, and have matching spatial resolutions. I also want to round their Pixel Size to a whole number (...
2
votes
2answers
867 views

Convert a tab (Mapinfo) file to ESRI Shapefile with ogr2ogr

I want to convert a tab file created with MapInfo to an ESRI Shapefile (.shp) using ogr2ogr in command line. I did the following ogr2ogr -f 'ESRI Shapefile' "file.shp" "file.tab" but it gives an ...
1
vote
0answers
331 views

Convert a raster to a polygon with gdal in command line

I want to convert a raster (agric.tif) to a polygon layer (agric.shp). I want to use gdal in command line since the QGIS (raster to polygon) seems to takes for ever (still running over an hour). I am ...
0
votes
1answer
144 views

gdal_grid does not work in cron but works in terminal

I use the gdal_grid interpolation command. When I work in the terminal everything works perfectly. However, when I try to run the command in the bash script from cron then it does not work. Bash ...
0
votes
1answer
412 views

How to convert an ASCII file (with lat,lon coordinates) to a shapefile using OGR?

I have an ASCII file with the following columns : ID, longitude, latitude, value Is it possible to use OGR (ogr2ogr or ogrinfo) in command line in order to open the ASCII file and convert it to a ...
0
votes
0answers
294 views

Alter and update a shapefile with a field from an ASCII file using ogr

I have a vector file "map.shp" with a field ID. I have an attribute table (data.txt) with the following fields: ID, value1, value2. The field ID is the same in both files. I want to update map.shp by ...
2
votes
0answers
56 views

Rasterio CLI warping multiple rasters like another raster in all minus one feature

I'm writing a bash script to warp all the rasters in a specific directory to match another raster. I'd like to warp all these rasters iteratively in to match the other raster in all was except shape ...
3
votes
1answer
247 views

dbf to shp within BASH (ogr2ogr would be ideal)

I have a CSV with many points and attributes that I'm trying to convert into a shapefile but I'm having no luck. I have installed gdal-bin and can use my terminal environment to create a shapefile ...
0
votes
1answer
5k views

Merge different KMZ layers to a unique KMZ file, a bash script

I have different .kmz files, each one contains a .png and a .kml, let's say: a.kmz, b.kmz, c.kmz. I would like to use a bash script to obtain a unique .kmz file, let's say d.kmz, that contains all the ...
1
vote
0answers
80 views

Linux (unix) bash, import multiple fgdb to PostGIS using find & ogr2ogr command

I have multiple file geodatabases in different folders and this is the command I made so far: find -path "*/V*/*.gdb" -o -path "*/W*/*.gdb" -o -path "*/R*/*.gdb" -o -path "*/WM*/*.gdb" | while read ...
0
votes
1answer
130 views

gdalwarp for clipping images using multiple polygon in a bash shell for loop

C:\OSGeo4W64\bin\gdalwarp.exe -dstnodata 0 -q -cutline D:\hillsborough_Images_work\split_Polygon\120-140k\Hillborough_FINAL_140000_region_IGD_120570003d29ed0dc.shp -crop_to_cutline -dstalpha -tr 0....
0
votes
1answer
68 views

Python 2.7, PgAdmin III & BASH 4.3.48: Error Invalid Provider when calling py script in bash script

I am working in Ubuntu 16.04 LTS This is my bash script; # Binarize raster for later polygon creation path=/home/rose/Desktop/test/DSM_BM24_2017_1000_4735.tif pathdir=$(echo $path | cut -d "/" -f 1,...
3
votes
1answer
430 views

Pipe, redirect or stream to osmfilter from "standard in" (stdin)

So many tools support chaining, or piping in data from standard input. This can decrease times needed for disk writing and also better use the memory of a machine. Examples of chaining: GDAL - "...
2
votes
1answer
59 views

Change column to row using awk inside of GRASS command [closed]

I have 2000+ raster files and counting their statistics. For now I am exporting all to Excel, but to work on it, I need better segregation. My output: Name1 1 123 2 243 3 455 Name2 1 432 3 655 ...
2
votes
3answers
379 views

Loop using variable - r.mapcalc GRASS GIS

I am doing threshold classification of NDVI rasters. One equation looks like that: r.mapcalc 'prog_r43_n65=if(ndvi_r43_n65>=0.6,1,2)' Now I want to make a loop for more than 2000 rasters, so I ...
4
votes
2answers
2k views

Calculate buffer / multi-ring buffer of geometry with GDAL / gdalUtils

I wonder if there is any way to calculate a buffer on a spatial data set with basic command line GDAL or the R interface gdalUtils. To specify the Q: I have a lot of points around the globe. For ...
4
votes
1answer
2k views

gdal_calc - How to calculate where raster A is not equal to raster B?

I have two binary rasters with values NaN and 254. I want to generate a new raster that consists of the pixels that have value NaN in raster A and 254 in raster B and vice versa - those should be 1, ...
0
votes
0answers
95 views

Data limits & runtime of shp2pgsql? [duplicate]

I am using shp2pgsql in a bash script to import shapefiles into postgres. I can successfully do this for shapefiles with hundreds of records however shapefiles with tens of thousands of records (in ...
1
vote
2answers
1k views

Execute GRASS modules in bash or python

I am a novice in writing scripts. I have a line geometry. Let's say line.shp. I want to smooth it with v.generalize, e.g. v.generalize input=line output=line_chaiken method=chaiken \ threshold=1 ...
15
votes
2answers
12k views

ogr2ogr merge multiple shapefiles: What is the purpose of -nln tag?

The basic script in order to iterate recursively over sub-folders and merge all shapefiles into single one is: #!/bin/bash consolidated_file="./consolidated.shp" for i in $(find . -name '*.shp'); do ...
4
votes
3answers
6k views

Extract information from gdalinfo/ogrinfo

In Bash scripts, I use gdal(srs)info / ogrinfo to get information from raster / vector files. To use this information in my scripts, I'm extracting information using grep ... e.g. like this (to ...
2
votes
1answer
1k views

How do I use gdal command-line utility to extract raster attributes as input for gdalwarp?

I need to reproject a raster into the same extent and resolution as an existing raster, and want to use the gdal command-line utilities to do it. How do I extract these values in a format I can use ...
4
votes
1answer
228 views

Batch Script to merge tab fles in a directory

Very similar to this question Merging multiple .tab files? can someone please help me with a batch script for this? Based on the answer in the above I have #!/bin/bash for i in *.tab; do ogr2ogr -...
1
vote
1answer
48 views

Problem with numeric variable in i.topo.corr

I have a script to do topographic correction on landsat images. Following the manual, I first have to create the illumination model. I do it with the following line: i.topo.corr -i --overwrite ...
1
vote
0answers
600 views

How to create a script using wgrib2 command [closed]

I have several model data with the following format postwrf_d01_YYYYMMDD_INIT_f00000.gr2 where INIT = 0000, 0600, 1200, 1800, each consisting of up to several hours of forecast (f00000 to let's say ...
3
votes
0answers
73 views

units for gdalwrap output extent

I am attempting to write a small bash script that will mass process a large number of raster .tif files. It should do the following: Clip to a smaller extent Reproject to UTM This is what I have, so ...
1
vote
1answer
161 views

Making GRASS GIS 7 Ubuntu bash file work on Windows 7

I have created this bash file (.sh) while working on watershed analysis stochastic simulation in GRASS GIS 7.0.2RC1, which is running on Ubuntu. It worked perfectly and I received the correct results. ...
3
votes
1answer
388 views

Mass reprojection of raster files in a loop [Linux]

I have a folder with numerous .asc raster files that each accompanied by a corresponding .prj file. The file basename is the same for both files. The projection however can vary between all of them (...
1
vote
0answers
403 views

TransCAD file format for matrix data

I've never used TransCAD before. I have what I believe to be a TransCAD matrix file called data.mtx which I would like to be able to convert to some other file formats. I would prefer to do this at ...
6
votes
3answers
561 views

How to run qgis scripts in parallel across remote server(s)

I have a stand alone python script using qgis that I wrote with the help of the SE question here The script takes three arguments being; an input file path, an output file path, and another input ...