[gdal-dev] Spatial view in GeoPackage
Hi list - I'm working with making spatial views "visible" for QGIS, i.e. so they look like a read-only table from the data source manager. However, I have one problem: QGIS doesn't recognize the crs for the view. I've tracked the problem down to that *OGR* dosn't recognize the crs for the view. Hence this mail... What I've done: *- creating the view: A union of parcels with the same owner (CVR-number) CREATE VIEW marker_2019_cvr AS SELECT "CVR", SUM(COALESCE(st_area(geom),0.0)) as area_m2, count(*) as antal, st_multi(st_union(geom)) as geom from marker_2019 group by 1; -- insert or update gpkg_contents INSERT OR REPLACE INTO gpkg_contents(table_name,data_type,identifier,min_x,min_y,max_x,max_y,srs_id) SELECT 'marker_2019_cvr' AS table_name, 'features' AS data_type, 'marker_2019_cvr' AS identifier, MIN(ST_MinX(geom)) AS min_x, MIN(ST_MinY(geom)) AS min_y, MAX(ST_MaxX(geom)) AS max_x, MAX(ST_MaxY(geom)) AS max_y, 25832 AS srs_id -- same srs as the base layer for the view FROM marker_2019_cvr; -- insert or update gpkg_geometry_columns INSERT OR REPLACE INTO gpkg_geometry_columns ( table_name, column_name , geometry_type_name, srs_id, z, m) VALUES ('marker_2019_cvr', 'geom', 'MULTIPOLYGON', 25832, 0, 0); -- insert or update gpkg_ogr_columns (necessary ?) INSERT OR REPLACE INTO gpkg_ogr_contents(table_name,feature_count) SELECT 'marker_2019_cvr' AS table_name, count(*) AS feature_count FROM marker_2019_cvr; * AFAIK, this is the necessary steps to make a spatial view visible in a GeoPackage. And it works; sort of... The QGIS datasource manager shows the view as a spatial table. I can add it to the QGIS map, but... it can't find the CRS for the layer and defaults to the projects CRS. Digging a litle bit deeper: Using ogrinfo like this: *ogrinfo -ro -so data_marker_vandloeb_soe.gpkg marker_2019_cvr* shows the layers SRS WKT as (unknown). Using the same command on the base layer *marker_2019 *gives the correct WKT. 25832 is the correct EPSG number for the CRS. And the definition exists in the *gpkg_spatial_ref_sys* table. What am I doing wrong ? Or is it just "out of scope" for OGR ?? -- Med venlig hilsen / Best regards Bo Victor Thomsen ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Stitching and geo coordinating drone images
Try WebODM (https://opendronemap.org/webodm/). It's an open-source tool to this kind of work-flow. Med venlig hilsen / Best regards Bo Victor Thomsen Den 20-01-2023 kl. 06:22 skrev Vaheed Ghaffari: Hello, I need some verification from the pros out there. I am trying to stitch together a set of images taken by the DJI drone camera (M300) and add geo coordination. Raw images are not geo coordinated, but I can access the photo information in XMP fields, including the coordinates of the image center (principal point). I am trying to use the GDAL C# Nuget Package. Here are the steps I am taking: 1- Calculate geotransform array 6 coefficients using the principal point coordinates, calculated GSD and camera pitch/yaw/roll for each image 2- Use setgeotransform assign the array to the images 3-Use GdalWarp try to stitch the geocoordinated images together. I am not getting any good results. the output of the Warp function is always a modified version of my last image in the dataset. I tried using a basic geotranform array (without roll or coordination move) for testing and got the same/similar results. I can provide the detailed code if required, but I have a feeling that I am missing steps. I appreciate the help, -Vaheed ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] org2org
Sorry to pollute this list (again !) with non GDAL related information, however - I made a mistake in my answer about the SQL statement and the nerd part of my brain just won't let go. So: * The SQL where-part contains a combination of st_intersects (geom, /..some geometry resulting function../) and not st_touches (geom, /..same geometry resulting function../) "intersects" and "not touches" is equivalent to "within", so you can probably rewrite the where part to: * WHERE ST_Within(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and')*)) The above is /not/ correct. The equivalent to "intersects and not touches" is "within or overlaps". The where statement should be: *WHERE ST_Within(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and')*)) *OR* *ST_Overlaps(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and')*)) Which is marginally better than the original where. But if you read the entire SQL statement, I would assume the purpose would be something like: "/Fetch all gridcells that is wihtin a 10 km. distance from a set of countries"//./ In that case the where part could be simplified (and running considerably faster) by using ST_DWithin: *SELECT a.name, a.left, a.top, a.right, a.bottom, a.geom FROM grids.grid_1_25grad a JOIN countries.table_with_countries b ON ST_DWIthin (a.geom, b.geom, 1.0)* If the 2 tables involved has the same SRID (using meters as distance unit) and the spatial columns is of type geometry ** ** Med venlig hilsen / Best regards Bo Victor Thomsen Den 09-11-2022 kl. 21:55 skrev Bo Victor Thomsen: Thorsten - It seems that your workstation has QGIS installed (The picture of file explorer shows a QGIS icon for one of the shape files). Why dont you use the DBManager function in QGIS to test your SQL ? Sanitized version of the select: *-- SELECT name, left, top, right, bottom, geom FROM grids.grid_1_25grad WHERE ST_Intersects(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and'))) AND NOT ST_Touches (geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and')))* -- * You are selecting features from table /grids.grid_1_25grad/. The name of the table indicates it contains grid cells - like the ones you show in the picture. * The SQL where-part contains a combination of st_intersects (geom, /..some geometry resulting funtion../) and not st_touches (geom, /..same geometry resulting funtion../) "intersects" and "not touches" is equivalent to "within", so you can probably rewrite the where part to: * WHERE ST_Within(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and')))* * * Med venlig hilsen / Best regards Bo Victor Thomsen Den 09-11-2022 kl. 14:53 skrev Rahkonen Jukka: Hi, You are selecting data from table grids.grid_1_25grad. I suppose that table contains grid polygons. By your image you seem to want some buffered geometry. Spend some time for thinking about what data do you want and where to get it. You can test your queries with for example pgAdmin that can preview the geometries. Or use OpenJUMP that is an excellent tool for visualizing PostGIS query results. -Jukka Rahkonen- *Lähettäjä:*Leber, Thorsten *Lähetetty:* keskiviikko 9. marraskuuta 2022 15.46 *Vastaanottaja:* Rahkonen Jukka *Aihe:* AW: org2org Hi Jukka, with geometry al 5 files are created ogr2ogr -f "ESRI Shapefile" C:\RenderTest\raster_clipper_and.shp PG:"host=10.49.20.42 port=5432 user=tilemill password=test dbname=nextgen" -sql "SELECT \""name\"", \""left\"", top, \""right\"", bottom, geom FROM grids.grid_1_25grad WHERE ST_Intersects(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and'))) AND NOT ST_Touches(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and')))" -s_srs "EPSG:4326" -t_srs "EPSG:4326" -overwrite -lco ENCODING=utf8 but it looks strange I would expect this Thorsten *Von:*Rahkonen Jukka *Gesendet:* Mittwoch, 9. November 2022 13:10 *An:* Leber, Thorsten *Betreff:* Re: org2org This message was sent from outside of HENSOLDT. Please do not click on links or open attachments unless you validate the source of this email and know the content is safe. Hi, Try to add a geometry into the selection -sql "SELECT \""name\"", \""left\"", top, \""right\"", bottom FROM.. -Jukka- *Lähettäjä:*Leber, Thorsten *Lähetetty:* keskiviikko 9. marraskuuta 2022 13.53 *Vastaanottaja:* Rahkonen Jukka *Aihe:* AW: org2org ogr2ogr -f "ESR
Re: [gdal-dev] org2org
Thorsten - It seems that your workstation has QGIS installed (The picture of file explorer shows a QGIS icon for one of the shape files). Why dont you use the DBManager function in QGIS to test your SQL ? Sanitized version of the select: *-- SELECT name, left, top, right, bottom, geom FROM grids.grid_1_25grad WHERE ST_Intersects(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and'))) AND NOT ST_Touches (geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and')))* -- * You are selecting features from table /grids.grid_1_25grad/. The name of the table indicates it contains grid cells - like the ones you show in the picture. * The SQL where-part contains a combination of st_intersects (geom, /..some geometry resulting funtion../) and not st_touches (geom, /..same geometry resulting funtion../) "intersects" and "not touches" is equivalent to "within", so you can probably rewrite the where part to: * WHERE ST_Within(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and')))* * * Med venlig hilsen / Best regards Bo Victor Thomsen Den 09-11-2022 kl. 14:53 skrev Rahkonen Jukka: Hi, You are selecting data from table grids.grid_1_25grad. I suppose that table contains grid polygons. By your image you seem to want some buffered geometry. Spend some time for thinking about what data do you want and where to get it. You can test your queries with for example pgAdmin that can preview the geometries. Or use OpenJUMP that is an excellent tool for visualizing PostGIS query results. -Jukka Rahkonen- *Lähettäjä:*Leber, Thorsten *Lähetetty:* keskiviikko 9. marraskuuta 2022 15.46 *Vastaanottaja:* Rahkonen Jukka *Aihe:* AW: org2org Hi Jukka, with geometry al 5 files are created ogr2ogr -f "ESRI Shapefile" C:\RenderTest\raster_clipper_and.shp PG:"host=10.49.20.42 port=5432 user=tilemill password=test dbname=nextgen" -sql "SELECT \""name\"", \""left\"", top, \""right\"", bottom, geom FROM grids.grid_1_25grad WHERE ST_Intersects(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and'))) AND NOT ST_Touches(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and')))" -s_srs "EPSG:4326" -t_srs "EPSG:4326" -overwrite -lco ENCODING=utf8 but it looks strange I would expect this Thorsten *Von:*Rahkonen Jukka *Gesendet:* Mittwoch, 9. November 2022 13:10 *An:* Leber, Thorsten *Betreff:* Re: org2org This message was sent from outside of HENSOLDT. Please do not click on links or open attachments unless you validate the source of this email and know the content is safe. Hi, Try to add a geometry into the selection -sql "SELECT \""name\"", \""left\"", top, \""right\"", bottom FROM.. -Jukka- *Lähettäjä:*Leber, Thorsten *Lähetetty:* keskiviikko 9. marraskuuta 2022 13.53 *Vastaanottaja:* Rahkonen Jukka *Aihe:* AW: org2org ogr2ogr -f "ESRI Shapefile" C:\RenderTest\raster_clipper_and.shp PG:"host=10.49.20.42 port=5432 user=tilemill password=test dbname=nextgen" -sql "SELECT \""name\"", \""left\"", top, \""right\"", bottom FROM grids.grid_1_25grad WHERE ST_Intersects(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and'))) AND NOT ST_Touches(geom, (SELECT geom FROM countries.geometries_boundary_buffer_10km('and')))" -s_srs EPSG:4326 -t_srs EPSG:4326 -overwrite -lco ENCODING=utf8 this works now without any warning but still only 3 files in output folder *Von:*Rahkonen Jukka *Gesendet:* Mittwoch, 9. November 2022 12:21 *An:* Leber, Thorsten ; gdal-dev@lists.osgeo.org *Betreff:* Re: org2org This message was sent from outside of HENSOLDT. Please do not click on links or open attachments unless you validate the source of this email and know the content is safe. Hi, Does the SQL part work with a tool like pgAdmin? Notice that the inner double quotes must be escaped as \” in the ogr2ogr command or otherwise they will truncate the -sql parameter. And it seems that you did not select the geometry field. Generally I would suggest to start with a simple SQL and add complexity once you have gotten a good result. Suggestion includes testing with easy table names first before forwarding to names like countries.geometries_boundary_buffer_10km('and'). -Jukka Rahkonen- *Lähettäjä:*gdal-dev *Puolesta *Leber, Thorsten *Lähetetty:* keskiviikko 9. marraskuuta 2022 13.02 *Vastaanottaja:* gdal-dev@lists.osgeo.org *Aihe:* [gdal-dev] org2org Hi All, I am trying to use org2org with the following command: ogr2ogr -f "ESRI Shapefile" C:\RenderTest\
Re: [gdal-dev] New behaviour of "PROMOTE_TO_MULTI" ?
Thanks to Hugues and Richard for responding to my questions. However, I'm using the ogr2ogr inside a DOS .cmd file like this: for /R D:\tmp %%f in (*.tab) do ogr2ogr --config PG_USE_COPY yes -progress -lco OVERWRITE=YES -lco SCHEMA=mat -dim XY -a_srs EPSG:25832 -f "PostgreSQL" PG:"host=localhost port=5432 user=*** password=*** dbname=geodata" "%%f" I.e. iterating through a directory plus sub-directories and converting every found tab file into a table into schema "mat" using ogr2ogr The tab files contains either points, linestrings or polygons. Polygons and linestrings can be a mix of simple and multi-objects. Each tab-file contains only one main type. So I can't use "-nlt multipolygons". And the point of this project was to get rid of a fairly complex postgres based function that checks an uploaded table and change its geometry type using "alter table ... using st_multi(geom)" type of commands. That was why I tried to use "-nlt promote_to_multi". According to this mail: https://lists.osgeo.org/pipermail/gdal-dev/2012-September/034128.html Even Rouault describes the exact behaviour I'm looking for: Simple linestrings / polygons will be changed to multi types and points will be left alone. And the geometry type will be set to a "multi*" as needed. What actually happens is that linestrings, polygons /and/ points all are changed to multi type, but the geometry type remains "Geometry". Med venlig hilsen / Kind regards Bo Victor Thomsen Den 25-07-2022 kl. 15:52 skrev Hugues François: Hi, I guess you should either => drop the created table prior to launch the ogr2ogr command with the -nlt PROMOTE_TO_MULTI switch => or maually alter the existing table: ALTER TABLE schema.table ALTER COLUMN geom TYPE geometry(MultiPolygon, SRID) using ST_MULTI(geom) HTH, Hug ---- *De: *"Richard Greenwood" *À: *"Bo Victor Thomsen" *Cc: *"gdal dev" *Envoyé: *Lundi 25 Juillet 2022 15:32:35 *Objet: *Re: [gdal-dev] New behaviour of "PROMOTE_TO_MULTI" ? Have you tried -nlt MultiPolygon? On Mon, Jul 25, 2022 at 2:54 AM Bo Victor Thomsen wrote: I have a MapInfo .tab file containing polygons, both simple and multipolygons (and only polygons). Using this command: (all ogr2ogr commands are one-liners, but examples are split for lucidity) ogr2ogr --config PG_USE_COPY yes -progress -lco OVERWRITE=YES -dim XY -f "PostgreSQL" PG:"host=localhost port=5432 user=*** password=*** dbname=geodata" FREDSKOV.TAB will (correctly) create a table in Postgres of PostGIS type "Geometry" If I change the command to: ogr2ogr --config PG_USE_COPY yes -progress -lco OVERWRITE=YES -dim XY * -nlt PROMOTE_TO_MULTI* -f "PostgreSQL" PG:"host=localhost port=5432 user=*** password=*** dbname=geodata" FREDSKOV.TAB I would expect the table to change the PostGIS type to "MultiPolygon". However it still is registered as "Geometry". Checking the table using SQL command: SELECT ST_geometrytype(wkb_geometry), count(*) FROM mat.fredskov group by 1 affirms, that all geometries now is of type "ST_MultiPolygon". AFAIK, this is a new behaviour. Or what ? Postgres/Postgis version : 13.2, 3.1 OGR2OGR version: both 3.4 andf 3.6 dev. -- Med venlig hilsen / Kind regards Bo Victor Thomsen ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev -- Richard W. Greenwood www.greenwoodmap.com <http://www.greenwoodmap.com> [Fichier texte:ATT1]___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
[gdal-dev] New behaviour of "PROMOTE_TO_MULTI" ?
I have a MapInfo .tab file containing polygons, both simple and multipolygons (and only polygons). Using this command: (all ogr2ogr commands are one-liners, but examples are split for lucidity) ogr2ogr --config PG_USE_COPY yes -progress -lco OVERWRITE=YES -dim XY -f "PostgreSQL" PG:"host=localhost port=5432 user=*** password=*** dbname=geodata" FREDSKOV.TAB will (correctly) create a table in Postgres of PostGIS type "Geometry" If I change the command to: ogr2ogr --config PG_USE_COPY yes -progress -lco OVERWRITE=YES -dim XY * -nlt PROMOTE_TO_MULTI* -f "PostgreSQL" PG:"host=localhost port=5432 user=*** password=*** dbname=geodata" FREDSKOV.TAB I would expect the table to change the PostGIS type to "MultiPolygon". However it still is registered as "Geometry". Checking the table using SQL command: SELECT ST_geometrytype(wkb_geometry), count(*) FROM mat.fredskov group by 1 affirms, that all geometries now is of type "ST_MultiPolygon". AFAIK, this is a new behaviour. Or what ? Postgres/Postgis version : 13.2, 3.1 OGR2OGR version: both 3.4 andf 3.6 dev. -- Med venlig hilsen / Kind regards Bo Victor Thomsen ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] ogr2ogr Postgres upload performance
I meant : "I used the "PG_USE_COPY *yes*" option without any other refinements" Med venlig hilsen / Kind regards Bo Victor Thomsen Den 24-05-2022 kl. 08:11 skrev Alexandre Gacon: As far as I remember, I used the "PG_USE_COPY no" option without any other refinements. But I didn't append data to an existing table. YMMV ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] ogr2ogr Postgres upload performance
Hi Alexandre - I made a DOS script ages ago to try the different use cases. It's inserted as text below. It doesn't test every setup combination, only the most pertinent. The base gpkg layer is all the buildings i Denmark, ca. 5.8 million objects. For my layer I had the following results: 1. PG_USE_COPY yes: 182 secs. 2. PG_USE_COPY yes, -gt 1000 (5.8 mill. objects in single transaction) : 181.5 secs. 3. PG_USE_COPY yes, -gt 1000, UNLOGGED ON, SPATIAL_INDEX NO : 152 secs. 4. PG_USE_COPY no : 15 min. So the "PG_USE_COPY yes" is crucial and using unlogged tables and no spatial index reduces the time with an extra 30 sec. But you have to build a spatial index afterwards. Using insert commands is an obvious "no-no" As far as I remember, I used the "PG_USE_COPY no" option without any other refinements. But I didn't append data to an existing table. YMMV === @echo on set pgclientencoding=UTF-8 set cc= ogr2ogr -progress -lco OVERWRITE=YES -lco SCHEMA=fot -a_srs EPSG:25832 -nlt PROMOTE_TO_MULTI -f "PostgreSQL" PG:"host=localhost port=5432 user=xxx password=yyy dbname=zzz" d:/tmp/geodanmark.gpkg bygning echo %time% %cc% --config PG_USE_COPY yes -nln bygning1 echo %time% %cc% --config PG_USE_COPY yes -gt 1000 -nln bygning2 echo %time% %cc% --config PG_USE_COPY yes -gt 1000 -lco UNLOGGED=ON -lco SPATIAL_INDEX=NO -nln bygning3 echo %time% %cc% --config PG_USE_COPY no -nln bygning4 echo %time% pause ======= Med venlig hilsen / Kind regards Bo Victor Thomsen Den 23-05-2022 kl. 15:03 skrev Alexandre Gacon: Hello, I am using ogr2ogr to upload data from several geopackages to a postgis database. Some tables contain thousands of rows (buildings for example). The import of the first file is quite fast (tables are created for the first file so PG_USE_COPY is used) but the following file is much slower (using INSERT instead of COPY). How could I data insertion for the other files? Force PG_USE_COPY ? Increase the value of GT ? Postpone spatial index creation ? Should I concatenate all the geopackages first and then insert the data in Postgis? Thank you for your help -- Alexandre Gacon ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
[gdal-dev] Problems with reading data into SQLServer
Hi all - I'm trying to use ogr2ogr to read shape data into a SQL Server Spatial database using ogr2ogr. The problem is that I have a insert trigger (which is absolutely necessary) on the receiving table. The command is like this: *ogr2ogr.exe --config MSSQLSPATIAL_USE_BCP false -append -skipfailures -a_srs EPSG:25832 -nlt PROMOTE_TO_MULTI -nln gnss_data -lco SCHEMA=transit -lco SPATIAL_INDEX=no -lco GEOMETRY_NAME=sp_geometry -lco FID=mi_prinx -dialect SQLITE -sql "SELECT ID AS id, TYPENAVN AS typenavn, KATEGORI AS kategori, REGISTRE AS registrering, ST_GeometryType(geometry) AS kommentar, DATO AS oprettet, INITIALER AS ini, 'Punkter.shp' AS filepath, geometry as sp_geometry from ""Punkter"" where IsEmpty(geometry) = 0 and IsValid(geometry) = 1" -f "MSSQLSpatial" "MSSQL:server=localhost\SQLExpress;database=drc-spor;trusted_connection=yes;" "Punkter.shp"*** Activates trigger, but is slow (even if I deactivate the trigger) *ogr2ogr.exe --config MSSQLSPATIAL_USE_BCP true -append -skipfailures -a_srs EPSG:25832 -nlt PROMOTE_TO_MULTI -nln gnss_data -lco SCHEMA=transit -lco SPATIAL_INDEX=no -lco GEOMETRY_NAME=sp_geometry -lco FID=mi_prinx -dialect SQLITE -sql "SELECT ID AS id, TYPENAVN AS typenavn, KATEGORI AS kategori, REGISTRE AS registrering, ST_GeometryType(geometry) AS kommentar, DATO AS oprettet, INITIALER AS ini, 'Punkter.shp' AS filepath, geometry as sp_geometry from ""Punkter"" where IsEmpty(geometry) = 0 and IsValid(geometry) = 1" -f "MSSQLSpatial" "MSSQL:server=localhost\SQLExpress;database=drc-spor;trusted_connection=yes;" "Punkter.shp"*** No error and data is correctly read and imported fast, but no trigger activation. ** Is there a qualifier/config option to get a trigger executed even if you are using the bcp-copy method for importing data into SQLServer ? -- Med venlig hilsen / Kind regards Bo Victor Thomsen ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Problems loading swedish climate data to PostGIS
Thimo - The ogr2ogr command from your reply contains an factual error: thiemo @ thiemos-toshi /mnt/schweden % ogr2ogr –f "PostgreSQL" -overwrite –progress --config PG_USE_COPY YES PG:"host='/var/run/postgresql' port='5432' dbname='sverige' user='sverige'" SCID_v4.0.gdb should be: thiemo @ thiemos-toshi /mnt/schweden % ogr2ogr –f "PostgreSQL" -overwrite –progress --config PG_USE_COPY YES PG:"host='/var/run/postgresql' *port='6543*' dbname='sverige' user='sverige'" SCID_v4.0.gdb Anther question: Has the postgresql user 'sverige' the necessary write/create rights to the database / schema ? Den 23-06-2020 kl. 22:35 skrev Thiemo Kellner: thiemo @ thiemos-toshi /mnt/schweden % ogr2ogr –f "PostgreSQL" -overwrite –progress --config PG_USE_COPY YES PG:"host='/var/run/postgresql' port='5432' dbname='sverige' user='sverige'" SCID_v4.0.gdb HBVSv_intrans_HQloc100_rcp85_ensembleMean_diffPerc FAILURE: Unable to open datasource `PostgreSQL' with the following drivers. -> `PCIDSK' ... # UNABLE TO USE ogr2ogr TO WRITE DATA TO MY PostGIS -- Med venlig hilsen / Kind regards Bo Victor Thomsen ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Problems loading swedish climate data to PostGIS
Try change the line: "PG:host='/var/run/postgresql' port='6543' dbname='sverige' user='sverige'" \ to: "PG:host='localhost' port='6543' dbname='sverige' user='sverige'" \ And: Is port really 6543, not 5432 ? What about the password ?, i.e something like: "PG:host='localhost' port='6543' dbname='sverige' user='sverige' password='supersecret'" \ -- Med venlig hilsen / Kind regards Bo Victor Thomsen Den 23-06-2020 kl. 09:27 skrev Thiemo Kellner: Hi I am new to spacial data processing. For a project of mine I try to load swedish climate data in to my PostGIS installation running/using an openSUSE Tumbleweed installation. I downloaded the data from https://www.smhi.se/pd/klimat/rcp_scenario/scid/SCID_v4.0.gdb.zip unzipped it and tried to load the data by ogr2ogr –f "PostgreSQL" \ -overwrite \ –progress \ --config PG_USE_COPY YES \ "PG:host='/var/run/postgresql' port='6543' dbname='sverige' user='sverige'" \ SCID_v4.0.gdb/gdb But I receive the error "Unable to open datasource `PostgreSQL' with the following drivers." (Find the full error message at the bottom. I tried to outsmart by workaround over shp file ogr2ogr –f "ESRI Shapefile" \ -overwrite \ –progress \ SCID_v4.0.gdb/gdb.shp \ SCID_v4.0.gdb/gdb but have been thwarted receiving the analogous error there too. I would appreciate help a great deal. Kind regards Thiemo FAILURE: Unable to open datasource `PostgreSQL' with the following drivers. -> `PCIDSK' -> `netCDF' -> `PDS4' -> `JP2OpenJPEG' -> `PDF' -> `MBTiles' -> `EEDA' -> `ESRI Shapefile' -> `MapInfo File' -> `UK .NTF' -> `OGR_SDTS' -> `S57' -> `DGN' -> `OGR_VRT' -> `REC' -> `Memory' -> `BNA' -> `CSV' -> `NAS' -> `GML' -> `GPX' -> `KML' -> `GeoJSON' -> `GeoJSONSeq' -> `ESRIJSON' -> `TopoJSON' -> `Interlis 1' -> `Interlis 2' -> `OGR_GMT' -> `GPKG' -> `SQLite' -> `ODBC' -> `WAsP' -> `PGeo' -> `MSSQLSpatial' -> `PostgreSQL' -> `MySQL' -> `OpenFileGDB' -> `XPlane' -> `DXF' -> `CAD' -> `Geoconcept' -> `GeoRSS' -> `GPSTrackMaker' -> `VFK' -> `PGDUMP' -> `OSM' -> `GPSBabel' -> `SUA' -> `OpenAir' -> `OGR_PDS' -> `WFS' -> `WFS3' -> `HTF' -> `AeronavFAA' -> `Geomedia' -> `EDIGEO' -> `GFT' -> `SVG' -> `CouchDB' -> `Cloudant' -> `Idrisi' -> `ARCGEN' -> `SEGUKOOA' -> `SEGY' -> `XLS' -> `ODS' -> `XLSX' -> `ElasticSearch' -> `Walk' -> `Carto' -> `AmigoCloud' -> `SXF' -> `Selafin' -> `JML' -> `PLSCENES' -> `CSW' -> `VDV' -> `GMLAS' -> `MVT' -> `TIGER' -> `AVCBin' -> `AVCE00' -> `NGW' -> `HTTP' ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Import Shapefile into SQL Server on Ubuntu
Hi Pete - Your first take on the commandstring probably contains an error... ogr2ogr -f MSSQLSpatial "MSSQL:server=localhost;database=[database-name];username=sa;password=* *;trusted_connection=yes*" [path-to-shape-file] You probably hasn't made the necessary setup with kerberos to use "integrated security" (the "*trusted_connection=yes*" part in the connection string) This command might have worked ( no trusted_connection parameter): ogr2ogr -f MSSQLSpatial "MSSQL:server=localhost;database=[database-name];username=sa;password=*" [path-to-shape-file] Your second take doesn't contain the "trusted_connection" part ogr2ogr -f MSSQLSpatial "MSSQL:server=[server];database=[database];uid=[username];Pwd=[password];Driver={ODBC Driver 17 for SQL Server}" [shape file] > --- Run ogr2ogr using driver > ogr2ogr -f MSSQLSpatial > "MSSQL:server=[server];database=[database];uid=[username];Pwd=[password];Driver={ODBC > Driver 17 for SQL Server}" [shape file] > > > Thanks, > Pete > > -Original Message- > From: gdal-dev On Behalf Of Mateusz > Loskot > Sent: 22 October 2018 16:31 > To: gdal-dev@lists.osgeo.org > Subject: Re: [gdal-dev] Import Shapefile into SQL Server on Ubuntu > > On Mon, 22 Oct 2018 at 17:25, Peter Marlow > wrote: > > > > I’m trying to import a Shapefile into an SQL Server database using > ogr2ogr on Ubuntu. The command I’m running looks like: > > > > ogr2ogr -f MSSQLSpatial > > "MSSQL:server=localhost;database=[database-name];username=sa;password= > > *;trusted_connection=yes" [path-to-shape-file] > > > > It returns an error stating: > > > > ERROR 1: Unable to find driver `MSSQLSpatial'. > > I guess, GDAL/OGR version you are using on Linux is not built with > ODBC/SQL Server support. > > > Is it possible to get the driver on linux? Or use an alternative driver? > I’ve had a google and can’t seem to see any workarounds. > > > > The docs here (https://www.gdal.org/drv_mssqlspatial.html) talk about > > specifying a Driver parameter that could be a custom SQL Server driver, > however this is in the connection string and not as a parameter for the > ogr2ogr command. > > Once you get GDAL/OGR built with SQL Server, install ODBC Driver for SQL > Server (there are clear docs on Microsoft site, you will find easily > searching the web) > > Then, try sticking the Driver option into the connection string > Driver={ODBC Driver 11 for SQL Server} Driver={ODBC Driver 13 for SQL > Server} Driver={ODBC Driver 13.1 for SQL Server} Driver={ODBC Driver 17 for > SQL Server} depending which version you install. > > Best regards, > -- > Mateusz Loskot, http://mateusz.loskot.net > ___ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/gdal-dev > > > SCISYS UK Limited. Registered in England and Wales No. 4373530. > Registered Office: Methuen Park, Chippenham, Wiltshire SN14 0GB, UK. > > Before printing, please think about the environment. > > ___ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/gdal-dev -- Med venlig hilsen Bo Victor Thomsen ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
[gdal-dev] Add timestamp field with value to table during ogr2ogr operation
To the list - I'm converting shapefiles to postgres tables using ogr2ogr. As usual with ogr2ogr, it works very well. Now I want to automatically add an extra column "created" with the current timestamp during the ogr2ogr operation. Something like this: ogr2ogr . -sql "SELECT *, CURRENT_TIMESTAMP AS created FROM point_data" Shapefile name is "point_data.shp" and CURRENT_TIMESTAMP is a SQL92 standard function However, It doesn't work. Is there some way, I can add this timestamp value to the resulting table using a built-in function in ogr2ogr? (The above command works, if you replace "CURRENT_TIMESTAMP" with ex. "OGR_TYPE". Obviously It doesn't produce a timestamp after this edit ;-) Kind regards Bo Victor Thomsen ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
[gdal-dev] Using GDALVectorTranslate() from c# ?
To the list- Has anybody a working c# example of using the GDALVectorTranslate() (ogr2ogr as a function) ? At the moment I have a C# based application calling ogr2ogr as an external program. Terrible hack. Kind regards Bo Victor Thomsen AestasGIS Denmark ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Primary keys are ignored in ogr2ogr when converting from Sqlite databases
Have you tried to use the *-preserve_fid *qualifier*?? * ex. ogr2ogr -preserve_fid -f "SQLite" db2.sqlite db.sqlite test -dsco SPATIALITE=YES Regards Bo Victor Thomsen AestasGIS Den 09-12-2016 kl. 00:21 skrev César Martínez: Hi, I am using ogr2ogr to export data from Spatialite to other formats (such as PostGIS or a new Spatialite db). The layers have an integer primary key, but this field is ignored in the output table, as an OGC_FID field is created which uses consecutive numbers, ignoring the real values of the primary key in the original field. This is quite inconvenient, as the layer is quite useless after loosing the PK. I'll provide one example to make it clearer. - Input data: CREATE TABLE test (id INTEGER NOT NULL PRIMARY KEY, name TEXT NOT NULL); SELECT AddGeometryColumn('test', 'the_geom', 4326, 'POINT', 'XY'); INSERT INTO 'test' (id, name, the_geom) VALUES (1, "row1", GeomFromText('POINT(1.01 2.02)', 4326)); INSERT INTO 'test' (id, name, the_geom) VALUES (3, "row3", GeomFromText('POINT(3.03 4.04)', 4326)); Now we export the table using ogr2ogr: ogr2ogr -f "SQLite" db2.sqlite db.sqlite test -dsco SPATIALITE=YES Now compare both layers: $ ogrinfo -q db.sqlite test Layer name: test OGRFeature(test):1 name (String) = row1 POINT (1.01 2.02) OGRFeature(test):3 name (String) = row3 POINT (3.03 4.04) $ ogrinfo -q db2.sqlite test Layer name: test OGRFeature(test):1 name (String) = row1 POINT (1.01 2.02) OGRFeature(test):2 name (String) = row3 POINT (3.03 4.04) Is this a bug or is an intended behaviour? Is there any way to workaround it? I am using GDAL version 1.11.3. It also happens when exporting to a different format such as PostGIS. Greetings, César Martinez ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Shapefile to SQL Server
I know, what the abbreviation "EPSG" stands for ! And I can't count the number of times I made this particular spelling mistake !! And four times in a row in one mail !!! At least it's weekend... Regards Bo Victor Den 15/04/16 kl. 20:16 skrev Jukka Rahkonen: Bo Victor Thomsen gmail.com> writes: The shape file in the zip is not in projection espg:4269. It's in utm zone 12N. Replace the "-a_srs", "ESPG:4269" with "-t_srs", "ESPG:4269" and "-s_srs", "ESPG: code_for_UTM_12N" This causes ogr2ogr to reproject you data to the correct projection And it is written "EPSG" as in European Petroleum Survey Group. -Jukka Rahkonen- ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Shapefile to SQL Server
The shape file in the zip is not in projection espg:4269. It's in utm zone 12N. Replace the "-a_srs", "ESPG:4269" with "-t_srs", "ESPG:4269" and "-s_srs", "ESPG: /code_for_UTM_12N/" This causes ogr2ogr to reproject you data to the correct projection Bo Victor Thomsen Den 15/04/16 kl. 17:06 skrev Mike Colbert: Hi, I have a Java web app with a SQL Server database and I would like to add support for importing shapefiles. The shapes will then be used to determine if geographic locations we have defined in our system are within the areas defined by the shapes. I’ve gone down the path of using ogr2ogr from Java to connect to SQL Server and load the shapefile. However, I’m getting an error on a particular file I will need to load. I’m wondering if I’m missing an option on the command? Using a different shapefile, it seems to work. Here is the command and the error: String[] cmd = { "-overwrite", "-f", "MSSQLSpatial", "MSSQL:Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx", "C:\\Users\\mcolbert\\Downloads\\UGRB_Ozone_NAA\\UGRB_Ozone_NAA.shp", // error on this one // "C:\\Users\\mcolbert\\Downloads\\tl_2010_06_zcta510\\tl_2010_06_zcta510.shp", // this one seems fine "-lco", "GEOM_TYPE=geography", "-lco", "GEOM_NAME=geog", "-nln", "CM_SHAPE", "--debug", "ON" //,"-a_srs", "ESPG:4269" }; ogr2ogr.main(cmd); OGR: OGROpen(C:\Users\mcolbert\Downloads\UGRB_Ozone_NAA\UGRB_Ozone_NAA.shp/003FFE40) succeeded as ESRI Shapefile. OGR_MSSQLSpatial: EstablishSession(Connection:"Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx") ODBC: SQLDriverConnect(DRIVER=SQL Server;Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx) OGR: OGROpen(MSSQL:Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx/0042C440) succeeded as MSSQLSpatial. MSSQLSpatial: DeleteLayer(cm_shape) OGR_MSSQLSpatial: Using column ogr_fid as FID for table cm_shape. ERROR 1: INSERT command for new feature failed. [Microsoft][ODBC SQL Server Driver][SQL Server]A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": System.FormatException: 24201: Latitude values must be between -90 and 90 degrees. System.FormatException: at Microsoft.SqlServer.Types.GeographyValidator.ValidatePoint(Double x, Double y, Nullable`1 z, Nullable`1 m) at Microsoft.SqlServer.Types.Validator.BeginFigure(Double x, Double y, Nullable`1 z, Nullable`1 m) at Microsoft.SqlServer.Types.Forw Terminating translation prematurely after failed translation of layer UGRB_Ozone_NAA (use -skipfailures to skip errors) I’m assuming there is nothing unusual about the shapefile. The file is available here: http://deq.wyoming.gov/media/attachments/Air%20Quality/Winter%20Ozone/Nonattainment%20Information/2012_AQD_UGRB-Ozone-Nonattainment-Area-GIS-Shape-File.zip Any help is appreciated. Thanks, Mike ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
[gdal-dev] ogr2ogr sqlserver identity field generation.
Is it possible for ogr2ogr to generate a "normal" integer field instead of a "identity" field for the primary key field when creating a new table in MS sqlserver ? (I can't find it in the documentation) Kind regards Bo Victor Thomsen ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Fwd: GDAL/OGR 2.0.2 and 1.11.4 released
Thanks Jürgen for the information - I was getting a little desperate :-) Regards Bo Victor 2016-01-29 14:08 GMT+01:00 Jürgen E. : > Hi Bo Victor Thomsen, > > On Fri, 29. Jan 2016 at 14:01:49 +0100, Bo Victor Thomsen wrote: > > Is there anywhere I can download Windows binaries of these GDAL > versions ? > > (gisinternals.com doesn't contain ver. 2.0.n) > > osgeo4w contains 2.0.2 (not yet the final, but RC2 I think) as experimental > (enable Exp in the installer). > > > Jürgen > > -- > Jürgen E. Fischer norBIT GmbH Tel. > +49-4931-918175-31 > Dipl.-Inf. (FH) Rheinstraße 13 Fax. > +49-4931-918175-50 > Software Engineer D-26506 Norden > http://www.norbit.de > QGIS release manager (PSC) GermanyIRC: jef on FreeNode > > ___ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev > -- Med venlig hilsen Bo Victor Thomsen ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
[gdal-dev] Fwd: GDAL/OGR 2.0.2 and 1.11.4 released
Is there anywhere I can download Windows binaries of these GDAL versions ? (gisinternals.com doesn't contain ver. 2.0.n) Regards Bo Victor Thomsen -- Forwarded message -- From: Even Rouault Date: 2016-01-29 12:16 GMT+01:00 Subject: [gdal-dev] GDAL/OGR 2.0.2 and 1.11.4 released To: gdal-dev@lists.osgeo.org, gdal-annou...@lists.osgeo.org Hi, On behalf of the GDAL/OGR development team, I am pleased to announce the release of the GDAL/OGR 1.11.4 and 2.0.2 bug fix versions. They contain respectively 44 and 92 bug fixes since 1.11.3 / 2.0.1. The sources for 1.11.4 are available at: http://download.osgeo.org/gdal/1.11.4/gdal-1.11.4.tar.xz http://download.osgeo.org/gdal/1.11.4/gdal-1.11.4.tar.gz http://download.osgeo.org/gdal/1.11.4/gdal1114.zip The sources for 2.0.2 are available at: http://download.osgeo.org/gdal/2.0.2/gdal-2.0.2.tar.xz http://download.osgeo.org/gdal/2.0.2/gdal-2.0.2.tar.gz http://download.osgeo.org/gdal/2.0.2/gdal202.zip Details on the fixes in those releases are available at: http://trac.osgeo.org/gdal/wiki/Release/1.11.4-News http://trac.osgeo.org/gdal/wiki/Release/2.0.2-News It is not definite how long the team will still maintain the 1.11 branch, so users are strongly encouraged to migrate to 2.0.2. Best regards, Even -- Spatialys - Geospatial professional services http://www.spatialys.com ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Problem with using ogr2ogr to migrate data from Postgis to TSQL/Oracle Spatial
Have you tried typecasting your "timestamp with time zone" to a "timestamp witout time zone" as a workaround ? *ogr2ogr ... -sql "select id, date_modified::timestamp, geom from public.my_geometry_table" ...* Regards Bo Victor Thomsen AestasGIS Denmark ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
[gdal-dev] http://www.gisinternals.com down ??
http://www.gisinternals.com is not accessible at the moment. Is there any alternatives for downloading binary windows versions of GDAL/OGR ? Regards Bo Victor Thomsen ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Importing completely MITAB into GDAL source tree ?
A very big +1 from me (As an occasional user of MiTab and a very small contributor to MiTab) Regards Bo Victor Thomsen AestasGIS Denmark Den 01-10-2014 14:07, Even Rouault skrev: Hi, As some of you know, the OGR MapInfo driver heavily depends on the source code of the MITAB library. Over the years, people have contributed fixes and improvements through GDAL. Not all those changes have made their way in the official MITAB repository that sits at https://github.com/mapgears/mitab and which has not evolved a lot in comparison to its copy in OGR. Maintaining 2 copies and synchronizing them is a time consuming and error- prone process. On the other hand, there are still people that depend on the standalone MITAB library, its utilities (tab2tab, etc...) and its dedicated C API. So I'm wondering if it wouldn't be more efficient to import those specific remaining parts (standalone build scripts, C API and utilities) into the GDAL source tree (probably a ogr/ogrsf_frmts/mitab/build and ogr/ogrsf_frmts/mitab/apps) That way both projects would share the same code in a very obvious way, while keeping their specificities. Thoughts ? Even ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Try to create a .bat for ogr2ogr
João - Try to get to ogr2ogr command to work (or not work) from GDAL command-line environment (SDKShell.bat) with one shape file. And don't depend on defaults in the database connection string, ie. PG:"*host=localhost port=5432 *dbname='temp_gis' user='test_user' password='test_pss'" You might try to simply create a new table in stead of appending to an existing table. At a glance I suspect you have some kind of permission problem in the database Checkpoint 101: 1. Have you a Postgres/Postgis databaser server installed at localhost and listening on port 5432 ? 2. Is your database user and password set correctly ? 3. Has you a database 'temp_gis' with PostGIS enabled running on the local database server ? 4. Has you a schema 'temp' in the database and a table 'upload' in schema ? 5. Has the table the right structure and a geometry column ? 6. Does the database user has permission to write data to the table ? I suspect that no. 5 or 6 is the culprit. Regards Bo Victor Thomsen Aestas-GIS Denmark Den 29-08-2014 12:45, João Gaspar skrev: Hi guys, i'm giving the first steps in this kind of programming. So the scenario is: I have a lot of users that dump work shapfiles into a folder, then i need to upload this files to a database into a single table (at this time i'm testing the PostGIS). So I read some snippets code and some tutorials and i try to do the .bat but at this time i have some errors. Note: I put the name of user and password with dummy value :) The error that give me for the 2 test shapefiles that i try to import is: ERROR 1: Unable to write feature 0 from layer Polygon1. ERROR 1: Terminating translation prematurely after failed translation of layer Polygon1 (use -skipfailures to skip errors) ERROR 1: Unable to write feature 0 from layer Polygon2. ERROR 1: Terminating translation prematurely after failed translation of layer Polygon2 (use -skipfailures to skip errors) My actual code of the .bat is: @echo off for %%I in (inputs_pggis\*.shp) do ( echo Import shapefile %%~nxI to schema temp.upload Tabela PostGIS ... ogr2ogr -append -update -f PostgreSQL PG:"dbname='temp_gis' user='test_user' password='test_pss'" inputs_pggis/%%~nxI -nln temp.upload ) Best Regards, João ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] processing map styles with OGR tools
You might have a look at Boundless's (former OpenGeo) QGIS plugin. It has some functions to convert QGIS style to GeoServer SLD styles: http://boundlessgeo.com/solutions/solutions-software/qgis/ Regards Bo Victor Thomsen Aestas-GIS Denamrk Den 08-02-2014 11:10, Kay F. Jahnke skrev: Hi group! I'm working on a large corpus of historical map data (the CTRN of the Piedmont Region in Italy). To visualize the data (shapefiles) I have created QGIS style files. Later I wrote style files to make the data into a GPS map using mkgmap. Currently I am setting up geoserver to serve the data as a WMS layer. So obviously I have to write yet another set of style files. I'm getting tired of this and I wish I could just translate style files from one format to another. QGIS now offers to store it's styles as SLD, but so far I've had limited success in using the SLD files made that way in geoserver; they seem to be to QGISish and would need a fair bit of editing. When browsing the OGR website, I noticed there was a section http://www.gdal.org/ogr/ogr_feature_style.html This sounds more like a proposal and hasn't been edited since 2011, but the idea is, of course, attractive. Is there any concrete code or are there any tools along these lines? Or are there tools from other sources for the purpose? with regards Kay F. Jahnke ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] effects of differences in .tgf and .tab files on Tiff imports
To Tim Southern - GDAL uses several different methods find information to georeference tiff files (Disclaimer: I'm not at all familiar with THE GDAL codebase and just had a brief look at the relevant c++ files): 1. GDAL look for georeference information embedded in the tiff file and will use it to georeference the file. 2. If no 1 fails it will look for a corresponding .twf or similar named files and read 6 parameters from it to establish affine transformations to/from the "pixel" coordinate system and the "world" coordinate system. 3. If no 2 fails it will look for a corresponding .tab file, read the ground control points (GCP) and establish the transformations using these GCP's. So, if your tiff file doesn't contain embedded information, GDAL wil use the twf file. However: (And now I'm making some big assumptions): * I assume the size of the tiff file is 4724 x 4724 * I assume the upper leftmost _egde_ of the image is at position 459000,181000 in the coordinate system. * I assume the lower rightmost _edge_ of the image is at position 46,18 in the coordinate system, making the tiff file 1000 x 1000 m in size in "world" coordinates This will make the pixel height and width approx. 0.2116850127 meters, not 0.21168 as implied in the twf file. *If* my assumptions are correct both the tfw and the tab-file contains incorrect parameters. The twf should look like this: 0.2116850127 0.0 0.0 -0.2116850127 459000.10584250635 180999.89415749365 The translation parameters (last 2 lines) is defined from the center of the pixel, not the edge The tab file should look like this: !table !version 300 !charset WindowsLatin1 Definition Table File "02SU5980.tif" Type "RASTER" (459000.10584250635, 180999.89415749365) (0,0) Label "Pt 1", (45.89415749365, 180999.89415749365) (4723,0) Label "Pt 2", (45.89415749365, 18.10584250635) (4723,4723) Label "Pt 3", (459000.10584250635, 18.10584250635) (0,4723) Label "Pt 4" CoordSys Earth Projection 8, 79, "m", -2, 49, 0.9996012717, 40, -10 The number of decimals might be a slight "overkill" :-) (The tab file doesn't contains any kind "rectangle" definitions; the GCP's could be placed anywhere in the image. But normally they are defined for the corners of the image) Regards Bo Victor Thomsen Aestas-GIS Denmark Den 20-01-2014 11:02, Tim Southern skrev: Dear Sir/Madame, I have recently downloaded a number of historic analogue maps which have associated .twf and .tab files. I notice that both these text files are required by GDAL for geo-referencing according to the information given on the appropriate web page for inputing tiff/geotiff files. In this particular case the two files are not compatible with each telling the system slightly different things. I have copied the contents below. How will GDAL handle this situation? Thanks Tim Southern .tab file !table !version 300 !charset WindowsLatin1 Definition Table File "02SU5980.tif" Type "RASTER" (459000, 181001) (0,0) Label "Pt 1", (45, 181001) (4723,0) Label "Pt 2", (45, 180001) (4723,4723) Label "Pt 3", (459000,180001) (0,4723) Label "Pt 4" CoordSys Earth Projection 8, 79, "m", -2, 49, 0.9996012717, 40, -10 and the .twf file is 0.21168000 0. 0. -0.21168000 459000. 181000. The .tab file gives coordinates for the pixel 0, 0 as 459000, 181001 whereas the .twf file defines the same pixel as 459000, 181000. The .tab file gives coordinates for the pixel 4723,0 as 45, 181001 whereas the .twf gives the same pixels as 45.76464, 181000. The .tab file gives coordinates for the pixel 4723, 4723 as 45, 180001 whereas .twf file gives same point as 45.76464, 18.23536 The .tab file gives coordinates for the pixel 0, 4723 as 459000, 180001 whereas .twf file gives same point as 459000, 18.23536 Another obvious difference is .tab file define a rectangle 999 by 1000 metres whereas the .twf file defines a square 999.76464 by 999.76464 metres. Tim Southern 17, Park Close, Sonning Common, Oxfordshire RG4 9RY ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev