New answers tagged

1

Use the /vsistdout/ virtual filesystem: ogr2ogr -f GeoJSON /vsistdout/ inputFile.shp


2

I think that converting data into SpatiaLite in this case may be a good idea, even shapefiles do support simple BBOX queries with spatial index if spatial index is created (the .qix or .sbn/.sbx files) and you can run your query with ogr2ogr also against the shapefile by using the SQLite SQL dialect. https://gdal.org/user/sql_sqlite_dialect.html. You should ...


1

Index the shapefile with: ogrinfo -sql 'CREATE SPATIAL INDEX ON "layername"' shapefile.shp To get the layer name, if you don't know it, use: ogrinfo shapefilename.shp eg, 1: 2019 Lines (Line String) This means the first layer in the file is "2019 lines" and it's a linestring. The query is run on the layer, not the file. The file is ...


2

There are couple of issues in the original command. The ogr2ogr utility converts vector data from source format into target format. It is possible to use ogr2ogr but then both datasource and target must be defined. However, ogrinfo might be better tool for making the metadata query. The syntax of the two "SQL requests" which are special for the ...


2

You can load the result of "native:centroids" into memory and then manipulate your .gpkg file. This has the advantage that you can also build in some checks before you overwrite your original source file. Something like this: # load layers from file source_path = os.path.join(<YOUR GEOPACKAGE PATH>) + "|layername=<POLYGON LAYER>&...


0

This is working for me in windows command prompt: ogrinfo "MSSQL:server=someserver;database=databasename;UID=username;PWD=password123"


2

In ogr2ogr the -gt option is the correct and only way to control the size of the transactions https://gdal.org/programs/ogr2ogr.html#cmdoption-ogr2ogr-gt -gt n Group n features per transaction (default 100 000). Increase the value for better performance when writing into DBMS drivers that have transaction support. n can be set to unlimited to load the data ...


1

Not sure if it's possible via GeoPandas but at least quite easy with ogr Python bindings (you have them if you have Geopandas). The dirty way e.g parsing is not required. import ogr # PostgreSQL recipe databaseServer,databaseName,databaseUser,databasePW = 'your_host', 'your_dbname', 'your_user', 'your_password' connString = f"PG: host={databaseServer} ...


0

I got it to work by adding: -lco UPLOAD_GEOM_FORMAT=wkt So the invalid object name error is complete nonsense. However, after 40 minutes of a small 30mb shape file that is read in about 5 seconds in QGIS it was still on 1% progress because it refuses to use BCP or the native sql drivers that every other app uses. Adding this comment in case it helps anyone ...


0

https://github.com/OSGeo/gdal/issues/835 has an example. It shows how the label syntax works. It creates a separate label file in DXF format.


1

To fix this problem, check "Beta: Use Unicode utf8 for worldwide language support " box in control panel ->region, administrator ->, language fornon unicode, which unfortunately does not exist in older Windows updates.


0

To upload a shapefile to a local or remote Microsoft SQL Server database (or Azure SQL) using GDAL's ogr2ogr, open a new command prompt and use this: ogr2ogr -f "MSSQLSpatial" "MSSQL:server=your_server_url,1433;database=your_database_name;uid=your_username;pwd=xxxxxxx" -lco SCHEMA=dbo -nln new_table_name "C:\path_to_file\shapefile....


2

within PostGIS: CREATE TABLE <multipolygon_layer> AS SELECT <id>, ..., ST_CurveToLine(<geom>) AS <geom> FROM <multisurface_layer> ; using ogr2ogr (GDAL > 3.0.5): ogr2ogr -f PostgreSQL <pg_conn> -nln <multipolygon_layer_name> -nlt CONVERT_TO_LINEAR -nlt PROMOTE_TO_MULTI <source> or, ...


Top 50 recent answers are included