Hot answers tagged

35

Grab a copy of the ogr2ogr Python port, which is distributed with the GDAL source code download or can be found here: http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/ogr2ogr.py Once you import that into your code, you can use it like this: import ogr2ogr def main(): #note: main is expecting sys.argv, where the first argument is the script name ...


17

You Can use ogr2ogr. Simplest to install it would be to download fwTools. the following command will do ogr2ogr -f "GeoJSON" E:\lakes.geojson e:\lakes.gml Else if you have QuantumGIS, you can add your GML layer to map and by Right-Clicking the Layer, Select Save As to GeoJSON format.


11

You can analyze polylines in amazing ways by using buffers. This is usually inefficient--buffers create many additional vertices--but (a) it is a technique available in many GISes (vector or raster based) and (b) it sometimes can produce information that is otherwise hard to get. In this case, buffering the road by a small amount and then buffering by the ...


11

You can't really choose either because as a GIS Professional data will come at you in a million different formats and you need to handle everything. This is why GDAL/OGR has so many translation algorithms. More importantly, neither format is a 'beautiful' way of managing and storing GIS data. For real GIS data management you want to use one of the ...


10

Shapefile as a temporary file format is not necessary and it may also alter the GML data (shorten attribute names, cut strings to max 255 characters, change DATETIME to DATE etc.) I would use ogr2ogr not by dropping unwanted attributes but by selecting those which are wanted. The SQLite SQL dialect is more standard than the defauld OGR dialect, that's why I ...


9

A great GIS that has a huge amount of functionality is QGIS. It is very easy to install especially if you use the osgeo4w installer (Windows). You can use it to view your GML file too. OSGeo is the place you want to look for OpenSource (free) GIS tools and libraries: http://www.osgeo.org/. You will find a ton of stuff here plus links to QGIS and other ...


9

GML, http://en.wikipedia.org/wiki/Geography_Markup_Language KML, http://en.wikipedia.org/wiki/Keyhole_Markup_Language GML / KML difference http://en.wikipedia.org/wiki/Geography_Markup_Language#GML_and_KML


9

If it is for using and editing in a gis system i would stick to shapefiles. This format is well supported by all GIS software.


9

Yes, srsName="EPSG:abcd" is GML-3 compliant but only in an application context where EPSG:abcd points to a CRS definition. As of 2013, OGC best practice (documented here) is to use http URIs of the form http://www.opengis.net/def/crs/EPSG/0/4326. The GML-3.0.0 spec (OCG 02-023r4) section v.2, page xiv states aliasing CRSs is kosher: in GML we have found ...


8

You can delete a field using OGR SQL and choosing an OGR format which supports the field deletion. Unfortunately GML doesn't support it, so you have to pass through another format, e.g. SHP: ogr2ogr temp.shp input.gml ogrinfo temp.shp -sql "ALTER TABLE temp DROP COLUMN field_to_drop" ogr2ogr -f GML output.gml temp.shp


7

From W3C's Extensible Markup Language (XML) 1.0 (Fifth Edition) recommendation: [Definition: The XML document type declaration contains or points to markup declarations that provide a grammar for a class of documents. This grammar is known as a document type definition, or DTD. The document type declaration can point to an external subset (a special kind ...


7

I don't understand if lines are understood by QGIS on kml layer well enough to be saved as Shapefile I'm not aware of any problems. If the lines are displayed correctly on the map, export to Shapefile should work too. You already found the solution: Save the GML as Shapefile and you can edit that. From the mailing list: The state of the "Toggle ...


7

If you have ArcGIS and if you have also installed the Data Interoperability Extension (ArcGIS-integrated version of FME by Safe Software), you can read simple GML and WFS data sources without a license for the extension (source). As long as your GML data sticks to the GML Simple Features profile, you do not need to enable the Data Interoperability Extension,...


7

No, GeoJSON is not an OGC standard: IETF Geographic JSON Working Group The Internet Engineering Task Force, in conjunction with the original specification authors, has formed the Geographic JSON WG to standardize the format. Work continues on GitHub at https://github.com/geojson/draft-geojson.


7

Time to ditch the shapefile! Here's a reproducible example using a combination of packages sf, gdalUtils and dplyr: library(sf) library(dplyr) library(mapview) library(gdalUtils) ## as an example we take nc shapefile from package sf shpfile = system.file("shape/nc.shp", package = "sf") ## set working directory (where to save the converted file) setwd("...


