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
0 answers
12 views

Merging OSC files into one using osmium

I am trying to create PBF out of thousands of OSC files using osmium. I have written a bash script for doing this task using jenkins. I am merging all OSC files into one master OSC files Then ...
user avatar
-1 votes
1 answer
40 views

Merging large number of .shp files via command line with ogrmerge.py

I have a directory containing many (about 100,000) .shp files. I would like to merge them together via the command line using ogrmerge.py like this: $ ogrmerge.py -single -o output.shp *inputs.shp I ...
user avatar
1 vote
1 answer
23 views

i.vi writing null data to output raster on first attempt

I have the following lines of code in a bash script I wrote using osgeo's GRASS command line tools: i.vi viname=ndvi output=$ndvi_fn nir=$nir_fn red=$red_fn --overwrite while r.info $ndvi_fn -r | grep ...
user avatar
1 vote
1 answer
82 views

Merge ERA5-Land and ERA5 time series

I am merging some ERA5-Land and ERA5 (netCDF) time series: extract individual ERA5 and ERA5-Land maps and apply scale and offset factors -- this by looping the following for BAND in $(seq 1 8784) ;...
user avatar
1 vote
0 answers
14 views

How to create a "normal" color image from multiband RGB images with GDAL CLI?

I am working on a personal project to automatically pull and process Sentinel 2 data and create viewable images with a bash script. So far I have succeesded with most of the steps but I'm stuck at the ...
user avatar
3 votes
1 answer
183 views

Importing a CSV inside PostgreSQL with ogr2ogr through a pipe

I can successfully import a CSV file inside PostgreSQL with the following command line: ogr2ogr -f "PostgreSQL" PG:"host=localhost port=5432 user=user password=password dbname=dbname&...
user avatar
  • 1,031
0 votes
1 answer
33 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 ...
user avatar
  • 1,205
1 vote
0 answers
135 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:"...
user avatar
  • 11
1 vote
1 answer
47 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 ...
user avatar
1 vote
0 answers
63 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 -...
user avatar
  • 999
6 votes
3 answers
192 views

Renaming 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 ...
user avatar
4 votes
2 answers
85 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 ...
user avatar
  • 2,022
0 votes
0 answers
85 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 ...
user avatar
0 votes
0 answers
47 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 (~...
user avatar
  • 93
0 votes
1 answer
97 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(...
user avatar
  • 2,022
2 votes
1 answer
113 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 ...
user avatar
2 votes
0 answers
57 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=-...
user avatar
1 vote
1 answer
1k 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 ...
user avatar
2 votes
1 answer
151 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 ...
user avatar
2 votes
0 answers
66 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), ...
user avatar
2 votes
1 answer
138 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 ...
user avatar
  • 2,022
0 votes
0 answers
44 views

Calling 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 ...
user avatar
2 votes
1 answer
410 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/...
user avatar
  • 465
5 votes
1 answer
671 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 ...
user avatar
  • 3,463
1 vote
0 answers
114 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 (...
user avatar
2 votes
2 answers
1k 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 ...
user avatar
  • 259
1 vote
0 answers
346 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 ...
user avatar
  • 259
1 vote
1 answer
156 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 ...
user avatar
  • 351
0 votes
1 answer
468 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 ...
user avatar
  • 259
0 votes
0 answers
333 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 ...
user avatar
  • 199
2 votes
0 answers
57 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 ...
user avatar
3 votes
1 answer
286 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 ...
user avatar
  • 145
0 votes
1 answer
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 ...
user avatar
  • 3
1 vote
0 answers
89 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 ...
user avatar
  • 942
0 votes
1 answer
147 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....
user avatar
0 votes
1 answer
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,...
user avatar
  • 295
3 votes
1 answer
473 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 - "...
user avatar
  • 185
2 votes
1 answer
62 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 ...
user avatar
  • 135
2 votes
3 answers
392 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 ...
user avatar
  • 135
4 votes
2 answers
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 ...
user avatar
  • 494
7 votes
2 answers
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, ...
user avatar
  • 241
0 votes
0 answers
96 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 ...
user avatar
  • 695
1 vote
2 answers
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 ...
user avatar
  • 1,068
15 votes
2 answers
13k 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 ...
user avatar
  • 1,689
4 votes
3 answers
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 ...
user avatar
  • 6,099
2 votes
1 answer
2k 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 ...
user avatar
  • 1,269
4 votes
1 answer
245 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 -...
user avatar
1 vote
1 answer
49 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 ...
user avatar
  • 167
1 vote
0 answers
618 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 ...
user avatar
  • 11
3 votes
0 answers
84 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 ...
user avatar
  • 31