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:
#note: main is expecting sys.argv, where the first argument is the script name
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.
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 ...
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 ...
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 ...
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 ...
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 ...
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
Time to ditch the shapefile!
Here's a reproducible example using a combination of packages sf, gdalUtils and dplyr:
## 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)
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,...
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 ...
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.
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 ...
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 ...
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 ...
You could give the GDAL/OGR utility ogr2ogr a try. It has to capability to convert between many formats of vector spatial data.
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\...
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
[-122.485792, 37.786931000000003, -122.446285, 37.811019000000002]
>>># Read the 8th point in the ...
Same reason --> OGR does not support multiple geometries in one feature
~~ 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:
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')
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:
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:
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.
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 +...
Maybe this triggers some new ideas: I've got an application running where users can edit a map with many elements.
Instead of sending all data as WFS, I use WMS maps, and when the user clicks, or draws a selection, I fetch the selected items as WFS.
After sending an update back to the server, I refresh the WMS layer.
There are some OpenLayers examples ...
Yes, using the command line ogr2ogr tool.
For example, given a "roads.shp" file, you could convert it using the following:
ogr2ogr -f GML roads.gml roads.shp
ogr2ogr provides a large array of options, so you might want to review them prior to executing. You can also use the tool to create only a subset of the input data and also reproject the output.