6

You could give the GDAL/OGR utility ogr2ogr a try. It has to capability to convert between many formats of vector spatial data. GDAL/OGR Downloads ogr2ogr Utility OGR GML Driver Documentation Depending on the flavor of your XML/GML it may be able to extract the spatial components straight away, and be as simple as: ogr2ogr -f "esri shapefile" path\to\...


6

Every XML document essentially has some given structure. When the structure is formally specified, we usually talk about a given XML grammar. The formal specification can take many forms, e. g. DTD (Document Type Definition) or XML Schema Definition (XSD). XSD itself is a XML document and is now being used for GML. There are also other means of specifying ...


6

You can use Python shapefile library pyshp >>> import shapefile >>> sf = shapefile.Reader("shapefiles/blockgroups") >>> shapes = sf.shapes() >>> # Read the bounding box from the 4th shape >>> shapes[3].bbox [-122.485792, 37.786931000000003, -122.446285, 37.811019000000002] >>># Read the 8th point in the ...


6

Same reason --> OGR does not support multiple geometries in one feature http://www.weichand.de/2012/08/26/qgis-wfs-2-0-plugin-update/comment-page-1/#comment-8177 ~~ UPDATE ~~ After the first import of your GML-file there will be a .gfs file in the same directory. This file contains the following part: <Name>CadastralParcel</Name> <...


6

I enjoy using ElementTree. It's standardized in Python since 2.5 as xml.etree.ElementTree. Forgive me for being blunt, but you're using it wrong. I suggest trying the find, findtext, and findall methods when you know the structure of the data. Is Order your root element? If so, >>> geography = rootElement.find('OrderRequest/SiteGeography') >>...


5

When someone designs a class of XML documents for representing information in a particular domain, they will sometimes call this an XML grammar, or a vocabulary, or a schema, or a document type, or even a language. The terminology isn't consistent. There's perhaps a different emphasis: calling it a schema implies that an XML Schema is the primary way in ...


5

Based on Filter Encoding with Spatial Filter within WFS-Request and Geoserver Filter. I found that there is a parameter named filter and the value can enter like this: http://localhost:8080/geoserver/tiger/ows?service=WFS&version=1.0.0 &request=GetFeature&typeName=tiger:poi&maxFeatures=2 &filter=<PropertyIsEqualTo><PropertyName&...


5

We have a new tool which you can load large number of Ordnance Survey's MasterMap into PostGIS. The tool is written from scratch and is pretty fast compared with others: http://www.lutraconsulting.co.uk/products/ostranslator-ii/ http://www.lutraconsulting.co.uk/blog/2015/02/23/loading-mastermap-free-easy-fast/


5

You will probably find much better answers than I can give you at http://www.gis.usu.edu/~chrisg/python/2009/lectures/ospy_slides1.pdf and http://trac.osgeo.org/gdal/wiki/GdalOgrInPython. Try there or another tutorial linked from the second URL and maybe ask another more specific question if you are stuck.


5

Read up on os.system or os.popen or subprocess. Or just use ogr2ogr and your shell. Even cmd.exe (Windows) lets you loop over input files.


4

You can try some of the CanVec data, available here. Some of those files range from 4 MB to 50GB, depending on the one you choose.


4

ST_GeomFromGML You can store your GML features as a PostGIS Geometry datatype by using the ST_GeomFromGML function which will convert your GML to the geometry datatype. FYI: There are similar functions for KML, WKT, and so on. just do something like: INSERT into myTable (mygeomField) values (ST_GeomFromGML(' <gml:LineString srsName="EPSG:4269"> ...


4

The simple answer is no. The complex answer is may be but you'll need to understand and use the complex feature extension (http://docs.geoserver.org/stable/en/user/data/app-schema/complex-features.html). This is non trivial so you might want to think about other ways of doing this like making a second request using the boundary of the state polygon as a ...


4

Check in Firebug (Firefox) or Fiddler (IE) if your file internet_users_2005.json.fixed is in fact being loaded. I suspect there's a problem with the path.


4

You can add this projection to the projection table postgis uses and then refer to it with the new name (97460 or SR-ORG:7460 in this case): INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) values ( 97460, 'sr-org', 7460, '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +...


Only top voted, non community-wiki answers of a minimum length are eligible